2014 Jan 03 10:50 AM
Hi,
I have first internal table like as below.
| HKONT | BELNR | ZUONR | BLDAT | PRCTR |
|---|---|---|---|---|
| 11111 | 12345 | 04012014 | 31.12.2103 | 88888 |
| 11111 | 67890 | 04012014 | 31.12.2103 | 88888 |
| 11111 | 22334 | 04012014 | 31.12.2103 | 99999 |
| 11111 | 66778 | 04012014 | 31.12.2103 | 77777 |
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.
| HKONT | BELNR1 | BELNR2 | BELNR3 | BELNR4 | ZUONR | BLDAT | PRCTR |
|---|---|---|---|---|---|---|---|
| 11111 | 12345 | 67890 | 04012014 | 31.12.2103 | 88888 | ||
| 11111 | 22334 | 04012014 | 31.12.2103 | 99999 | |||
| 11111 | 66778 | 04012014 | 31.12.2103 | 77777 |
Please can you give me some solution or tips to get this type of result.
Thanks.
2014 Jan 03 11:06 AM
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.
2014 Jan 03 11:06 AM
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.