Skip to Content
author's profile photo Former Member
Former Member

hai

How to delete a selected row of table control from database.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 21, 2008 at 04:38 AM

    Hi,

    Try this code to the get the current line

    DATA: v_sel_line LIKE sy-loopc,

    v_tabix LIKE sy-tabix.

    GET CURSOR LINE v_sel_line.

    v_tabix = tc-top_line + ( v_sel_line - 1 ).

    tc will be your table control name.

    v_tabix will have the current line.

    Then use READ TABLE with V_TABIX to get the current

    row value.

    Now based on internal table value

    DELETE FROM dbtab WHERE cond.

    Pls. reward if useful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 21, 2008 at 04:47 AM

    Hi,

    Procedure for Table control line selection and modifying master table using those values.

    1).

    U should take one variable in your internal table or in structure which is used for table control fields

    ex :

    data :
    begin of itab occurs 0 ,
        mark type c ,  "This is used to select record on table control.
        matnr like mara-matnr ,
        matkl like mara-matkl,
        maktx like makt-maktx,
    end of itab .
    
    Controls: TABC types TABLEVIEW using screen 100.

    2).

    This mark variable should be given in Table control properties.

    follow the path

    double click on the table control-- >attributes . ->select

    w/SelColumn and in that itab-mark. Check in the figure.

    Click here [Table control Attributes screen|http://bp2.blogger.com/_O5f8iAlgdNQ/R99gOUH8CXI/AAAAAAAAA9I/d3gOum1fJ6s/s1600-h/pic28145-796618.jpg]

    3).

    After that. Take this example.

    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    LOOP AT ITAB WITH CONTROL tabc
    ENDLOOP.
    
    PROCESS AFTER INPUT.
    MODULE CANCEL AT EXIT-COMMAND.
    LOOP AT ITAB.
       Module read_table_control.
    ENDLOOP.
    module user_command_0100

    .

    In this Module read_table_control, You should write the following code

    MODULE read_table_control INPUT.
    MODIFY itab INDEX tabc-current_line.
    "( This will update the ITAB tableMARK field with 'X ' whatever 
    "we have selected on table control.)
    ENDMODULE.

    4)

    If you want to Delete some of the records from Table control

    follow this code Â…Create one pushbutton and give Fucnction code to that

    and write below code

    CASE OKCODE
      WHEN 'DELETE'.
         LOOP AT itab WHERE mark = 'X'.
            DELETE itab.
         ENDLOOP.
    ENDCASE.

    I hope that u will get.

    Regards,

    Venkat.O

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 21, 2008 at 05:10 AM

    Table Controls: Examples with Modifications Locate the document in its SAP Library structure

    The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a function code.

    Example

    REPORT demo_dynpro_tabcont_loop_at.

    CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

    DATA: cols LIKE LINE OF flights-cols,

    lines TYPE i.

    DATA: ok_code TYPE sy-ucomm,

    save_ok TYPE sy-ucomm.

    DATA: itab TYPE TABLE OF demo_conn.

    TABLES demo_conn.

    SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

    LOOP AT flights-cols INTO cols WHERE index GT 2.

    cols-screen-input = '0'.

    MODIFY flights-cols FROM cols INDEX sy-tabix.

    ENDLOOP.

    CALL SCREEN 100.

    MODULE status_0100 OUTPUT.

    SET PF-STATUS 'SCREEN_100'.

    DESCRIBE TABLE itab LINES lines.

    flights-lines = lines.

    ENDMODULE.

    MODULE cancel INPUT.

    LEAVE PROGRAM.

    ENDMODULE.

    MODULE read_table_control INPUT.

    MODIFY itab FROM demo_conn INDEX flights-current_line.

    ENDMODULE.

    MODULE user_command_0100 INPUT.

    save_ok = ok_code.

    CLEAR ok_code.

    CASE save_ok.

    WHEN 'TOGGLE'.

    LOOP AT flights-cols INTO cols WHERE index GT 2.

    IF cols-screen-input = '0'.

    cols-screen-input = '1'.

    ELSEIF cols-screen-input = '1'.

    cols-screen-input = '0'.

    ENDIF.

    MODIFY flights-cols FROM cols INDEX sy-tabix.

    ENDLOOP.

    WHEN 'SORT_UP'.

    READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

    IF sy-subrc = 0.

    SORT itab STABLE BY (cols-screen-name+10) ASCENDING.

    cols-selected = ' '.

    MODIFY flights-cols FROM cols INDEX sy-tabix.

    ENDIF.

    WHEN 'SORT_DOWN'.

    READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

    IF sy-subrc = 0.

    SORT itab STABLE BY (cols-screen-name+10) DESCENDING.

    cols-selected = ' '.

    MODIFY flights-cols FROM cols INDEX sy-tabix.

    ENDIF.

    WHEN 'DELETE'.

    READ TABLE flights-cols INTO cols

    WITH KEY screen-input = '1'.

    IF sy-subrc = 0.

    LOOP AT itab INTO demo_conn WHERE mark = 'X'.

    DELETE itab.

    ENDLOOP.

    ENDIF.

    ENDCASE.

    ENDMODULE.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.