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

Not able to delete table control lines : Table control wizard

Former Member
0 Likes
1,044

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

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

6 REPLIES 6
Read only

lijisusan_mathews
Active Contributor
0 Likes
804

have you added this line.. or was it there in teh generated code ?/

REFRESH CONTROL 'TC1_BOQ' FROM SCREEN '9000'.

Suzie

Read only

0 Likes
804

Also is the select field name = 'FLAG' for your table control ?

Suzie

Read only

0 Likes
804

Hi Suzie!!!

Yes I have added the line which you are referring to i.e. REFRESH control TC1_BOQ FROM SCREEN '9000'.

Apart from that I have added FLAG field in my dictionary structure and the same I am referring to in Table control.

Cheers

VJ

Read only

0 Likes
804

First can you put a break point in your code and see if the code is getting accessed.

The code seems to fine except for the Refresh statement. I think it should come after the loop.

In debugging mode, Can you check if the line is getting deleted after the delete statement ?

Suzie

Read only

0 Likes
804

I have checked it....

Records are not getting deleted

Read only

0 Likes
804

Solved it myself. Problem was there is one line between CHAIN and ENCHAIN statement

PROCESS AFTER INPUT.
MODULE exit AT EXIT-COMMAND.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC1_BOQ'
  LOOP AT G_TC1_BOQ_ITAB.
    CHAIN.
      FIELD ZPS_BOQ-PROJ_DEF.
      FIELD ZPS_BOQ-WBS_ELMNT.
      FIELD ZPS_BOQ-MAT_CODE.
      FIELD ZPS_BOQ-PARNT_MAT.
      FIELD ZPS_BOQ-CHECK_PRNT.
      FIELD ZPS_BOQ-BOQ_QTY.
      FIELD ZPS_BOQ-SURVEY_QTY.
      FIELD ZPS_BOQ-UOM.
      FIELD ZPS_BOQ-RATE.
      *FIELD ZPS_BOQ-flag.*  " +This line was commented earlier. After uncommenting it it started working+
      MODULE TC1_BOQ_MODIFY ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.

Cheers

VJ