Dear All,
I am very in ABAP, i wrote the coding as below and my sample input and output is
Input
Vendor PO number value PO Qty GRN Qty
1 1111 100 1 1
1 1111 200 2 2
Output
Vendor PO number value PO Qty GRN Qty
1 1111 300 3 2
Code
IF EKKO IS INITIAL.
SELECT
EKKO~LIFNR
EKKO~EBELN
EKPO~NETWR
EKKO~AEDAT
LFA1~NAME1
EKPO~EBELP
EKPO~WERKS
INTO TABLE IT1
FROM EKKO
JOIN EKPO ON ( EKKO~EBELN = EKPO~EBELN )
JOIN LFA1 ON ( EKKO~LIFNR = LFA1~LIFNR )
* JOIN EKBE ON ( EKKO~EBELN = EKBE~EBELN AND EKKO~EBELN = EKBE~EBELN )
WHERE EKKO~EBELN IN SO_EBELN AND
EKKO~AEDAT IN SO_EDAT
ORDER BY EKKO~LIFNR .
LOOP AT IT1 INTO WA1.
SELECT SINGLE * FROM EKBE INTO WA3 WHERE EBELN = WA1-EBELN.
IF SY-SUBRC = 0.
wa_COLLECT-LIFNR = WA1-LIFNR.
wa_COLLECT-EBELN = WA1-EBELN.
wa_COLLECT-NETWR = WA1-NETWR.
wa_COLLECT-MENGE = WA3-MENGE.
ENDIF.
COLLECT WA_COLLECT INTO IT_COLLECT.
ENDLOOP.
LOOP AT it_collect INTO wa_collect.
WRITE : / wa_collect-EBELN , wa_collect-LIFNR , wa_collect-MENGE.
ENDLOOP.
Total value is calculated correct and GRN first line item value calculated double time. Also, used debugging, EKBE table, first line item GRN qty value is same second line item also ..
Please help. I am so much confused. Please guide the logic..