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

Using a variable on select

Former Member
0 Likes
545

Hi guys, i need to delete some entries from different tables like 20,

i want to do something like this:

IF dumy = x.

table = 'PA0001'.

ELSE.

table = 'pa2001'.

ENDIF.

DELETE FROM TABLE.

WHERE BEGDA = '99991231'

AND ENDDA = '99991231'.

any ideas?

Edited by: javier santana on Mar 19, 2008 12:33 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
528

Hi,

Refer to the code snippet below.

Code Snippet

DATA: l_dummy TYPE char1,

l_table TYPE tabname.

l_dummy = 'X'.

IF l_dummy EQ 'X'.

l_table = 'PA0001'.

ELSE.

l_table = 'PA2001'.

ENDIF.

DELETE FROM (l_table)

WHERE begda = '99991231'

AND endda = '99991231'.

Regards,

Farheen

4 REPLIES 4
Read only

Former Member
0 Likes
528

Hi Javier,

It is not recommended that you delete the data from standard table using ABAP code. Use the standard transactions, BAPI provided to do the same.

Regards,

Atish

Read only

0 Likes
528

Atish,

its only for Z tables, i wrote standards in order to made the example.

tks anyway.

Read only

Former Member
0 Likes
529

Hi,

Refer to the code snippet below.

Code Snippet

DATA: l_dummy TYPE char1,

l_table TYPE tabname.

l_dummy = 'X'.

IF l_dummy EQ 'X'.

l_table = 'PA0001'.

ELSE.

l_table = 'PA2001'.

ENDIF.

DELETE FROM (l_table)

WHERE begda = '99991231'

AND endda = '99991231'.

Regards,

Farheen

Read only

Former Member
0 Likes
528

data: tab(10) type c,

l_pernr type pa0001-pernr value '00000002'.

if l_pernr eq '00000002'.

tab = 'PA0001'.

else.

tab = 'PA2001'.

endif.

delete from (tab) where pernr = l_pernr.

if sy-subrc eq 0.

write:/ 'Done'.

endif.

Reward if useful............