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 data from 1st table based on the 2nd table

Former Member
0 Likes
538

Hi experts,

I have a requirement in which I need to delete the data of 1st table based on the data from the 2nd table.

Its like:

1st internal table has the following entries:

GT_T001W

MTES

Z001

Z002

Z003

Z004

Z005

ZREF

ZTST

2nd internal table has the following entries:

Gt_mard

14 M004 000000000000276001 1000 9987.990

15 M002 000000000000276003 1000 6.000

16 M004 000000000000276003 1000 3.600

17 Z003 000000009800000635 1001 100.000-

Now I want that in GT_MARD, all the entries except the common one (Z003) should be deleted.

How do I do this?

Thanks,

Ajay.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
505

Hi

Loop at GT_T001W .

Read table Gt_mard with key MTES = gt_t001w-mtes.

If sy-subrc = 0.

delete gt_mard index sy-tabix.

endif.

Endloop.

Try this .. this will work.

Regards,

Raghu.

Hi

Loop at GT_T001W .

Read table Gt_mard with key MTES = gt_t001w-mtes.

If sy-subrc = 0.

delete gt_mard index sy-tabix.

endif.

Endloop.

Try this .. this will work.

Regards,

Raghu.

2 REPLIES 2
Read only

Former Member
0 Likes
506

Hi

Loop at GT_T001W .

Read table Gt_mard with key MTES = gt_t001w-mtes.

If sy-subrc = 0.

delete gt_mard index sy-tabix.

endif.

Endloop.

Try this .. this will work.

Regards,

Raghu.

Read only

0 Likes
505

Hi

The above code will not work properly.

Your check for subrc is ok But if it is true, then it deletes the entries which is common to both the tables which is not the requirement.

PLease clarify

BR

Jerry