‎2007 Aug 23 7:57 PM
Hi All,
How can i write dynamic delete stmt. please give example.
I have internale table contains the 4 fields IT_SET. depends on IT_SET i want to delete the data from IT_FINAL_DATA.
HOw can i write the delete stmt dynamically.
regards,
AJ
‎2007 Aug 23 11:22 PM
Something like this....
DATA: WHERE_STRING TYPE STRING.
WHERE_STRING = 'FIELD1 NE SPACE AND FIELD2 EQ ''2'''.
DELETE MYTABLE WHERE (WHERE_STRING).
Greetings,
Blag.
‎2007 Aug 23 8:30 PM
Hi Ajay,
I would say Loop thru ur it_final_data and within the loop read ur it_Set table and if the condition satisfies delete the entry from it_final_data. I don't understand what you mean by dynamic delete.
I hope it helps you.
David.
‎2007 Aug 23 8:38 PM
Hi David,
I want wriite delete stmt dynamically on the IT_FINAL_DATA.
regards,
Aj
‎2007 Aug 23 9:01 PM
Hi Ajay,
Use this statement
Loop thru it_final_data.
Read table it_set into wa_set with key cond1
cond2.
If sy-subrc EQ 0.
Delete it_final_data where field1 = wa_set-field1.
Endif.
Endloop.
Hope it helps you.
Thanks,
David.
‎2007 Aug 23 8:54 PM
Hi,
try this...
loop at IT_SET.
if it_set-field1 = 'X' and it_set-field3 = 'Y' . "(for example)
delete IT_FINAL_DATA where f1 = 'Z' and f2 = 'W'.
endif.
endloop.
(suppose field1 and field3 are fields of it_set and f1 and f2 are fields of it+final_data)
regards,
Ravi
‎2007 Aug 23 11:22 PM
Something like this....
DATA: WHERE_STRING TYPE STRING.
WHERE_STRING = 'FIELD1 NE SPACE AND FIELD2 EQ ''2'''.
DELETE MYTABLE WHERE (WHERE_STRING).
Greetings,
Blag.
‎2007 Aug 24 6:32 AM
I don't think you can use a (where_cond) for deleting from an internal table, only from a DB table.
Another solution is using field symbols:
loop at it_final_data into final_data.
loop at it_set into set.
assign component set-fieldname of structure final_data to <field>.
if set-value ne <field>.
delete it_final_data.
exit.
endif.
endloop.
endloop.
michael