10-17-2008 6:25 AM
hi guys,
I have one PO(EBELN) and corresponding to that PO there are multile material documents(MBLNR) , posting date(BUDAT) and quantity(ERFMG).But if i see in PO there is only one record i.e ebeln and in MSEG there r 4 records with the same PO number.
In final output table the user need to see all the MBLNR, BUDAT and ERFMG for doing some calculations. when i keep the loop for PO data then it is not going for 2nd loop as it have only 1 record but inside that again if i keep the loop of MSEG i am able to get those 4 records into my work area.but i am appending all the records of PO data + MSEG data+ del data + shipment data after the PO loop.
and also after appending to the final table i am srting it and deleting all adjacent duplicates from the final tabel as they dont want duplicates .
if u want to see my code plz check ti once.
LOOP AT tab_po_data INTO wa_po_data.
MOVE wa_po_data-matnr TO wa_final_alv-matnr.
MOVE wa_po_data-lifnr TO wa_final_alv-lifnr.
MOVE wa_po_data-ebeln TO wa_final_alv-ebeln.
IF wa_po_data-ebelp NE 0.
MOVE wa_po_data-ebelp TO wa_final_alv-ebelp.
ENDIF.
MOVE wa_po_data-menge TO wa_final_alv-menge.
MOVE wa_po_data-eindt TO wa_final_alv-eindt.
MOVE wa_po_data-menge1 TO wa_final_alv-menge1.
MOVE wa_po_data-eindt1 TO wa_final_alv-eindt1.
READ TABLE tab_del_data INTO wa_del_data WITH KEY vbeln = wa_po_data-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_del_data-vbeln TO wa_final_alv-vbeln.
MOVE wa_del_data-posnr TO wa_final_alv-posnr.
ENDIF.
LOOP AT tab_goods_data INTO wa_goods_data where ebeln = wa_po_data-ebeln
and ebelp = wa_po_data-ebelp.
MOVE wa_goods_data-mblnr TO wa_final_alv-mblnr.
MOVE wa_goods_data-budat TO wa_final_alv-budat_i.
MOVE wa_goods_data-erfmg TO wa_final_alv-erfmg_i.
MOVE wa_goods_data-budat1 TO wa_final_alv-budat_r.
MOVE wa_goods_data-erfmg1 TO wa_final_alv-erfmg_r.
MOVE wa_goods_data-open_qty TO wa_final_alv-ope
ENDLOOP.
LOOP AT tab_del_data INTO wa_del_data WHERE vgbel = wa_po_data-ebeln.
READ TABLE tab_shipment_data INTO wa_shipment_data WITH KEY vbeln = wa_del_data-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
MOVE wa_shipment_data-tknum TO wa_final_alv-tknum.
MOVE wa_shipment_data-signi TO wa_final_alv-signi.
ENDIF.
ENDLOOP.
APPEND wa_final_alv TO tab_final_alv.
SORT tab_final_alv DESCENDING BY ebeln ebelp.
DELETE ADJACENT DUPLICATES FROM tab_final_alv COMPARING ebeln.
SORT tab_final_alv BY ebeln ebelp.
CLEAR : wa_final_alv,
wa_po_data,
wa_del_data,
wa_goods_data,
wa_shipment_data,
wa_ekbe.
ENDLOOP.
Can anybody provide me the solution if possible with sample code. Even i have tried with parallel cursor method but i am not able to form the logic for it.
10-17-2008 7:09 AM
hi,
suppose IT_A contains 1 record for PO data and IT_B contains 4 records for material document data and u want all the 4 records then to get all the 4 records along with the PO no,do:
loop at IT_B into WA_B.
read table IT_A into WA_A with key ebeln = WA_B-ebeln.
if sy-subrc = 0.
move-corresponding WA_A to WA_B(or move selected fields).
modify IT_B index sy-tabix from WA_B transporting fields....
endif.
endloop.
now the internal table IT_B will contain PO data as well as material document data.
10-17-2008 7:09 AM
hi,
suppose IT_A contains 1 record for PO data and IT_B contains 4 records for material document data and u want all the 4 records then to get all the 4 records along with the PO no,do:
loop at IT_B into WA_B.
read table IT_A into WA_A with key ebeln = WA_B-ebeln.
if sy-subrc = 0.
move-corresponding WA_A to WA_B(or move selected fields).
modify IT_B index sy-tabix from WA_B transporting fields....
endif.
endloop.
now the internal table IT_B will contain PO data as well as material document data.
10-17-2008 8:10 AM
Hi Sidharth,
first of all thanks for ur reply.
i just did the exactly the samething what u suggested me.i am able to get the get the records into my final table ,but they r not getting displayed corresponding to the PO numbers as we r modifying the tab_final_alv and it is getting appended from 1st row.
Any suggetion for this.
12-22-2009 7:36 AM