Modification of code - assistance required
In the below mentioned code the quantity is read from EKPO-MENGE field & the open qty field is calculated by subtracting EKPO-MENGE from EKBE-MENGE.
I want to modify this code to read the quantity from EKET-MENGE & the Open qty field should subtract EKET-MENGE from EKES-MENGE. I need to keep in mind that EKET table can have multiple delivery schedule lines per PO line. So when i subtract the quantity coming from EKES table, it has to subtract starting from delivery schedule line 1 & move to the next line.
Hope my question is clear, await inputs....
BEGIN OF TL_EKBE,
SHKZG TYPE EKBE-SHKZG,
MENGE TYPE EKBE-MENGE,
END OF TL_EKBE.
IL_EKBE TYPE TABLE OF TL_EKBE,
HL_EKBE TYPE TL_EKBE.
OPEN_QUANTITY = EKPO-MENGE.
SELECT SHKZG MENGE INTO TABLE IL_EKBE
WHERE EBELN EQ EKKO-EBELN
AND EBELP EQ EKPO-EBELP.
IF SY-SUBRC EQ 0.
LOOP AT IL_EKBE INTO HL_EKBE.
SUBTRACT HL_EKBE-MENGE FROM OPEN_QUANTITY.
ADD HL_EKBE-MENGE TO OPEN_QUANTITY.