Application Development 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: 

Module Pool - Delete Button

Former Member
0 Kudos

Hi Experts,

I have this requirement, I need to display some set of data in form of a table control as soon as the transaction is entered and those data will be in disabled mode.Its clear that, this will happen in PBO.

Only thing that the user can do is, just delete the entries

Now, if the user selects any entry from the given display list and presses the Delete button, then that entry has to be deleted from the table control list, with a pop-up information message like "Are sure to delete this entry" .

Can anyone share some lines of code regarding this ?

Thanks

Chandan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You have to give a column SEL in your table control add this button in your table control attributes in screen painter.

Then read selected record in PAI where SEL = 'X' from the internal table .

This will give you the selected record then you can delete that particular record from table.

Hope it helps in resolving your problem.

8 REPLIES 8

Former Member
0 Kudos

Hi,

You have to give a column SEL in your table control add this button in your table control attributes in screen painter.

Then read selected record in PAI where SEL = 'X' from the internal table .

This will give you the selected record then you can delete that particular record from table.

Hope it helps in resolving your problem.

0 Kudos

That was nice, just can you be bit more elaborate in describing that.

Thanks

Chandan

0 Kudos

Add that SEL column (which you have declared in table control attribute w/e selcolumn )to your internal table.

Add a delete button on screen

In PAI, handle that button when sy-ucomm = <function code of your buton>

Read <tabname > in to <work area > where sel = 'X'

Delete <inter tabnme > from <work area selected>

You can use "POP_UP_TO_CONFRIM " function module to give popup message for user confirmation.

Hope it resolves your problem.

0 Kudos

That was a great answer, just 1 last question, can you tell me how to add the SEL of Table Control to the internal table ?

Thanks

Chandan

0 Kudos

Declare a internal table in your main program having same fields as in your table control, In the type declaration of of your internal table also add field SEL type c.

0 Kudos

How to define sel in the program?

Former Member
0 Kudos

HI,

Check this Code.. you need to declare the flag field in the internal table and pass this field in the Table Control attributes Selection col. name and select the check box With Sel column*.

WHEN 'DELETE'.
 *     Routine to delete the Selected records
      PERFORM delete_records.

 FORM delete_records .
   DATA :
     lv_answer,
     lv_lines TYPE i.

   REFRESH it_delrec.
   CLEAR g_val_BENE_maint_wa.

   CALL FUNCTION 'ENQUEUE_E_TABLE'
     EXPORTING
       tabname        = 'ZVAL_BENEFIT'
     EXCEPTIONS
       foreign_lock   = 1
       system_failure = 2
       OTHERS         = 3.
   IF sy-subrc <> 0.
     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   ENDIF.

   LOOP AT g_val_BENE_maint_itab INTO g_val_BENE_maint_wa.
     CHECK g_val_BENE_maint_wa-flag EQ 'X'.
     APPEND g_val_BENE_maint_wa TO it_delrec .
     CLEAR g_val_BENE_maint_wa.
   ENDLOOP.

   DESCRIBE TABLE it_delrec LINES lv_lines .
   IF lv_lines NE 0.
     CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
       EXPORTING
         defaultoption  = 'N'
       textline1      = 'Do you want to delete selected record(s)'(009)
         titel          = 'Delete Lines'(010)
         cancel_display = ' '
       IMPORTING
         answer         = lv_answer.
     IF sy-subrc EQ 0.
       IF lv_answer = 'J'.
         DELETE zval_BENEFIT FROM TABLE it_delrec.
         IF sy-subrc EQ 0.
           MESSAGE s398(00) WITH
                          'Records deleted sucessfully,'(008)
                          space
                          space
                          space.

         ENDIF.
         DELETE g_val_BENE_maint_itab WHERE flag EQ 'X'.
       ENDIF.
     ENDIF.
   ENDIF.
   CALL FUNCTION 'DEQUEUE_E_TABLE'
     EXPORTING
       tabname = 'ZVAL_BENEFIT'.

 ENDFORM.                    " delete_records