Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to get the multiple records in to final table

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.

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question