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 itab.

Former Member
0 Likes
679

hi all

i have a small query .

init1 i have

matnr

72100008

72100009

and in it2 i have

matnr menge

7210008 20

72100011 30

but i wnt to keep only those matnr in it2 which are same in it1and it2

without having loop at it2 how can i do it any answer plz .i it urgent.

Message was edited by:

sarabjit kaur

6 REPLIES 6
Read only

Former Member
0 Likes
658

My first question (because I'm curious) would be "why can't you loop at itab2"... but purely as an academic exercise, here's a suggestion which loops at itab1 instead (not syntax checked as no system access right now):

ranges:
  lr_matnr          for mara-matnr.

lr_matnr-sign   = 'I'.
lr_matnr-option = 'EQ'.
loop at itab1. "assume header line
  lr_matnr-low = itab1-matnr.
  append lr_matnr.
endloop.

delete itab2 where matnr not in lr_matnr.

Read only

0 Likes
658

because my proggram is already having alot of loops so i just wanted to avoid that , anyway thanx a lot,for prompt reply,i will surely try your option

Read only

0 Likes
658

Thanks. SAP / ABAP thrives on loops, so it may not be a problem anyhow... also you might be able to incorporate the lookup of itab1 whilst you are building up itab2. Good luck.

Jonathan

Read only

Former Member
0 Likes
658

hi sarabjit .....................where r u working at ??????

Read only

varma_narayana
Active Contributor
0 Likes
658

Hii Sarabjit..

This is somewhat different logic but it may work for ur Req:

Just Try once...

Sort itab1 by Matnr as TEXT ASCENDING.

Sort itab2 by Matnr AS TEXT ASCENDING.

Data: v_lastrec type i.

Describe table Itab1.

v_lastrec = sy-tfill.

Read table itab1 index v_lastrec . "Last row...

Delete itab2 Where matnr > ITAB1-MATNR.

<b>reward points if Helpful...</b>

Read only

0 Likes
658

u can try for this ...

loop at it1

read table it2 with key matnr ne it2-mantr.

if sy-subrc = 0.

delete it2.

endif.

endloop.

ok

bye