11-24-2007 12:17 PM
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.
11-25-2007 5:51 AM
What is your requirement according to the spec?.
Then Paste your code, it will be useful to understand better.
11-24-2007 4:12 PM
11-25-2007 5:51 AM
What is your requirement according to the spec?.
Then Paste your code, it will be useful to understand better.
11-25-2007 6:15 AM
Mr. Baburaj,
Thanks for the inputs.
Functional Requirement:
Open Quantity field to display the quantity which is to be received (i.e. per Delivery Schedule of a PO line) after subtracting the Delivery shcedule quantity from the shipping notification quantity
Technical Spec:
Read quantity field from EKET-MENGE & subtract EKES-MENGE
Eg:
Purchase Order with one line
EKPO-MENGE = 10 nos
EKPO-EBELP = 0010
This item has 2 delivery schedules
EKET-EBELP = 0010, EKET-ETENR=0001, EKET-MENGE = 3 nos
EKET-EBELP = 0010, EKET-ETENR=0002, EKET-MENGE = 7 nos
Case 1: When Shipping Notification is done for 2 nos
EKES-MENGE = 2 nos
Open Quantity for line 1 = 1
Open Quantity for line 2 = 7
Case 2: When Shipping Notification is done for 5 nos
EKES-MENGE = 5 nos
Open Quantity for line 1 = 0
Open Quantity for line 2 = 5
Hope i was able to put across my problem clearly, await inputs.
Vivek
11-25-2007 6:46 AM
Get the data from EKET based on EKPO
if not t_ekpo[] is initial.
SELECT
ebeln ebelp etenr eindt
menge
INTO TABLE t_eket
FROM eket
FOR ALL ENTRIES IN t_ekpo
WHERE ebeln = t_ekpo-ebeln
AND ebelp = t_ekpo-ebelp.
Get the data from EKES
SELECT EBELN EBELP ETENS MENGE
INTO TABLE t_EKES
FROM EKES
FOR ALL ENTRIES IN t_ekpo
WHERE ebeln = t_ekpo-ebeln
AND ebelp = t_ekpo-ebelp.
endif.
clear OPEN_QUANTITY.
loop at EKPO into wa_EKPO.
OPEN_QUANTITY = wa_EKPO-MENGE.
clear CONFIRMED_QTY .
loop at t_ekes into wa_ekes where ebeln = wa_ekpo-ebeln
and ebelp = wa_ekpo-ebelp.
CONFIRMED_QTY = CONFIRMED_QTY + wa_ekes-menge.
clear wa_ekes.
endloop.
*Calculate the open quantity for each schedule line
loop at t_eket into wa_eket where ebeln = wa_ekpo-ebeln
and ebelp = wa_ekpo-ebelp.
if wa_eket-menge ge CONFIRMED_QTY.
CONFIRMED_QTY = CONFIRMED_QTY - wa_eket-menge.
wa_eket-menge = 0.
else.
wa_eket-menge = wa_eket-menge - CONFIRMED_QTY.
CONFIRMED_QTY = 0.
endif.
modify wa_eket.
clear wa_eket.
if CONFIRMED_QTY = 0.
exit.
endif.
endloop
clear wa_ekpo.
endloop.
t_eket will have the open qty, do necessary additions for credit / debit indicators.
11-25-2007 7:51 AM
Mr. Baburaj,
Thanks for your inputs. I will study your program & see what i need to add to it to ensure it works fine. I am still a novice in ABAP, so it will take a little time for me to make this work.
Vivek
11-25-2007 9:14 AM
Mr. Baburaj,
Can you please explain this part of the program which you have written with an example:
*Calculate the open quantity for each schedule line
loop at t_eket into wa_eket where ebeln = wa_ekpo-ebeln
and ebelp = wa_ekpo-ebelp.
if wa_eket-menge ge CONFIRMED_QTY.
CONFIRMED_QTY = CONFIRMED_QTY - wa_eket-menge.
wa_eket-menge = 0.
else.
wa_eket-menge = wa_eket-menge - CONFIRMED_QTY.
CONFIRMED_QTY = 0.
endif.
modify wa_eket.
clear wa_eket.
if CONFIRMED_QTY = 0.
exit.
endif.
endloop
Eg:
If EKES-MENGE = 3 nos & EKET-MENGE for line 1 = 5 nos & line 2 = 5 nos.
Await your inputs.
Vivek
11-25-2007 10:03 AM
This item has 2 delivery schedules
EKET-EBELP = 0010, EKET-ETENR=0001, EKET-MENGE = 3 nos
EKET-EBELP = 0010, EKET-ETENR=0002, EKET-MENGE = 7 nos
Case 1: When Shipping Notification is done for 2 nos
EKES-MENGE = 2 nos
Open Quantity for line 1 = 1
Open Quantity for line 2 = 7
************
CONFIRMED_QTY = 2
*Calculate the open quantity for each schedule line
loop at t_eket into wa_eket where ebeln = wa_ekpo-ebeln
and ebelp = wa_ekpo-ebelp.
if wa_eket-menge ge CONFIRMED_QTY... 3 >= 2...true
/* Condition is failing here, you should change as le instead of ge
CONFIRMED_QTY = CONFIRMED_QTY - wa_eket-menge. ... 1
wa_eket-menge = 0............................................. 0
else.
wa_eket-menge = wa_eket-menge - CONFIRMED_QTY.
CONFIRMED_QTY = 0.
endif.
modify wa_eket.
clear wa_eket.
if CONFIRMED_QTY = 0.
exit.
endif.
endloop
11-25-2007 11:43 AM
Mr. Baburaj,
I still believe there is a bug in the program,
Eg: Shipping notification qty is 2 (EKES-MENGE = 2)
1. IF wa_eket-menge LE confirmed_qty
When i change GE to LE as mentioned by you then this condition will fail because wa_eket-menge is greater than confirmed_qty. Anyways i believe point 2 is more critical
2. This program will subtract 2 from the second delivery schedule line as well as there is no condition preventing this from happening & this should not happen. Only when the notification qty exceeds 3 i.e 4 or above, should it start subtracting from delivery schedule line 2.
Await your inputs
Vivek