Skip to Content

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

Modification of code - assistance required

Hi All,

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....

Code:

TYPES :

BEGIN OF TL_EKBE,

SHKZG TYPE EKBE-SHKZG,

MENGE TYPE EKBE-MENGE,

END OF TL_EKBE.

DATA :

IL_EKBE TYPE TABLE OF TL_EKBE,

HL_EKBE TYPE TL_EKBE.

REFRESH :

IL_EKBE[].

CLEAR :

HL_EKBE,

OPEN_QUANTITY.

*Open quantity

OPEN_QUANTITY = EKPO-MENGE.

SELECT SHKZG MENGE INTO TABLE IL_EKBE[]

FROM EKBE

WHERE EBELN EQ EKKO-EBELN

AND EBELP EQ EKPO-EBELP.

IF SY-SUBRC EQ 0.

LOOP AT IL_EKBE[] INTO HL_EKBE.

CASE HL_EKBE-SHKZG.

WHEN 'S'.

SUBTRACT HL_EKBE-MENGE FROM OPEN_QUANTITY.

WHEN 'H'.

ADD HL_EKBE-MENGE TO OPEN_QUANTITY.

ENDCASE.

ENDLOOP.

ENDIF.

Tags:
Former Member

Helpful Answer

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