03-24-2006 12:02 PM
i want to delete a selected entry in table control which should also delte the entry from database table,please help me out with some code.thanks in advance.
03-24-2006 12:06 PM
in PAI
PROCESS AFTER INPUT.
LOOP AT ITAB.
MODULE DELETE_SELECTED.
ENDLOOP.
in that module.
if itab-sel = 'X'.
delete itab index sy-tabix.
move-corresponding itab to itab1.
append itab1.
endif.
sel is the box in table control
*to delete unwanted records from ztable
delete ztab from table itab1.
Message was edited by: Sekhar
Message was edited by: Sekhar
03-24-2006 12:17 PM
hi,
u can use case sy-ucomm.
when 'dele'.
if itab-sel = 'X'.
delete itab index sy-tabix.
append itab.
if sy-subrc = 0.
delete <dbtable> from table itab.
endif.
endif.
declare sel in the internal table as type c.
and u should also give select option in screen painter for the table control.
thanks,
priya
Message was edited by: Priya
03-24-2006 12:32 PM
Hi,
Check this sample code.In this,I am deleting the selected records.Kindly reward points if it helps.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-co... control in abap.pdf
For deleting from database,you need to code
delete ztable where f1 = value.
03-24-2006 12:41 PM
Hi Babita,
The best example for the same reqmts is in
Check progam : <b>demo_dynpro_tabcont_loop_at</b>.
Hope this will help you .
Cheers
Sunny
Rewrd points, if found helpful
Message was edited by: Sunny
03-24-2006 1:00 PM
Hi Babita,
You can code like this ...
* In PAI (Process After Input)
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'DELETE'.
READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
IF SY-SUBRC = 0.
LOOP AT I_BINNLOC INTO ZMBINLOC WHERE ZMARK = 'X'.
I_DELETE = ZMBINLOC.
I_DELETE-ZMARK = SPACE.
APPEND I_DELETE.
DELETE I_BINLOC.
ENDLOOP.
DESCRIBE TABLE I_BINLOC LINES TC-LINES.
ENDIF.
WHEN 'SAVE'.
SORT I_BINLOC ASCENDING BY WERKS LGORT ZBINLOC.
DELETE ADJACENT DUPLICATES FROM I_BINLOC.
IF NOT I_DELETE[] IS INITIAL.
DELETE ZMBINLOC FROM TABLE I_DELETE.
ENDIF.
MODIFY ZMBINLOC FROM TABLE I_BINLOC.
IF SY-SUBRC = 0.
MESSAGE S899(BD) WITH TEXT-002.
ENDIF.
WHEN 'EXIT'.
PERFORM ENQUEUE USING 'D'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
In this case, user always needs to click 'SAVE' button for any changes in table control. Otherwise, no change will be updated.
Hope this will help.
Regards,
Ferry Lianto