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

Regarding loop to internal table

Former Member
0 Likes
498

Hi,

I have first internal table like as below.

HKONTBELNRZUONRBLDATPRCTR
11111123450401201431.12.210388888
11111678900401201431.12.210388888
11111223340401201431.12.210399999
11111667780401201431.12.210377777

     
I have hundreds of entries in the internal first internal table. I am going to use F-04 to post with clear the documents and using document number.

I have another internal table whose fields are HKONT, BELNR1, BELNR2, BELNR3, BELNR4, ZUONR, BLDAT, PRCTR. My requirement is to insert fields BELNR1, BELNR2,... from first internal table whose PRCTR is same.

In the above first internal table PRCTR 88888 is same so second internal table should show the result s below.

HKONTBELNR1BELNR2BELNR3BELNR4ZUONRBLDATPRCTR
1111112345678900401201431.12.210388888
11111223340401201431.12.210399999
11111667780401201431.12.210377777

Please can you give me some solution or tips to get this type of result.

Thanks.

2 REPLIES 2
Read only

harshsisodia31
Participant
0 Likes
456

Hi

Loop at <it1> into <wa1>

     sort it1 by prctr.

     read table <it2> into <wa2> with key prctr = wa1-prctr binary search.

     if sy-subrc = 0

          move wa1-belnr1 to wa2-belnr1.

          move wa1-belnr2 to wa2-belnr2.

     modify it1 from wa1 transporting <belnr1> <belnr2>  where wa1-prctr = wa2-prctr.

     endif.

endloop.

    

Hope it helps.

Read only

Former Member
0 Likes
456

Hello,

Spend a little time on researching the different types of internal table to choose from, and the use of field symbols.

Basic pseudocode is:

Loop at table1 assigning field symbol x

  Loop at table 2 assigning field symbol y where prctr = <x>-prctr

    <y>-belnr2 = <x>-belnr

You need to choose if table 2 is sorted or uses a key for fast access (if the table has a lot of data)

Hope that helps,

Stuart.