‎2007 Mar 20 5:42 AM
hi experts,
i m using table control for showing multiple data in the o/p screen , i have two buttons display and delete.
display button is working fine...but for deletion purpose what i want is on selecting any row in table control if i press delete button then the data will be deleted from database table as per row's data. plz help me regarding this how will i do this plz help me with codes.
i m using lfa1 table for displaying fields on the table control...what sud i write in w/selcolumn.
thnx in advance.
Message was edited by:
ravi gupta
‎2007 Mar 20 5:50 AM
hi,
i think in the table control u are displaying some of the fields of the data base table.
so if u try to delete that row from DBtable means it will search for the records which is having the records with values same as the table ctrl selected line and all other fields(which u didn't display) in the DBtable are null values.
regards,
bharat.
‎2007 Mar 20 5:54 AM
Hi Ravi,
First u will have to maintain OK-Code for the delete button . In the PAI event of the screen you should write this .
The table control should be with selection column .
WHEN 'OK-CODE'.
Delete itab where sel = 'X'.(Sel is the column which u have selected).
Modify dbtab from itab.
Thanks
‎2007 Mar 20 5:58 AM
hi
in the attributes of the table control, enable w/selcolumn and give a name for it..in your itab (which you are displaying in the table control), have a field mark of character type...when a row is selected in the table control, the field mark will be set to X...in the PAI of the user command delete button, write something like this..
case sy-ucomm.
when 'DELE'.
loop at itab where mark = 'X'
delete ztable where primary key eq itab-key..
endloop.
endcase.
this program DEMO_DYNPRO_TABCONT_LOOP_AT exactly does what you are looking for...have a look at this
if helpful, reward.
Sathish. R
‎2007 Mar 20 6:08 AM
hi sathish,
this statement is showing error,"delete ztable where primary key eq itab-key.."
plz help me,,i have to delete the data from lfa1 table
null
‎2007 Mar 20 6:10 AM
Check the syntax.
delete from ztable where field1 = itab-field1.
‎2007 Mar 20 6:09 AM
Hi Ravi,
write this in PAI - Module
LOOP AT itab.
MODIFY itab index t300-current_line.
ENDLOOP.
write this in PAI - User-command
WHEN 'DELETE'.
LOOP AT itab.
IF itab-sel = 'X'.
APPEND itab TO iDel.
DELETE <dbtabname> from table iDel .
ENDIF.
ENDLOOP.
hope this helps.
regds,
Seema
‎2007 Mar 20 6:16 AM
Hi Ravi,
for deletion of row what you can do is that,
<b>**you can change the logic as per your requirement as this is just a psudocode to expalin you the logic
</b>
**FLOW LOGIC
MODULE CHECK_BUTTON_PRESS
you must be having a F-CODE for the delete button say 'DEL'.
in the PAI module check for the DEL button pressed in CASE condition.
WHEN 'DEL'.
MOVE 'X' TO DEL_FLAG.
**here only set the delete flag and check it later.
**end of module check_button_press.
FLOW LOGIC:
loop at internal table used for the table control say TBL_OUT
LOOP AT TBL_OUT.
FIELD: TBL_OUT-MARK
MODULE DELETE_DATA_FROM_DB.
ENDLOOP.
**module DELETE_DATA_FROM_DB
IF TBL_OUT-MARK = 'X' AND DEL_FLAG = 'X'.
*here you can get the primary key(s) field and then using that key delete the data from the database table as deleting records with the help of primary key will assure you that only 1 record is deleted.
ENDIF.
**NOTE: for this logic to work find you need to select the lines to be deleted on the table control.
hope this is helpful to you.
Regards,
Kunjal
‎2007 Mar 20 6:19 AM
hi
good
you can create a delete button using the menu painter and in the code you can give the delete statement as per your requirement.
thanks
mrutyun^
‎2007 Mar 20 10:21 AM