‎2007 Oct 24 8:31 AM
I have one internal table itab1 with field VBELN KUNNR which contain the sales orders and the customer numbers based on some selection criteria..
I have another internal table itab2 with fields VBELN POSNR and MATNR (line items) for the above sales orders
I want to display a report with VBELN and KUNNR from itab1 and POSNR MATNR from itab2 for all the orders in itab1..
‎2007 Oct 24 8:35 AM
Loop at itab1 into wa1.
loop at itab2 into wa2
where vbeln = wa1-vbeln.
write: / wa1-vbeln, wa1-kunnr, wa2-posnr, wa2-matnr.
clear: wa2.
endloop.
clear: wa1.
endloop.suppose wa1 in the workarea for itab1 and wa2 is workarea for itab2.
‎2007 Oct 24 8:36 AM
Hi suresh,
here is the code which suits ur requirement.
You include matnr in the itab1 table.
sort itab1 by vbeln kunnr.
sort itab2 by vbeln posnr matnr.
loop at itab1.
read table itab2 with key vbeln = itab1-vbeln
binary search.
if sy-subrc = 0.
itab1-matnr = itab2-matnr.
modify itab1.
clear itab1.
endif.
endloop.
Award points for all helpful answers and close the question if u hav got ur required answer.
Regards
Gowri
‎2007 Oct 24 8:38 AM
Hi Suresh,
Refer following code :
loop at itab1.
loop at itab2 where vbeln = itab1-vbeln.
write:/10 itab1-vbeln, itab2-posnr.
endloop.
endloop.
Regards,
Hemant
‎2007 Oct 24 8:40 AM
Hi
You can either move the data to one internal table and use that internal table for display purpose in ALV.Or you can define fieldcatalog seperately where you can mention the table name and field name.If your creating ordinary report you can use write statement.
Loop at itab1
loop at itab2 where vbeln = itab1-vbeln.
write:itab1,itab2.
endloop.
endloop.
Reward if useful.
Regards
Shibin
‎2007 Oct 24 9:05 AM
sort it_vbak by vbeln.
sort it_vbap by vbeln.
data : l_tabix like sy-tabix.
loop at it_vbak.
clear l_tabix.
read table it_vbap with key vbeln = it_vbak-vbeln binary serach.
if sy-subrc eq 0.
l_tabix = sy-tabix.
endif.
loop at it_vbap from index l_tabix.
if it_vbak-vbeln eq it_vbap-vbeln.
-->>popualte it_final with it_vbap and it_vbak.
else.
exit.
endif.
endloop.
endloop.
Reward the points if it is helpful..
Message was edited by:
Sasidhar Indukuru
‎2007 Oct 24 9:19 AM
Hi,
From my understanding, your internal table 1 contain of field VBELN KUNNR, the data inside this table should be unique. What I mean by unique is there are no duplicate entries for the same VBELN.
Internal table 2 contain of fields VBELN POSNR and MATNR which is line items data which will consists of more than 1 line item with the same VBELN.
Below is my suggestion on the coding.
SORT INTERNAL TABLE 1 BY VBELN. (sort the table first before read table with binary search can be used)
LOOP at <INTERNAL TABLE 2>.
READ TABLE <INTERNAL TABLE 1> WITH KEY VBELN = <INTERNAL TABLE 2>-VBELN BINARY SEARCH.
IF SY-SUBRC = 0.
WRITE: <INTERNAL TABLE 1>-VBELN, <INTERNAL TABLE 1>-KUNNR, <INTERNAL TABLE 2>-POSNR, <INTERNAL TABLE 1>-MATNR.
ENDIF.
ENDLOOP.
Hope this help.
Cheers....