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

Delete entries inside a loop

Former Member
0 Likes
1,444

Hi,

In my requirement i need to delete the entries when values is equal to DELE and to run the loop with trade number.

LOOP AT Y_VVT INTO YS_VVT WHERE ITEM_STAT NE 'DELE'.

READ TABLE Y_VVT INTO YS_VVT WITH KEY TRADE_NUM = '0000'.

Is  my coding is correct. Since i dont have the test case to test , i am searching for help.

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,342

Hi,

Before starting the processing of loop, use DELETE statement. This can be done if you don't want the deleted entries further.

DELETE  Y_VVT WHERE ITEM_STAT EQ 'DELE'.

Then if you want to execute the loop with TRADE_NUM = '0000' , specify that in the loop.
LOOP AT Y_VVT INTO YS_VVT where trade_num = '0000'.

...

endloop.

5 REPLIES 5
Read only

Former Member
0 Likes
1,342

hi bharani,

what actually you wish to do?

if you wish to delete entries having TRADE_NUM = '0000' then use DELETE statement.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,343

Hi,

Before starting the processing of loop, use DELETE statement. This can be done if you don't want the deleted entries further.

DELETE  Y_VVT WHERE ITEM_STAT EQ 'DELE'.

Then if you want to execute the loop with TRADE_NUM = '0000' , specify that in the loop.
LOOP AT Y_VVT INTO YS_VVT where trade_num = '0000'.

...

endloop.

Read only

mayur_priyan
Active Participant
0 Likes
1,342

Bharani G wrote:

Hi,

In my requirement i need to delete the entries when values is equal to DELE and to run the loop with trade number.

LOOP AT Y_VVT INTO YS_VVT WHERE ITEM_STAT NE 'DELE'.

READ TABLE Y_VVT INTO YS_VVT WITH KEY TRADE_NUM = '0000'.

Is  my coding is correct. Since i dont have the test case to test , i am searching for help.

According to your code, the program will consider only the records having ITEM_STAT NE 'DELE' within your LOOP, thereby ignoring the records with ITEM_STAT EQ 'DELE' in your process.

If you wanna delete the entries equal to DELE, then u can directly do it using the DELETE statement. i.e

DELETE Y_VVT WHERE ITEM_STAT = 'DELE'.

The above statement delete all the records with ITEM_STAT = 'DELE'.

Regards,

Mayur Priyan. S

Read only

Former Member
0 Likes
1,342

Can any one tell me how to declare a constant for 'DELE' and '00000'

Read only

0 Likes
1,342

Hi,

For declaring constants, it is best practise to refer their datatype.

For example,

constants c_dele type dbtablename followed by ITEM_STAT will help

similarly if you can check the data type for ITEM_STAT field,

you can also declare

constants c_dele type <datatype directly here>.

Same is true for '0000' as well, you need to refer trade_num field in the database table.

For simple ABAP help, you can do F1 on keyword which will show F1 Help.