04-30-2009 12:04 PM
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
04-30-2009 12:11 PM
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.
04-30-2009 12:11 PM
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.
04-30-2009 12:14 PM
That was nice, just can you be bit more elaborate in describing that.
Thanks
Chandan
04-30-2009 12:20 PM
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.
04-30-2009 12:25 PM
Check this sample code:
http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
Regards,
Ravi
04-30-2009 12:45 PM
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
04-30-2009 12:57 PM
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.
10-17-2014 7:35 AM
04-30-2009 12:15 PM
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