on 07-24-2007 6:30 PM
Hello friends,
This is a continuation of my earlier query - for which I got half the solution, and this is the remaining problem.
I want to know: from delivery document line item, how to link it to sales order line item's schedule line (when there are multiple schedule lines with identical quantities).
Thanks for your help.
- Chetan
This is the code which i used for the same purpose and its working.
Hope this will help you too....
****it_itab is my final internal table.
*Internal table for manupulating the Delivery balance when
*its used in more than one schedule line
TYPES: BEGIN OF ty_new,
vbeln TYPE vbep-vbeln," so no
posnr TYPE vbep-posnr," so line no
etenr TYPE vbep-etenr," schedule line
delno TYPE lips-vbeln,"delivery no
delposnr TYPE lips-posnr,"del item no
totval TYPE vbep-wmeng," total del wise value
val TYPE vbep-wmeng," del wise used value
sdval TYPE vbep-wmeng,"schedule wise del used value
sdtotval TYPE vbep-wmeng," total Schedule value
END OF ty_new.
DATA:it_new TYPE ty_new OCCURS 0,
wa_new TYPE ty_new.
DATA: it_vbepvb TYPE TABLE OF vbepvb,
wa_vbepvb LIKE LINE OF it_vbepvb,
fvbfa TYPE TABLE OF vbfa,
fvbup TYPE TABLE OF vbup,
fvbap TYPE TABLE OF vbapvb.
LOOP AT it_vbak INTO wa_vbak.
LOOP AT it_vbap INTO wa_vbap
WHERE vbeln = wa_vbak-vbeln.
SELECT * FROM vbfa INTO TABLE fvbfa WHERE vbelv = wa_vbap-vbeln
AND posnv = wa_vbap-posnr.
SELECT * FROM vbup INTO TABLE fvbup WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
SELECT * FROM vbap INTO TABLE fvbap WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
SELECT * FROM vbep INTO TABLE it_vbepvb WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = wa_vbap-vbeln
fposnr = wa_vbap-posnr
FVERRECHNUNG = ' '
FS073_ALT = ' '
IF_NO_SORT = ' '
TABLES
fvbfa = fvbfa
fvbup = fvbup
fxvbep = it_vbepvb
FVBLB =
fvbap = fvbap
EXCEPTIONS
FEHLER_BEI_LESEN_FVBUP = 1
FEHLER_BEI_LESEN_FXVBEP = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SORT it_vbepvb BY vbeln posnr edatu.
LOOP AT it_vbepvb INTO wa_vbepvb
WHERE vbeln = wa_vbap-vbeln
AND posnr = wa_vbap-posnr.
to write data of schedule line with no delivery
MOVE wa_vbepvb-olfmng_flt TO wa_itab-openqty.
IF wa_vbepvb-bmeng EQ wa_itab-openqty.
CLEAR wa_itab.
PERFORM schedule_data. "schedule line based data to be displayed
MOVE: wa_vbap-lgort TO wa_itab-lgort.
MOVE: wa_vbepvb-etenr TO wa_itab-etenr,
wa_vbepvb-bmeng TO wa_itab-kwmeng,
wa_vbepvb-olfmng_flt TO wa_itab-openqty.
APPEND wa_itab TO it_itab .
CLEAR wa_itab.
ENDIF.
LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = wa_vbepvb-vbeln
AND posnv = wa_vbepvb-posnr.
READ TABLE it_likp INTO wa_likp WITH KEY vbeln = wa_vbfa-vbeln.
CHECK wa_likp-bldat >= wa_vbepvb-edatu.
check the Delivery doc date with the schedule line confirmed date
CLEAR: delbal, deltot,wa_new.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr.
deltot = deltot + wa_new-sdval.
ENDLOOP.
delbal = wa_new-sdtotval - deltot.
CHECK sy-subrc <> 0 OR delbal GT 0.
MOVE wa_vbepvb-olfmng_flt TO wa_itab-openqty.
CHECK wa_vbepvb-bmeng NE wa_itab-openqty.
****To check whether this delivery is already fully allocated against
any other schedule.
LOOP AT it_lips INTO wa_lips WHERE vbeln = wa_vbfa-vbeln
AND posnr = wa_vbfa-posnn.
MOVE: wa_likp-bolnr TO wa_itab-vesname.
MOVE: wa_likp-vbeln TO wa_itab-delno.
MOVE: wa_likp-wadat TO wa_itab-wadat.
MOVE: wa_likp-anzpk TO wa_itab-anzpk.
MOVE: wa_likp-lddat TO wa_itab-lddat.
MOVE: wa_likp-ernam TO wa_itab-ernam.
******end of code added by IVL1 on sep 27 2007 #3618
PERFORM schedule_data.
IF wa_lips-umvkz <> 0.
tempquant = wa_lips-umvkn / wa_lips-umvkz.
ELSE.
tempquant = wa_lips-umvkn. "delivery qty
ENDIF.
tempquant = tempquant * wa_vbfa-rfmng.
***New logic added to get delivery qty schedule wise****
MOVE: wa_vbepvb-etenr TO wa_itab-etenr,
wa_vbepvb-bmeng TO wa_itab-kwmeng,
wa_vbepvb-olfmng_flt TO wa_itab-openqty. "jo
**if delivery qty is less than or equal to schedule line qty******
IF tempquant LE wa_vbepvb-bmeng.
wa_itab-delqty = tempquant.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = tempquant.
wa_new-totval = tempquant.
wa_new-sdval = tempquant.
wa_new-sdtotval = wa_vbepvb-bmeng.
MODIFY TABLE it_new FROM wa_new .
IF NOT sy-subrc IS INITIAL.
APPEND wa_new TO it_new.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = tempquant.
wa_new-totval = tempquant.
wa_new-sdval = tempquant.
wa_new-sdtotval = wa_vbepvb-bmeng.
APPEND wa_new TO it_new.
ENDIF.
wa_itab-delqty = tempquant.
CLEAR tempquant.
ELSE.
lips qty > so schedule lineqty
CLEAR deltol.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND etenr = wa_vbepvb-etenr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
deltol = deltol + wa_new-val.
ENDLOOP.
LOOP AT it_new INTO wa_new WHERE vbeln = wa_vbepvb-vbeln
AND posnr = wa_vbepvb-posnr
AND delno = wa_lips-vbeln
AND delposnr = wa_lips-posnr.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_new-val = wa_new-totval - deltol.
wa_itab-delqty = wa_new-val.
wa_new-delposnr = wa_lips-posnr.
wa_new-totval = tempquant.
wa_new-sdval = wa_new-val.
wa_new-sdtotval = wa_vbepvb-bmeng.
MODIFY TABLE it_new FROM wa_new .
IF NOT sy-subrc IS INITIAL.
APPEND wa_new TO it_new.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
MOVE-CORRESPONDING wa_itab TO wa_new.
wa_itab-delqty = wa_vbepvb-bmeng.
wa_new-delposnr = wa_lips-posnr.
wa_new-val = wa_vbepvb-bmeng.
wa_new-totval = tempquant.
wa_new-sdval = wa_vbepvb-bmeng.
wa_new-sdtotval = wa_vbepvb-bmeng.
APPEND wa_new TO it_new.
ENDIF.
ENDIF.
IF NOT wa_lips-lgort IS INITIAL.
MOVE: wa_lips-lgort TO wa_itab-lgort.
ELSE.
MOVE: wa_vbap-lgort TO wa_itab-lgort.
ENDIF.
APPEND wa_itab TO it_itab .
CLEAR wa_itab.
ENDLOOP.
ENDLOOP.
CLEAR wa_vbepvb.
ENDLOOP.
ENDLOOP.
CLEAR wa_vbak.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sales Order - Schedule Line Items becomes Line Item at Delivery Level.
The structure of Sales Order Type is:
Sales Order Header - Valid for whole document. Eg: Customer, Sales Order Type, etc
Sales Item Level - Valid for Line Items, such as Material, Quantity, Price at line item & so on...
Schedule Line Level - Delivery Date & Delivery Quantity. This forms the Line item at Delivery Level. Based on Schedules, that many deliveries will be created.
The Structure at Delivery Level is as under:
Header - Valid for entire Delivery document, such as Ship to party, etc
Item Level - Valid for Line Item i.e Material, Delivery Quantity, etc.
Hope the above is helpful.
Regards,
Rajesh Banka
Reward points if helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Rajeshbhai,
I know you are trying your best to help me, but I feel still some details are missing. May I request you to help me with table-level details please. i.e. starting from a record in table LIPS, how can we go to the right record in table VBEP (without depending on quantity values, because there could be multiple schedule lines with identical quantities) ? Thanks for your time and help.
- Chetan
Hi Chetan,
Was trying this out when you had posted the query and could find a proper link. Just a thought can we join with the delivery date? If there are two schedule lines with the same delivery date they would be consolidated in the delivery document as one line. So I guess the delivery date field might help you.
Regards
Nadarajah Pratheb
Link: http://www.sap-img.com/
Topic: Free ABAP eBook Download
SAP MM, SD, FI, PS, PP, PM, HR, System Tables
This link give a very good insight on tables & their link, with common field possible to link 2 tables. Hopefully this helps you to answer your query.
Regards,
Rajesh Banka
Reward suitable points.
How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).
Hi,
Did you try using SAP query to combine VBEP and LIPS tables in to a single report....?
Syed Nasir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.