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

modify int table

Former Member
0 Likes
874

hi all , my requirement is like this

i have two int tables it1 and it2 as follows.

it1

matnr po no date

100 257 25.4.06

and it2 as

matnr lgort werks

100 200 1000

100 400 1000

100 600 1000

and i want to display dat in final tab as like this

matnr po no date lgort werks

100 257 25.4.06 200 1000

100 257 25.4.06 400 1000

100 257 25.4.06 600 1000

means lgort should be displayed every value but when i read the table

with key matnr it only display first value ogf lgort not all

can nay one help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
837

LOOP AT IT2.

READ TABLE IT1 WITH KEY MATNR = IT2-MATNR.

IF SY-SUBRC = 0.

IT3-MATNR = IT1-MATNR.

IT3-PONO = IT1-PONO.

IT3-DATE = IT1-DATE.

IT3-LGORT = IT2-LGORT.

IT3-WERKS = IT2-WERKS.

APPEND IT3.

ENDIF.

ENDLOOP.

8 REPLIES 8
Read only

viquar_iqbal
Active Contributor
0 Likes
837

Hi

you need put the read statement in between while looping final table.

as read statement will read first single value it encounters.

Thanks

Viquar Iqbal

Read only

Former Member
0 Likes
838

LOOP AT IT2.

READ TABLE IT1 WITH KEY MATNR = IT2-MATNR.

IF SY-SUBRC = 0.

IT3-MATNR = IT1-MATNR.

IT3-PONO = IT1-PONO.

IT3-DATE = IT1-DATE.

IT3-LGORT = IT2-LGORT.

IT3-WERKS = IT2-WERKS.

APPEND IT3.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
837

Hi Sarabjit,

First loop on it2 and inside loop read it1 with matnr.

Read only

venkat_o
Active Contributor
0 Likes
837

Hi Sarabjit, You are correct. When you read internal table with READ statement always gives only record. Instead of that, You have to loop internal table and use your work area. You can write WHERE condition in LOOP statement also.


LOOP AT it3  WHERE matnr = xyz-matnr.
"Do process here
ENDLOOP.
Thanks Venkat.O

Read only

Former Member
0 Likes
837

hi

check it

loop at it2

read table it1 into wa with key matnr=it2-matnr.

write : wa-it2-matnr , wa-it1po , wa-it1date ,wa-it2lgort ,wa-it2-werks

endloop.

Edited by: dharma raj on Jul 1, 2009 1:39 PM

Read only

Former Member
0 Likes
837

Hi,

First declar final table with following fields.

Matnr,

po no,

date,

lgort,

werks.

You can write the code as,

Sort it1 by matnr

Sort it2 by matnr

Clear it2

Loop at it2.

Clear it1.

Read table it1 with key matnr = it2-matnr binary search.

Ifinal-Matnr = it1-matnr.

Ifinal-po no = it1-po no.

Ifinal-date = it1-date ,

Ifinal-lgort = it2-lgort.

Ifinal-werks = it2-werks.

Append ifinal.

Clear ifinal.

Endloop.

For printing data,

Clear final.

Loop at i_final.

Write: Ifinal-Matnr,

Ifinal-po no,

Ifinal-date,

Ifinal-lgort,

Ifinal-werks.

Endloop.

Hope this will help you.

Regards,

Deepa Kulkarni

Read only

Former Member
0 Likes
837

hi,

try this..



loop at it2.
it_final-matnr  = it2-matnr.
it_final- lgort   = it2- lgort .
it_final- werks = it2- werks.

read table it1 with key matnr = it2-matnr.
if sy-subrc = 0.
it_final-po no   = it1-po no.
it_final-date   = it1-date.

endif.
append it_final.
clear it_final.

endloop.

hope this helps

Regards

Ritesh J

Read only

Former Member
0 Likes
837

Hello Sarabjit,

the code is


loop at it1 into wa1.
   loop at it2 into wa2 where matnr eq wa1-matnr.
       wa_final-matnr    =  wa1-matnr.
       wa_final-pono	   =  wa1-pono.
       wa_final-date 	   =  wa1-date.
       wa_final-lgort 	   =  wa2-lgort.
       wa_final-werks  =  wa2-werks.
       append wa_final to it_final.
    endloop.
endloop.

so the final result will be in the internal table it_final.

This code is good interms of Performance also.

Regards

Sajid

Edited by: shaik sajid on Jul 1, 2009 11:53 AM

Edited by: shaik sajid on Jul 1, 2009 11:54 AM