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

looping the internal table

Former Member
0 Likes
617

Hi,

I have two select queries like this.

Select voleh volum mtart

into table l_t_mara

from mara

FOR ALL ENTRIES IN itab1

where matnr = itab1-matnr and

mtart in mtart.

Select zlegt zwdth zhgth zvolm

into table l_t_zcnmm_volume

from zcnmm_volume

FOR ALL ENTRIES IN itab1

where matnr = itab1-matnr and

werks = itab1-werks.

Now I want to move the fields voleh volum mtart zlegt zwdth zhgth zvolm into global internal table itab which is having same structure as itab1.How can I do this?

5 REPLIES 5
Read only

Former Member
0 Likes
589

Hi,

fetch MATNR also ,

then loop throgh one internal table,

inside loop read second internal table

then pass all the values for that particular MATNR into main ITab work area,

then append it to main internal table.

regards,

muralidhar.

Read only

0 Likes
589

Hi,

Can you please give me an example.

Read only

Former Member
0 Likes
589

For the first query directly append the entries in your global internal table.

Now since Matnr is the common field in both the tables.You can modify the already filled global internal table based on the values of matnr transporting the fileds from your second query.

Try this.

t_global is your global table.

move fields from l_t_mara to t_global.

append t_lobal.

for second query.

loop at l_t_zcnmm_volume.

modify t_global from l_t_zcnmm_volume where matnr = l_t_zcnmm_volume-matnr trasnporting required fileds.

append t_global.

endloop.

Chek the syntax.

Read only

Former Member
0 Likes
589

Hi,

Try this code:

Retriev matnr also then:

data: wa_itab1 like line of itab1

similarly declare other work areas

Loop at itab1 into wa_itab1.

read table l_t_mara into wa_mara with key matnr = wa_itab1-matnr.

wa_itab-voleh = wa_mara-voleh

wa_itab-volum =

wa_itab-mtart =

read table l_t_zcnmm_volume into wa_t_zcnmm_volume with key matnr = wa_itab1-matnr.

wa_itab-zlegt = wa_t_zcnmm_volume-zlegt

wa_itab-zwdth =

wa_itab-zhgth =

wa_itab-zvolm =

append wa_itab to lt_itab.

endloop.

Reward points if helpful.

Regards,

Mukul

Edited by: Mukul Sharma on Jun 4, 2008 3:37 PM

Read only

Former Member
0 Likes
589

Hi,

If the relationship bet'n mara and zcnmm_volume is 1 to many, which i think is, then you can use a inner join.

Select m~voleh m~volum m~mtart
z~zlegt z~zwdth z~zhgth z~zvolm
into table itab 
from mara as m inner join 
zcnmm_volume as z on
m~matnr = z~matnr
and m~werks = z~werks
FOR ALL ENTRIES IN itab1
where matnr = itab1-matnr and
mtart in mtart.

Now itab will have all the fields from both the tables mara as well as the z table.

Note inner join is fast compared to nested loops.

regards,

Advait.