Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete line in table control

Former Member
0 Likes
1,010

Hi Friends,

Kindly explain with sample code as to how to delete lines from the table control.

TIA.

Regards,

Mark K

Hi Friends,

Kindly explain with sample code as to how to delete lines from the table control.

TIA.

Regards,

Mark K

6 REPLIES 6
Read only

Former Member
0 Likes
915

Hi,

Tip to delete a selected record

1) write a module 'Mark' in the PAI as below

PROCESS AFTER INPUT.

MODULE cancel AT EXIT-COMMAND.

LOOP WITH CONTROL table_view.

MODULE read_table_control.

FIELD flag MODULE mark ON INPUT.

ENDLOOP.

MODULE user_command_0100.

2) Module Mark is below.

MODULE mark INPUT.

CHECK flag = 'X'.

x = table_view-top_line + sy-stepl - 1.

Delete itab INDEX x.

ENDMODULE. " mark INPUT

Table_view is the TableControl Name.

'flag' is of type char(1) available in the Internal table which was assigned to the select option in the table control.

Regards,

Padmam.

Read only

0 Likes
915

What does the following part indicates.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: cols LIKE LINE OF flights-cols,

lines TYPE i.

Kindly explain.

Regards

Read only

Former Member
0 Likes
915

you need to delete the lines from the internal Table on which the TC is based.

Read only

Former Member
0 Likes
915

Hi

First select the lines that are to be deleted in table control with the help of selection indicator into a Internal table.

Loop at itab where v_sel = 'X'.

move these records into another internal table ITAB1.

endloop.

In PAI

case OK code.

When 'DELE'.

modify <db table> from Itab1.

endcase.

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
915

I am not clear with this. Could any one pls give more simpler code. Basically, I want to understand, how to mark the internal table with 'X' for those selected line in the table control.

Regards,

Read only

Former Member
0 Likes
915
   
CONTROLS: TC1 TYPE TABLEVIEW USING SCREEN 0200.
  OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING    'TC1'
                              'G_TC1_ITAB'
                              'FLAG'
                     CHANGING OK_CODE.


    FORM USER_OK_TC USING    P_TC_NAME TYPE DYNFNAM
                          P_TABLE_NAME
                          P_MARK_NAME
                 CHANGING P_OK      LIKE SY-UCOMM.
DATA: L_OK              TYPE SY-UCOMM,
         L_OFFSET          TYPE I.
 SEARCH P_OK FOR P_TC_NAME.
   IF SY-SUBRC <> 0.
     EXIT.
   ENDIF.
   L_OFFSET = STRLEN( P_TC_NAME ) + 1.
   L_OK = P_OK+L_OFFSET.CASE L_OK.
     WHEN 'INSR'.                      "insert row
       PERFORM FCODE_INSERT_ROW USING    P_TC_NAME
                                         P_TABLE_NAME.
       CLEAR P_OK.

     WHEN 'DELE'.                      "delete row
       PERFORM FCODE_DELETE_ROW USING    P_TC_NAME
                                         P_TABLE_NAME
                                         P_MARK_NAME.
       CLEAR P_OK.
ENDCASE.
 ENDFORM.                              " USER_OK_TC

FORM fcode_delete_row
               USING    P_TC_NAME           TYPE DYNFNAM
                        P_TABLE_NAME
                        P_MARK_NAME   .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
   DATA L_TABLE_NAME       LIKE FELD-NAME.

   FIELD-SYMBOLS <TC>         TYPE cxtab_control.
   FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.
   FIELD-SYMBOLS <WA>.
   FIELD-SYMBOLS <MARK_FIELD>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc                     *
   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline

*&SPWIZARD: delete marked lines                                        *
   DESCRIBE TABLE <TABLE> LINES <TC>-LINES.

   LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header         *
     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

     IF <MARK_FIELD> = 'X'.
       DELETE <TABLE> INDEX SYST-TABIX.
       IF SY-SUBRC = 0.
         <TC>-LINES = <TC>-LINES - 1.
       ENDIF.
     ENDIF.
   ENDLOOP.

 ENDFORM.                              " FCODE_DELETE_ROW


reward points if it is usefull ..

Girish