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 internal table - Urgent

Former Member
0 Likes
1,425

Hi

I have 2 int tables called it_final and it_z1log1.

I want to delete the records from it_final using it_z1log1.

following statement is going to dump. Both table has same structure

if it_z1log1[] is not initial.
delete it_final from it_z1log1.
endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,282

Hi,

Try like this...

Loop at it_final .
read table it_z1log1 with key xyz = it_final-xyz.
if sy-subrc = 0.
delete it_final.
continue.
endif.
Endloop.

Regards,

Vrithika

Hi

I have 2 int tables called it_final and it_z1log1.

I want to delete the records from it_final using it_z1log1.

following statement is going to dump. Both table has same structure

if it_z1log1[] is not initial.
delete it_final from it_z1log1.
endif.

10 REPLIES 10
Read only

Former Member
0 Likes
1,282

hi,

Use like this.

loop at itab1 into wa.

delete itab2 from wa.

endloop.

Regards,

Subramanian

Read only

Former Member
0 Likes
1,282

hi.....

is there any field mismatch.....just check.....whats the dump which you are getting.

check the character lenth of variables in oth the structures.

Read only

prasanth_kasturi
Active Contributor
0 Likes
1,282

Hi,

How you want to delete ?

is that using the whole record

do following way

loop at itab1 into wa.

delete table itab2 from wa.

endloop.

Read only

Former Member
0 Likes
1,283

Hi,

Try like this...

Loop at it_final .
read table it_z1log1 with key xyz = it_final-xyz.
if sy-subrc = 0.
delete it_final.
continue.
endif.
Endloop.

Regards,

Vrithika

Read only

Former Member
0 Likes
1,282
loop at it_final into wa_final.
v_tabix = sy-tabix.
read table it_zlog1 into wa_zlog1 with key field1 = wa_final-field1.
if sy-subrc eq 0.
delete it_final index v_tabix.
endif.
endloop.

Regards

Kannaiah

Read only

Former Member
0 Likes
1,282

Hi Kumar,

Your question is quite incomplete.. What I have understood is that you want to delete the table IT_FINAL based on the table it_z1log1.

What you have to do is


data: tabix type sy-tabix.
Loop at it_final.
tabix = sy-tabix.
Read table it_z1log1 with key = <key val>.
if sy-subrc = 0.
   delete it_final index tabix.
endif.
Endloop.

Read only

Former Member
0 Likes
1,282

Hi,

Does your internal tables have work area. If yes then it will delete only the entry present in the work area. Else write :

delete it_final[] from it_z1log1[].

This should work, Give it a try.

Regards,

Lalit Kabra

Read only

Former Member
0 Likes
1,282

use

loop at itab1 where itab1-value eq ' '.

loop at itab2.

delete itab2

..........

.............

nested loops

with where conditions

Read only

prasanth_kasturi
Active Contributor
0 Likes
1,282

hi,

see below example

DATA : it_kna1 TYPE TABLE OF kna1 WITH HEADER LINE,

it_kna2 TYPE TABLE OF kna1 WITH HEADER LINE.

SELECT * FROM kna1 INTO TABLE it_kna1 UP TO 10 ROWS.

SELECT * FROM kna1 INTO TABLE it_kna2 UP TO 30 ROWS.

LOOP AT it_kna1 . " you can use where condition also with the loop

DELETE TABLE it_kna2 FROM it_kna1.

ENDLOOP.

LOOP AT it_kna1.

WRITE : / it_kna1-kunnr.

ENDLOOP.

SKIP.

write : 'SECOND TABLE'.

LOOP AT it_kna2.

WRITE 😕 it_kna2-kunnr.

ENDLOOP.

regards

prasanth

Read only

Former Member
0 Likes
1,282

Hi,

We cannot delete internal table form other internal table , we can delete the contents on internal table from workarea.

Create a workarea for it_z1log1, example wa_it_z1log1.

Loop at it_final.
Read table it_z1log1 into wa_it_z1log1 with key abc = it_final-abc.
If sy-subrc eq 0.
Delete it_final from wa_it_z1log1.
Endif.
Endloop.

This will surely work.

Plz rewardi if useful.

Thanks,

Dhanashri.