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

Read table probelm

Former Member
0 Likes
598

hi i have one internal table T_STAT like that

vbeln posnr matnr

111 10 abc

111 20 def

112 10 abc

112 20 abc

113 30 def

I am using read table compare only matnr. means the line items which contain matnr abc should move other internal table.

but it is moving only one record. is it possible without loop.

1 ACCEPTED SOLUTION
Read only

StMou
Active Participant
0 Likes
566

hi,

try this



data T_STAT_ABC  like T_STAT occurs 0.

T_STAT_ABC[] = T_STAT[].

delete T_STAT_QBC where MATNR NE 'ABC'.

you have in T_STAT_ABC entry with matnr = 'ABC' without used loop. CQFD

Rgds

hi,

try this



data T_STAT_ABC  like T_STAT occurs 0.

T_STAT_ABC[] = T_STAT[].

delete T_STAT_QBC where MATNR NE 'ABC'.

you have in T_STAT_ABC entry with matnr = 'ABC' without used loop. CQFD

Rgds

4 REPLIES 4
Read only

Former Member
0 Likes
566

READ TABLE reads just one record. So in your case, it will not work. You use

LOOP at ITAB WHERE MATNR eq 'abc'.

move the records to another internal table.

ENDLOOP.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
566

I think you are doing this with two itabs.

Loop at itab1 into wa. "The matnr to be checked

loop at itab2 into wa2 from wk_tabix. "The records to be moved.

if wa2-matnr ne wa-matnr.

wk_tabix = sy-tabix.

exit.

endif.

move-corresponding wa2 to wa3.

append wa3 to itab3.

endloop.

endloop.

Read only

StMou
Active Participant
0 Likes
567

hi,

try this



data T_STAT_ABC  like T_STAT occurs 0.

T_STAT_ABC[] = T_STAT[].

delete T_STAT_QBC where MATNR NE 'ABC'.

you have in T_STAT_ABC entry with matnr = 'ABC' without used loop. CQFD

Rgds

Read only

Former Member
0 Likes
566

Hi Priyank,

Try with the below mentioned code :


data : begin of itab occurs 0,
        vbeln(3) type c,
        posnr(2) type c,
        matnr(3) type c ,
        end of itab.

*data : itab type table of ty_tab,
*       wa_itab like line of itab.
data : ind type i value 1.
data : it_final like itab occurs 0.
data : recs type i.

itab-vbeln = '111'.
itab-posnr = '10'.
itab-matnr = 'abc'.
append itab.
clear itab.

itab-vbeln = '111'.
itab-posnr = '20'.
itab-matnr = 'def'.
append itab.
clear itab.

itab-vbeln = '112'.
itab-posnr = '10'.
itab-matnr = 'abc'.
append itab.
clear itab.

itab-vbeln = '112'.
itab-posnr = '20'.
itab-matnr = 'abc'.
append itab.
clear itab.

itab-vbeln = '113'.
itab-posnr = '30'.
itab-matnr = 'def'.
append itab.
clear itab.


read table itab.

recs = sy-tfill.

while ind LE recs.
read table itab into itab index ind.
if itab-matnr = 'abc'.
append itab to it_final.
clear itab.
endif.
ind = ind + 1.
endwhile.

Cheers

VJ