Link between delivery line item and sales order item schedule line.

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.

Similar Messages

  • How to add line item to sales order item table?

    Kindly help me the with the below requirement .
    Add line item to sales order(va01) dynamically on click of button. The button is also custom created push button.
    In the above requirement I have added the pushbutton to va01 tcode. But when I click on that button I need to add line item to sales order item table.
    I tried a lot but I am not successful. If possible can u please help on this.
    Regards,
    Rachel

    Hi!
    It's quite easy even in the standard SAP to add a line item for a customer order, I don't think it worth to develop a new button for this.
    However if you wanted to add a line automatically, the you can do the following in the program MV45AFZZ, FORM USEREXIT_SAVE_DOCUMENT.
    You can use similar code, but with some modifications.
    DATA: lv_posnr.
    LOOP AT xvbap.
    MOVE xvbap-posnr TO lv_posnr.   "get the last posnr
    ENDLOOP.
    ADD 10 TO lv_posnr.
    MOVE 'XYZ' TO xvbap-matnr.   "enter your material number here
    MOVE lv_posnr TO xvbap-posnr.
    * fill additinal field data in XVBAP if necessary
    MOVE 'I' TO xvbap-updkz.                  "Insert line
    APPEND xvbap.
    Regards
    Tamá

  • Contract and sales order  item deletion

    Dear Experts
    I am facing a problem in a praticular scenario.In our process we are making quotation(thru VA21)>Sales order>delivery>PGI>Billing
    Now if we have a material code Z with qty as 10 in quotation the same gets copied to the sales order.But if i wish to delete the same line item in sales order , system prompts that this item refers to the quotation so it cannot be deleted.
    Now if i go to quotation and try to delete the same line item , then also the system prompts that the sales order XXXX refers to this line item , you cannot delete it.
    I wish to delete the same from sales order as well as the Quotation also.Kindly advise
    Regards
    Naveen
    Edited by: Naveen Sharma on Apr 16, 2010 11:11 AM

    Hi Raga
    But my problem is for ex. i have prepared quotation for Material codes
    X-->5 QTY
    Y-->6QTY
    Z-->7 QTY
    Now the sales order is also having the same 3 material codes.After this we had done the delivery for lets say only X & Y.We dont wish to do the delivery for Z material so even i am going back to VA02 and trying to delete it the system prompts the earlier messages which i had explained
    My requirement is to delete only Z from SO & Quotation

  • Sales order: Two schedule line items for single order item

    Hi,
    I have an issue with the schedule lines in the sales order. When we create a sales order  with today as the delivery date, it creates two schedule lines for the single order item. But if we give future date as the delivery date, then it creates one schedule line only. The confirmed quantity for the first line item (with today we the delivery date) is zero and second line item confirmed quantity (with delivery date as tomorrow) is actual order quantity. So as there is no confirmed quantity on todayu2019s date, it looks like it is creating new line item. But we do we have stock.
    We donu2019t have availability check on and we use custom line item and schedule line categories.
    Please give some hints on what might be the issue.
    There was on post with this kind of issue, but it was closed without answer.
    Thanks,
    Srini

    Hi Srinivas,
    So as there is no confirmed quantity on todayu2019s date, it looks like it is creating new line item. But we do have stock.
    As per my understanding although you have sufficient stock for the material system may be confirming the quantity in future date because of the forward scheduling. As you know system adds different times while evaluating the  confirmed delivery date. Check the route which system is using.

  • Liquidity Report not picking up Noted item and Sales orders

    Hi Experts,
    I created planning levels from source as PSK, yet the liquidity is not picking up these items from sales orders and purchase orders. Also while creating noted items, i have given planning levels in the configurarion and the same is not picking up in the liquidity too
    Please advice
    Thanks in Advance

    Hi Hien,
    We have created planning levels separately for MM and SD and we have created under SDF and MMF respectively.
    IT is working for group created for direct FI entrly and linked the same with PSK and the same is working fine.
    I am new to FSCM. Can you please elaborate FDFD?
    Thanks and Regards

  • How to create service items and sales order for service contracts.

    Hi,
    I have created item using Purchased Item template and one more item(service item) using service /warranty program template. Then I have used these items to create sales order with service item in it and closed that order , but Iam not getting this order in service contracts. Is this right way to create sales order for service items. I
    item name:- personal_computer
    copied from purchased order template. service is enabled and install base is checked and enable service coverage is enabled.
    item name:- service_item
    copied from service /warranty program template
    service is selected to inactive,
    service type: service
    duration: 1 year
    template: Gold
    and saved the item.
    Then I have used these two items in sales order for service contracts. But that sales order is not hitting in service contracts. Is there any error with item creation.
    Thanks,
    Bharat G.

    Following SAP Notes to be referred for Service Tax:
    1.     778976 u2013 Service Tax and Ecess on Service Tax
    2.     1032265 - SEcess on Service Tax
    Regards
    AK

  • Link between alocation table(WA01) and purchase order PO/STO

    HI,
    I have on doubt regarding allocation table which we create in WA01.
    During the creation of allocation table, when we select line item and goes into taxts tab and enter some text like "abcd". I just to know does this text hav any relation with PO. or does allocation table and PO/STO have a link .

    hi,
         I hope you can use the EKBE for fetching the good reciept data for those purchase orders.
    regards,
    Veeresh

  • AR Invoice Line Numbers and Sales Order line numbers are not in Sync.

    Hi,
    There is an AR Invoic with 2 lines and SO with 2 lines. The line numbers on the Invoice and SO are not in Sync. SO line No 2 is Invoice line No1 and SO line No1 is Invoice Line No2. What determines the Invoice line numbering?
    Thanks

    Hi,
    Goto the T.Code "VOV7".
    Select your item category.
    Details.
    Maintain the Completion rule as "A(Item is completed with the first reference)".
    Save.
    If you do this after the follow on document is created,the item is completed and you cannot reject the item.
    For your second question,
    Goto the T.Code "VTLA".
    Select your valid combination.
    Click on item.Select your item category.Details.
    There is a check box called as "Update document flow".Tick that one.
    Save.
    Regards,
    Krishna.

  • Table Link between the Functional Location and work order

    Hi Gurus,
    I am stuck in a big problem and have to find a way to list down the work order with a specific user status in the system. I am trying to link it based on the functional location as the inputs will have to be functional location and the date. Can any one guide me with the tables to link these two???
    Thanks in advance
    Anoop

    Hi,
    Depending on your exact requirement, you might be able to select from view VIAUFKST_IFLOS. This would allow selection based on order, functional location and various dates. The field IPHAS will give you some system status information - value will indicate which status the order has reached. Example value = 3 indicates order is technically completed.
    To get the exact system status (or user status) you need to read the JEST table. Read this table by OBJNR. The object number will have the format OR005000123456 (where 5000123456 is the order number). It will be available in the order tables.
    Status values in JEST are in the internal format - example I0002 = REL. Check transaction BS23 to see the link. User status values will have the format E0002. If INACT flag is set in a jest record then that status value is not active. If you want to check for a specific status value then call function STATUS_READ.
    -Paul

  • Link between Delivery and Sales Order Schedule Line

    Hi Gurus,
    I have a requirement in which i need to display quantity and amount at schedule line level and also the delivery and delivery item for each schedule line.
    For example, if there is a sales order O1 and item 10 for which we have 3 schedule lines and 3 deliveries as well say D1, D2 and D3.
    Report should be something like this
    Sales Order    Item   Schedule Line    Delivery    Del Item   Confirmed Order Qty
    O1                 10      1                       D1           10            5
    O1                 10       2                      D2            10            5
    O1                 10       3                      D3            10            4
    How can i determine that a particular delivery corresponds to which schedule line of that saler order-item?
    We have the link between delivery and sales order but is there any way that we can get the link of delivery at schedule line level?
    Please help.
    Regards,
    Gaurav

    Hi,
    I suppose you must check with SD functional consultant and the post should also be in the logistics SD forum and not BI. But I suppose there is know specific link between the schedule line of SO to the Delivery. It is more like a bucket flow for ex.
    Sale order   Item    Schedule line  qty
    SO1            Item1     Sch1            10
    SO2            Item1      Sch2           10
    Delivery Item QTy
    DO1       IT1   15
    DO2       IT1    5
    In this case qty 15 is distributed over both SO1 and SO2, and SO2 ITem1 Sch2 has link to both the DOs
    So I am not sure if you can establish a one to one link, please check with your SD consultants.
    Regards,
    Ashwin G

  • Link between Accounting Document and Sales Order

    Dear SD Gurus,
    How to find the Sales Order number and Sales Order Item from the accounting document- like document types DZ, DG, ID etc.
    Kindly specify the table links and fields to fetch the above details
    Regards
    Vimal

    Link Between SAP SD, MM & FI
    The link between SD and MM :-
    1. When you create sales order in SD, all the details of the items are copied from Material master of MM.
    2. MRP and availibility check related data is also taken from MM although you control this data in SD also.
    3. While you create inbound/outbound delivery with reference to a sales order,the shipping point determination takes place with the help of the loading group, plant data, shipping conditions etc. This also refers to Material Master.
    4. The material which you are entering in a sales order must be extended to the sales area of your sales order/customer otherwise you cannot transact with this material.
    There are many such links between SD and MM.
    Now the link between SD and FI :-
    1. Whenever you create a delivery with reference to a sales order, goods movement takes place in the bacgground. eg. In case of standard sales order, you create an outbound goods delivery to the customer.
    Here movement 601 takes place. This movement is configured in MM. Also, this movement hits some G/L account in FI. Every such movement of good s hits some G/L account.
    2. The accounts posting in FI is done with reference to the billing documents (invoice, debit note, credit note etc) created in SD. Thus this is a link between SD and FI
    3. Tax determination: In case of a tax determination also, there is a direct link between SD and MM
    SD Integration points with other modules
    SD module is highly integrated with the other modules in SAP.
    Sales Order –
    Integration Points                      Module
    •Availability Check             -       MM
    •Credit Check                   -       FI
    •Costing                        -       CO/ MM
    •Tax Determination              -       FI
    •Transfer of Requirements       -       PP/ MM
    Delivery & Goods Issue –
    Integration Points                      Module
    •Availability Check             -       MM
    •Credit Check                   -       FI
    •Reduces stock                  -       MM
    •Reduces Inventory $            -       FI/ CO
    •Requirement Eliminated         -       PP/ MM
    Billing -
    Integration Points                      Module
    •Debit A/R                      -       FI/ CO
    •Credit Revenue                 -       FI/ CO
    •Updates G/ L                   -       FI/ CO
      (Tax, discounts, surcharges, etc.)
    •Milestone Billing              -       PS
    Return Delivery & Credit Memo -
    Integration Points                      Module
    •Increases Inventory            -       MM
    •Updates G/ L                   -       FI
    •Credit Memo                    -       FI
    •Adjustment to A/R              -       FI
    •Reduces Revenue                -       FI
    SD Transaction Code Flow: 
    Inquiry / Document type IN
    Tcode for creation VA11,VA12,VA13. tables VBAK,VBAP
    Quotation / QT
    Tcode for creation VA21,VA22,VA23. tables VBAK,VBAP
    Purchase Order PO
    Tcode for creation ME21,ME22,ME23. tables EKKO,EKPO.
    Sales Order OR
    Tcode for creation VA01,VA02,VA03. tables VBAK,VBAP
    Delivery LF
    Tcode for creation VL01,VL02,VL03. tables LIKP,LIPS
    Billing F2
    Tcode for creation VF01,VF02,VF03. tables VBRK,VBRP
    <b>The SD & FI link is established through mapping of appropriate G/L accounts through T.Code: VKOA</b>
    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).

  • Delivery schedule line number in sales order is not populated in production

    Hi all,
    i am doing make to order scenario with 20 strategy group. In sales order we r defining the different delivery schedule lines.when i run the MRP and getting the plan orders for all the FG material and semifinished material, the sale order number and sale order item number is getting updated in production order . Beside these two , delivery schedule line number is not populated in production order.
    please give your valuable suggestion .
    i would be highly thankful to u
    Will reward points.
    Regards
    Kumaraguru

    Hi Kumar,
    Some changes done in your PRD server.If yes then contact abap consultant regarding the same.
    Because these type of problem comes when you do transport or changes done in the system.
    Regards,
    Anil

  • Delivery schedule line number in sales order is not populated  in productio

    Hi all,
    i am doing make to order scenario with 20 strategy group. In sales order we r defining the different delivery schedule lines.when i run the MRP and getting the plan orders for all the FG material and semifinished material, the sale order number and sale order item number is getting updated in production order . Beside these two , delivery schedule line number is not populated in production order.
    please give your valuable suggestion .
    i would be highly thankful to u
    Regards
    Kumaraguru

    Hi Kumar,
    Some changes done in your PRD server.If yes then contact abap consultant regarding the same.
    Because these type of problem comes when you do transport or changes done in the system.
    Regards,
    Anil

  • Production order from sales order with multiple line item(for one material)

    Dear Gurus,
    I am working in MTO scenarios. If there is several line item in a sales order for one material, multiple production order( same as no. of sales order line item) is getting created against each of the line item.My requirement is,since the material code is same in each line item and sales order is one, one production order should be generated for all line item. please tell me how to do it.
    (Here for one material, multiple line item is required for some specific reason)
    Regards
    Rajib Pathak

    Hi,
    This is not possible.
    In Std SAP will create one production order for one sales order. The stock is also allocated to thet particular sales order only. Because each and every sales order may vary in any one of the parameters. Considering this, SAP has designed like this.
    Regards,
    V. Suresh

  • Ignore the number of schedule lines in sale order item when run MRP

    Dear All,
    I have a problem when I create production order (discrete manufacturing)
    When I create a sale order with one sale order item and 3 schedule lines for this sale order item.
    After that, I run MRP for this sale order, what I get is 3 planned orders for 3 schedule lines. It means that I will have 3 production orders for 1 sale order item.
    I want  create one production order for one sale order item whatever the number of schedule lines in sale order item.
    I think I have to config in MRP. Please help me.
    Thanks in advance

    Dear
    Check in OPPQ then look in Master data Availability Check & strategy for material also check whether u have maintained strategy for same material and see did u extended sales views for other material
    As u said 3 schedule lines for this sale order item check whether u have extended sales views for next material
    With Regards
    Pushpalas

Maybe you are looking for