Skip to Content
0
Former Member
Feb 24, 2011 at 04:17 AM

Not able to delete table control lines : Table control wizard

239 Views

Hi Experts,

I am facing one issue from a long time. I have created a TC through wizard. Now when I am trying to delete one or multiple records in the table control, they are not getting deleted. Please help and find the below code:

MODULE TC1_BOQ_USER_COMMAND INPUT.
  OK_CODE = SY-UCOMM.
  PERFORM USER_OK_TC USING    'TC1_BOQ'       'G_TC1_BOQ_ITAB'     'FLAG'                      CHANGING OK_CODE.
  SY-UCOMM = OK_CODE.
ENDMODULE.

FORM USER_OK_TC USING    P_TC_NAME TYPE DYNFNAM          P_TABLE_NAME     P_MARK_NAME                                                                                
CHANGING P_OK      LIKE SY-UCOMM.
     WHEN 'DELE'.                      "delete row
       PERFORM FCODE_DELETE_ROW USING    P_TC_NAME   P_TABLE_NAME   P_MARK_NAME.
 FORM fcode_delete_row
               USING    P_TC_NAME           TYPE DYNFNAM
                        P_TABLE_NAME
                        P_MARK_NAME.
               "CHANGING P_TABLE_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.
       REFRESH CONTROL 'TC1_BOQ' FROM SCREEN '9000'.
     ENDIF.
   ENDLOOP.
 ENDFORM.

Cheers

VJ