Application Development and Automation 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: 
Read only

Dynamic delete stmt

Former Member
0 Likes
752

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
726

Something like this....


DATA: WHERE_STRING TYPE STRING.

WHERE_STRING = 'FIELD1 NE SPACE AND FIELD2 EQ ''2'''.

DELETE MYTABLE WHERE (WHERE_STRING).

Greetings,

Blag.

6 REPLIES 6
Read only

Former Member
0 Likes
726

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.

Read only

0 Likes
726

Hi David,

I want wriite delete stmt dynamically on the IT_FINAL_DATA.

regards,

Aj

Read only

0 Likes
726

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.

Read only

Former Member
0 Likes
726

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

Read only

Former Member
0 Likes
727

Something like this....


DATA: WHERE_STRING TYPE STRING.

WHERE_STRING = 'FIELD1 NE SPACE AND FIELD2 EQ ''2'''.

DELETE MYTABLE WHERE (WHERE_STRING).

Greetings,

Blag.

Read only

Former Member
0 Likes
726

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