Sales order document with reference to Contract

Hi Sap gurus,
I have question pertaining to sales order with refrence to contract documents,
I have created 2-3 contract documents, and with reference to these contracts i am creating a sales order, while i am creating the sales order i am supposed to get the Pop-UP box stating that this customer and particular material has got open contract documents , but i am not getting any such message why.? though there are open contract documents for that particular customer and material combination.

To get the pop up message, u need to Goto  t. code VOV8, under transaction flow tab, there is a field called outline agreement messages.
There u need to enter an entry as per ur requirement.  After that u can try to create the release orders.
Hope it is useful,
Reward points if useful...
Regards
Kaleeswaran

Similar Messages

  • Change of Sold to Party in Sales order created with Reference to Contract

    Dear Gurus
    I want to change the sold to party in Sales Order created with reference to contract.
    When I create a Sales order with reference to contract the system copies all the partner functions- Sold to, Ship to, Bill to and Payer alongwith other data.
    However Sold to is marked as "Grey" and not changable, rest of the partners can be changed.
    There is no subsiquent document created with reference to this Sales Order.
    Please advice.
    Thanks a lot.
    Regards
    Raghu

    Hi ,
    Please follow the below mentioned step.
    1) Create a partner function letts say Authorized SP .
    2) Assign all the possible authorised  SP (customer) in the contract.
    3) When you create sales order with reff to Contract. Put the customer for whom you wish to create a sales order in release partner tab.
    Hop this will resolve our problem
    Regards,
    Krishna O

  • Sales Order Created with reference to Contract - Exchange rate Issue

    When Sales Order created with reference to contract VBKD fields KURSK and KURSK_DAT gets copied from contract and not redetrmined based on pricing date and Exchange rate type. I expected it to be determined based on pricing date is standard. What I am missing, should it be controlled by data transfers
    If Document currency and condition currency are different it cause problems with incorrect condition values are calculated, as KOMP-KURSK are copied from VBKD-KURSK
    Any help or directions would be greatly appreciated . We are on 4.7 ISOIL
    Sincerely Julietta

    Well,
    and if we have the same issue, but we don't have OIL Version, but simple 4.6C, which solution has to be applied then?
    Thank you
    Standa

  • Error while posting a sales order created with reference from contract for

    Hi,
    I am posting a sales document( Type: WA)  created with reference from contract document(  type wk2) for delivery.  The item category in the sales order of the Item is WAN. On posting this document for delivery I am getting the error as "Item category WAN is not defined".  Please help me out how to resolve this issue.
    Thanks
    Jayant

    Hi Jayant,
    I think its value contract releated error,
    You suppose to check material item category group through T.code-MM02 into sales2 tab and maintain VCIT,
    and do item category assignment through T.code- VOV4.
    plz.maintain like that,
    WK2 -          -VCIT-         -           - WAN(contract item category),
    wk2  -          -        -VCTR-          - WAN((contract item category),
    you should also maintain same against your standard Sales Document type and for Standard Item category into VOV4,
    WA(standard docu.type) -VCIT-                             -                -TAN(your standard docu.type item category),
    WA(standard docu.type) -         -VCTR(item usage)-              -TAN(your standard docu.type item category),

  • Sales Order Creation with reference to Contract

    Hi all ,
    Existing Setup in the System:
    1)  I have a contract created with a validity period of 30 days. When i create sales order with reference to contract, then i get a pop-up box, from the box i can select my contract.
    2) I have a Lead time configured as 5 days for the Sales document type , I,e when I create sales order I can see my Requested delivery date is always system date + 5 days.
    3) I have a Pricing date configured as Today’s date. Therefore when I create sales order I can see pricing date becomes the system date.
    Execution of Sales Order:
    4) When I create Sales Order with reference to contract document. Always Requested Delivery date is compared with Contract Validity Dates.
    Example: Contract Validity 01/03/2008   -    31/03/2008
    Sales Order: Sales Order Creation date -> 19/03/2008, Pricing Date: 19/03/2008 Requested delivery date 24/03/2008.
    REQUIREMENT IS:
    But my requirement is when i create Sales Order it should consider System date or Pricing Date( since pricing date is today date)  for to compare with contract validity dates.
    Can it be done with standard config or do we need to some type of custom?  Appreciate your help
    Thanks

    Hi ,
    As said when I create Sales Order with reference to contract document. Always Requested Delivery date on Sales Order is checked against Contract Validity Dates.
    But i want Pricing date  in Sales Order should be checked against Contract Validity Dates.
    Can someone suggest me on this?

  • Problem in Sales Order Creation with reference to Contract

    Hi All,
    We had enhanced Contracts (VA41) by adding fields thru append structures in VBAP and the same is provided in the "Additional Data B" tab at the item level.
    The Z fields are populated with data and gets saved along with the contracts line items.
    But when a sale order is created with reference to a contract, the data in the Z fields (maintained in Append Structures) of the contract are not getting copied to the line item of Sales orders.
    Should a routine be necessarily written for copying Z fields from contract to Sales orders or Copy control must be set up for Z fields separately?
    Any info on this would help.
    Thanks,
    K.V.Venkatasubramanian

    Hi VJ,
    The copying from Contract to Orders worked. I copied the standard routine (151) in data transfers and added the code to transfer Z fields from work area CVBAP to work area VBAP and attached the same in the copy control. It works!!!
    Thanks for the help VJ.
    Cheers,
    Venkat

  • Re. Sales order Created with reference to Contract

    Hi Guru's,
    I have create a Contract with Sold to party, Ship to party and material combination. So when i am creating a Sales order for the same combination system is not proposing the availability of contract. I manually need to assign the contract to the sales order.
    Am i missing any configuration. Can any one suggest the solution for the same.
    It would be of great help.
    Thanks in advance.
    With Best Regards,
    M. Rajendran.

    Hi Rajendran M, 
    Maintain the copy control in VTAA
    select your Sales document type & contract document type
    In Header
    Data T- 051
    Data T- 101
    Data T- 001
    copying req- 001
    check mark copy item number
    in Item - select yourcontract item category
    Data T- 151
    Data T- 102
    Data T- 002
    FPLA- 251
    copying req- 301
    check mark copy schedules
    x update document flow
    pos/neg qty - +
    pricing type- G
    Let me know if your problem is solved
    Regards
    Pradeep

  • Creating sales order document with reference to billing document

    I have to create sales order with reference to existing billing document. I have tried to following bapis.
    1. BAPI_SALESORDER_CREATEed
    I have successfully created document with following details.
    -->ORDER_HEADER_IN:
    DOC_TYPE = ZRK
    SALES_ORG = 3000
    DISTR_CHAN = 00
    DIVISION = 00
    ORD_REASON = 100
    SD_DOC_CAT = L
    CURRENCY = EUR
    REF_DOC = 100000028
    REF_DOC_CA = M
    -->ORDER_ITEMS_IN:
    ITM_NUMBER = 000010
    MATERIAL = 701791
    TARGET_QTY = 0000000001000
    CURRENCY = EUR
    REF_DOC = 100000028
    REF_DOC_CA = M
    -->ORDER_PARTNERS:
    PARTN_ROLE = SP
    PARTN_NUMB = W12001
    COUNTRY = NL
    by providing this input i am able to create the document but it is not picking up the net value. so i have passed some extra paramters in ORDER_ITEMS_IN
    COND_TYPE = PNET
    COND_VALUE = 14,56
    COND_D_UNT = PC.
    folowing error is occured: Condition PNET is missing in pricing procedure A V Z0000.
    is it something related to configuration problem?
    2.BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2
    I have used same test data that is used for BAPI_SALESORDER_CREATEFROMDATA (where in i coudl succefully create doc). but here i encounterd following error.
    Unpermitted combination of business object BUS2032 and sales doc. category L.
    When i created manually using transaction : VA01
    I could do the same by passing following inputs:
    DOC_TYPE = ZRK
    SALES_ORG = 3000
    DISTR_CHAN = 00
    DIVISION = 00
    Reference document number.
    Please suggest me right way of approach.

    Hi,
    In SAP, when the sub-sequent document is existing , we can not cancel the preceeding document. Therefore if you want to cancel the billing document you need to calcel the documents which are created with reference to that.
    Check and confirm.
    Regards,
    Ravi Duggirala

  • Sales order create with reference to contract order

    Hi,
            I am trying to create a sales order with reference to an
    existing contract order. I have given the contract order and clicked on the selection-list button to select the items I want to copy. It listed the items, but I am not getting all the details of the item. Material description (VBAP-ARKTX) is not coming.
    Is it related to config? This is happening in my quality system where as in my development system, I could see the material
    shorttext appearing.
    Please let me know how to proceed.
    Thanks & Regards,
    Vishnu Priya

    hi,
    please check if there are any missing transports between Development and quality. and also check if there are any customizations done either to bring them or prevent on any specific conditions. Also check if all the required master data is maintianed correctly.
    regards
    sadhu kishore

  • How to create sales order Automatically with reference to contract?

    how to create sales order automatically through batch or online? can anyone please suggest what needs to be change in SAPMV45A program?

    Hi,
    Wt am able to understand from the above question is, you want to create automatic sales order against contract on a day to day basis by doing batch program, hope am wright.
    See you can do it in two ways.
    1. By using BDC, in SHDB T code record how exactly you will do transaction and then give it to your abaper rest he will do. he will write a program and he will schedule that program every day night.
    2. By using BAPI. Just check in there are many threads are there which gives sales order bapi. Tell your abaper to map that bapi and tell them to schedule back ground job.
    Hope this will help out in solving your problem.
    Regards,
    Nagesh

  • Error  : Sales order 'create with Reference' to the contract

    We have made a value contract. Now we are trying to make a Sales order 'create with Reference' to the contract.
    when we do that, we am getting error 'copying material in any value contract item is not permitted'
    Any help or directions would be greatly appreciated . We are on Ecc 6.0
    Rohit

    As of now my value contract has just one material. so i dont need assortment module settings. right?
    in VTAA settings are as follows
    Target type: OR  
    Source type: ZK1
    there is only on item category
    Target item category: TAN   
    Source item category: WKN
    Copying requirement : 301
    update doc flow : 2
    pricing type : C
    cont item copy mode : A
    DataT am using 151,102,002
    There are no schedule line.
    Rohit
    Edited by: rohit kumar on May 15, 2008 7:36 PM

  • BAPI SALES ORDER & Copy with reference

    Hello,
    I'm creating sales order copied with reference to an invoice. My problem is that the data item is empty. When I create the sales order manually and use the option 'Create with reference' and choose an invoice, the sales order is created with all data item. I don't know how I can get to copy the data item from the invoice in the new sales order. The code that I'm using is the following:
    DATA: order_header_in      LIKE bapisdhd1,
          order_partners       LIKE bapiparnr OCCURS 0 WITH HEADER LINE,
          order_text           LIKE bapisdtext OCCURS 0 WITH HEADER LINE,
          order_header_inx     LIKE bapisdhd1x,
          order_item_in        LIKE bapisditm OCCURS 0 WITH HEADER LINE,
          order_schedules_in   LIKE bapischdl OCCURS 0 WITH HEADER LINE,
          order_conditions_in  LIKE bapicond OCCURS 0 WITH HEADER LINE,
          extensionin          LIKE bapiparex OCCURS 0 WITH HEADER LINE,
          partneraddresses     LIKE bapiaddr1 OCCURS 0 WITH HEADER LINE,
          order_cfgs_ref       like BAPICUCFG occurs 0 with header line.
    DATA: salesdocument LIKE bapivbeln-vbeln.
    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    order_header_in-doc_type   = 'ZA09'.
    order_header_in-sales_org  = '1700'.
    order_header_in-distr_chan = '01'.
    order_header_in-division   = '01'.
    order_header_in-BILL_DATE   = '20060701'.
    order_header_in-ref_doc    = '0900000019'.
    order_header_in-refdoc_cat = 'M'.
    *order_header_in-REF_DOC_L_LONG = '0900000019'.
    order_header_in-purch_no_c  ='prueba'.
    *order_header_in-ord_reason = '003'.
    *order_header_in-pmnttrms   = '0002'.
    *order_header_in-sales_off  = '2800'.
    order_header_in-ref_doc_l  = 'FACTURA ES'.
    *order_header_in-fix_val_dy = '20060701'.
    *order_header_in-currency   = 'USD'.
    *order_header_in-exchg_rate = '1.2'.
    order_partners-partn_role = 'AG'.
    order_partners-partn_numb = '0000000001'.
    order_partners-langu      = 'EN'.
    order_partners-name       = 'El corte aleman'.
    order_partners-country = 'ES'.
    APPEND order_partners.
    order_partners-partn_role = 'RE'.
    order_partners-partn_numb = 'ARR000'.
    order_partners-addr_link  = '0000030044'.
    APPEND order_partners.
    CALL FUNCTION 'ADDR_GET_COMPLETE_ALL_TYPES'
      EXPORTING
        addrnumber                 = order_partners-addr_link
      PERSNUMBER                 =
        address_object_type        = '1'
      IV_CURRENT_COMM_DATA       = 'X'
    IMPORTING
      ADDR1_COMPLETE             =
      ADDR2_COMPLETE             =
      ADDR3_COMPLETE             =
       ADDR1_COMPLETE_BAPI        = partneraddresses
      ADDR2_COMPLETE_BAPI        =
      ADDR3_COMPLETE_BAPI        =
    EXCEPTIONS
      PARAMETER_ERROR            = 1
      ADDRESS_NOT_EXIST          = 2
      PERSON_NOT_EXIST           = 3
      INTERNAL_ERROR             = 4
      OTHERS                     = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    data: vl_texto(40) value 'NUEVOOOOO'.
    partneraddresses-name    = vl_texto. clear vl_texto.
    partneraddresses-name_2  = vl_texto.
    partneraddresses-name_3  = vl_texto.
    partneraddresses-name_4  = vl_texto.
    partneraddresses-langu   = 'E'.
    APPEND partneraddresses.
    DATA: vl_cantidad LIKE bapisditm-target_qty.
    vl_cantidad = 1.
    order_item_in-itm_number = 10.
    order_item_in-material = 'HONORARIOS'.
    order_item_in-ref_doc = '0900000019'.
    order_item_in-ref_doc_it = 10.
    order_item_in-ref_doc_ca = 'M'.
    APPEND order_item_in.
    order_schedules_in-itm_number = 10.
    order_schedules_in-req_qty = vl_cantidad.
    APPEND order_schedules_in.
    order_text-text_id = 'Z001'.
    order_text-ITM_NUMBER = ''.
    order_text-langu = 'EN'.
    order_text-text_line = 'Hola, CARACOLAcola'.
    APPEND order_text.
    order_text-text_id = 'Z001'.
    order_text-langu = 'EN'.
    order_text-text_line = 'Adios caracol'.
    APPEND order_text.
    order_text-itm_number = '000010'.
    order_text-text_id = '0001'.
    order_text-langu = 'EN'.
    order_text-text_line = 'Hola, POSICIÓN'.
    APPEND order_text.
    extensionin-structure = 'BAPE_VBAK'.
    extensionin-valuepart1 = '          BCL  7'.
    APPEND extensionin.
    order_cfgs_ref-posex = '10'.
    order_cfgs_ref-config_id = '10'.
    order_cfgs_ref-root_id = '00000001'.
    append order_cfgs_ref.
    CALL FUNCTION 'ZBAPI_SALESORDER_CREATEFROMDT2'
      EXPORTING
       SALESDOCUMENTIN               =  salesdocument
        order_header_in               =  order_header_in
       ORDER_HEADER_INX              =  order_header_inx
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
       salesdocument                 = salesdocument
      TABLES
        return                        = return
        order_items_in                = order_item_in
      ORDER_ITEMS_INX               =
        order_partners                = order_partners
        order_schedules_in            = order_schedules_in
      ORDER_SCHEDULES_INX           =
        order_conditions_in           = order_conditions_in
      ORDER_CONDITIONS_INX          =
        ORDER_CFGS_REF                = order_cfgs_ref
      ORDER_CFGS_INST               =
      ORDER_CFGS_PART_OF            =
      ORDER_CFGS_VALUE              =
      ORDER_CFGS_BLOB               =
      ORDER_CFGS_VK                 =
      ORDER_CFGS_REFINST            =
      ORDER_CCARD                   =
        order_text                    = order_text
      ORDER_KEYS                    =
       extensionin                   = extensionin
        partneraddresses              = partneraddresses
    PERFORM  report TABLES return.
    *DATA: salesdocument LIKE bapivbeln-vbeln.
    *DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    *refresh return.
    *CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'
    EXPORTING
       salesdocument          = '0400000191'
       documenttype           = 'ZA04'
      TESTRUN                = ' '
    IMPORTING
       SALESDOCUMENT_EX       = salesdocument
    TABLES
       RETURN                 = return
    *PERFORM  report TABLES return.
    *write: / salesdocument.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    *&      Form  report
          text
         -->P_MENSAJE  text
    FORM report  TABLES   p_mensaje STRUCTURE bapiret2.
      DATA: vl_mensaje TYPE string.
      LOOP AT return.
        CLEAR vl_mensaje.
        MESSAGE ID     return-id
                TYPE   return-type
                NUMBER return-number
                INTO   vl_mensaje
                WITH   return-message_v1
                       return-message_v2
                       return-message_v3
                       return-message_v4.
        WRITE: / vl_mensaje.
      ENDLOOP.
    ENDFORM.                    " report

    Hi Manuel,
    There are some function modules which is there to copy the order details. I am not sure about the function module name. But you can search in SE37. But bapi for creating the sales order does not have the functionality of copying the data from one document to another document.
    You can try using this function module.
    BAPI_SALESDOCUMENT_COPY
    Data will be copied based on the copy control routines that is set between the two document types.
    Thanks,
    Arun

  • I have created a quotation in CRM system. I want that to be downloaded into ECC, so that, I can create a sales order there with reference to that quotation. So, what are the parameters that I need to set in CRM system so that my quotation gets replicated?

    Dear Experts,
    I have created a quotation in CRM system. I want that to be downloaded into ECC, so that, I can create a sales order there with reference to that quotation. What are the parameters that I need to set in CRM system so that my quotation gets replicated without any error?
    Please help me in this regard. An early and in detail step by step guidance is highly appreciated.
    Thanks,
    SMTP

    It may be best to recreate the folder and the smart playlists from scratch.
    tt2

  • BAPI Sales order create with reference

    Hi
    I need to use BAPI to create sales order with reference to Quantity Contract. The line item material quantity would be less than or equal to quantity contract quantity.
    Sales order needs to be created with new quantity.
    Quantity contract quantity change needs to be maintained.
    Document flow needs to be maintained.
    Is any one aware if this is possible using BAPI_SALESORDER_CREATEFROMDAT2. If yes, how?
    Any insights would be highly appreciated.

    Hi Maninder,
    The BAPI does not allow the Pricing Conditions to be sourced from the Contract. I debugged the BAPI and it uses a piece of code (don't recall which subroutine though) from SAPMV45A which is relevant for dialog processing where it reads from the VBAP and *VBAP structures. Well this structure is only populated when you are using the Front End transaction (VA41, VA42, etc). Because this structure is empty, pricing conditions do not flow across.
    Here is a little prototype program I whipped up to test my method of creating a Sales order and then changing the Sales Order:
    REPORT  ypat_salesorder_create LINE-SIZE 256.
    * This program will create a ZOC Sales Order with Reference to Contract
    * 20000720 / 10. This will be done via BAPI. There are 2 BAPi calls,
    * BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE. We need to
    * perform 2 BAPI calls as the BAPI to create the Sales Order does not
    * bring across the Pricing Conditions properly. To get around this we
    * create the Order with reference to the Contract, then we get the
    * related Pricing Conditions from the COntract and then update the newly
    * created Order.
    * Constants
    CONSTANTS: c_contract  LIKE vbak-vbeln VALUE '0020000720',
               c_item      LIKE vbap-posnr VALUE '000010'.
    * Structures
    * Structure to hold BAPI Header
    DATA: st_bapisdhd1   LIKE bapisdhd1.
    * Internal Tables
    * Sales Order Create BAPI Return Messages
    DATA: tbl_return     TYPE STANDARD TABLE OF bapiret2
                         WITH HEADER LINE.
    * Sales Order BAPI Line Item
    DATA: tbl_bapisditm  TYPE STANDARD TABLE OF bapisditm
                         WITH HEADER LINE.
    * Sales Order BAPI Line Item
    DATA: tbl_bapisditmx  TYPE STANDARD TABLE OF bapisditmx
                         WITH HEADER LINE.
    * Sales Order BAPI Pricing Conditions
    DATA: tbl_bapicond   TYPE STANDARD TABLE OF bapicond
                         WITH HEADER LINE.
    * Sales Order BAPI Partner Functions
    DATA: tbl_bapiparnr  TYPE STANDARD TABLE OF bapiparnr
                         WITH HEADER LINE.
    * Sales Order BAPI Schedule Lines
    DATA: tbl_bapischdl  TYPE STANDARD TABLE OF bapischdl
                         WITH HEADER LINE.
    * Sales Order BAPI Schedule Lines
    DATA: tbl_bapischdlx TYPE STANDARD TABLE OF bapischdlx
                         WITH HEADER LINE.
    * Sales Order BAPI Pricing Conditions
    DATA: tbl_bapicondx    TYPE STANDARD TABLE OF bapicondx
                           WITH HEADER LINE.
    * Customer Enhancement for VBAK, VBAP, VBEP
    DATA: tbl_bapiparex    TYPE STANDARD TABLE OF bapiparex
                           WITH HEADER LINE.
    * Table to hold BAPI Detail Conditions
    DATA: tbl_bapisdcond   TYPE STANDARD TABLE OF bapisdcond
                           WITH HEADER LINE.
    * Table to hold Return Messages from Sales Order Change BAPI
    DATA: tbl_return_chg  TYPE STANDARD TABLE OF bapiret2
                          WITH HEADER LINE.
    * Variables
    DATA: g_vbeln_created   LIKE vbak-vbeln,
          g_valid_contract  TYPE c,
          g_cont_price_date TYPE d.
    * Start of Selection
    START-OF-SELECTION.
      PERFORM validate_contract.
      PERFORM create_sales_ord.
      PERFORM update_sales_ord.
    * End of Selection
    END-OF-SELECTION.
      PERFORM write_output_report.
    * Subroutines
    *&      Form  create_sales_ord
    *       Create the Sales Order
    FORM create_sales_ord .
      PERFORM populate_bapi_tables.
      PERFORM call_create_sales_ord_bapi.
    ENDFORM.                    " create_sales_ord
    *&      Form  populate_bapi_tables
    *       Fill up the BAPI Tables
    FORM populate_bapi_tables .
      PERFORM populate_bapi_header.
      PERFORM build_bapi_partners.
      PERFORM build_bapi_items.
      PERFORM build_bapi_sched_lines.
    ENDFORM.                    " populate_bapi_tables
    *&      Form  populate_bapi_header
    *       Build BAPI Header Details
    FORM populate_bapi_header .
      CLEAR st_bapisdhd1.
      st_bapisdhd1-doc_type     = 'ZOC'.         "Order type
      st_bapisdhd1-sales_org    = '026'.         "Sales Org
      st_bapisdhd1-distr_chan   = '00'.          "Dist Channel
      st_bapisdhd1-division     = '00'.          "Division
      st_bapisdhd1-purch_no_c   = 'Cust Po No'.  "Cust PO No
      st_bapisdhd1-name         = 'Orderer'.     "Name of Orderer
      st_bapisdhd1-ord_reason   = ''.            "Order Reason
      st_bapisdhd1-sales_off    = '3001'.        "Sales Office
      st_bapisdhd1-sales_grp    = '301'.         "Market Area
      IF g_valid_contract = 'X'.
        st_bapisdhd1-price_date = g_cont_price_date.
      ENDIF.
    ENDFORM.                    " populate_bapi_header
    *&      Form  build_bapi_partners
    *       Build BAPI Partner Functions
    FORM build_bapi_partners .
      CLEAR tbl_bapiparnr.
      tbl_bapiparnr-partn_role   = 'AG'.
      tbl_bapiparnr-partn_numb   = '0000100750'.
      APPEND tbl_bapiparnr.
      CLEAR tbl_bapiparnr.
      tbl_bapiparnr-partn_role   = 'WE'.
      tbl_bapiparnr-partn_numb   = '0000504472'.
      APPEND tbl_bapiparnr.
    ENDFORM.                    " build_bapi_partners
    *&      Form  build_bapi_items
    *       Build The BAPI Line Items
    FORM build_bapi_items .
      DATA: l_matnr LIKE mara-matnr.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = '10000072'
        IMPORTING
          output = l_matnr.
      CLEAR tbl_bapisditm.
      tbl_bapisditm-itm_number  = c_item.
      IF g_valid_contract = 'X'.
        tbl_bapisditm-ref_doc     = c_contract.
        tbl_bapisditm-ref_doc_it  = c_item.
        tbl_bapisditm-ref_doc_ca  = 'G'.       "Contract
      ENDIF.
      tbl_bapisditm-material    = l_matnr.
      tbl_bapisditm-plant       = '3012'.
      tbl_bapisditm-target_qty  = '5.000'.
      tbl_bapisditm-target_qu   = 'M3'.
      tbl_bapisditm-item_categ  = 'ZZOC'.
      tbl_bapisditm-sales_dist  = '301'.
      tbl_bapisditm-dlv_prio    = '02'.
      tbl_bapisditm-prc_group5  = '080'.
      tbl_bapisditm-cust_mat35  = 'kdmat'.
      tbl_bapisditm-route       = 'TESYS'.
      tbl_bapisditm-usage_ind   = 'CIV'.
      APPEND tbl_bapisditm.
      CLEAR tbl_bapisditmx.
      tbl_bapisditmx-itm_number = c_item.
      tbl_bapisditmx-ref_doc    = 'X'.
      tbl_bapisditmx-ref_doc_it = 'X'.
      tbl_bapisditmx-ref_doc_ca = 'X'.
      tbl_bapisditmx-material   = 'X'.
      tbl_bapisditmx-updateflag = 'I'.
      tbl_bapisditmx-plant      = 'X'.
      tbl_bapisditmx-target_qty = 'X'.
      tbl_bapisditmx-target_qu  = 'X'.
      tbl_bapisditmx-item_categ = 'X'.
      tbl_bapisditmx-sales_dist = 'X'.
      tbl_bapisditmx-dlv_prio   = 'X'.
      tbl_bapisditmx-prc_group5 = 'X'.
      tbl_bapisditmx-cust_mat35 = 'X'.
      tbl_bapisditmx-usage_ind  = 'X'.
      tbl_bapisditmx-route      = 'X'.
      APPEND tbl_bapisditmx.
    ENDFORM.                    " build_bapi_items
    *&      Form  build_bapi_sched_lines
    *       Build the BAPI Schedule Lines
    FORM build_bapi_sched_lines .
      CLEAR tbl_bapischdl.
      tbl_bapischdl-itm_number  = c_item.
      tbl_bapischdl-req_qty     = '1'.
      tbl_bapischdl-req_date    = sy-datum.
      APPEND tbl_bapischdl.
    ENDFORM.                    " build_bapi_sched_lines
    *&      Form  build_bapi_conditions
    *       Pull the BAPI Pricing Conditions from the Contract
    FORM build_bapi_conditions .
      LOOP AT tbl_bapisdcond.
        CLEAR tbl_bapicond.
        MOVE-CORRESPONDING tbl_bapisdcond TO tbl_bapicond.
        APPEND tbl_bapicond.
        CLEAR tbl_bapicondx.
        tbl_bapicondx-itm_number = tbl_bapicond-itm_number.
        tbl_bapicondx-cond_st_no = tbl_bapicond-cond_st_no.
        tbl_bapicondx-cond_count = tbl_bapicond-cond_count.
        tbl_bapicondx-cond_type  = tbl_bapicond-cond_type.
        tbl_bapicondx-updateflag = 'I'.
        tbl_bapicondx-cond_value = 'X'.
        tbl_bapicondx-currency   = 'X'.
        tbl_bapicondx-cond_unit  = 'X'.
        tbl_bapicondx-cond_p_unt = 'X'.
        tbl_bapicondx-varcond    = tbl_bapicond-varcond.
        APPEND tbl_bapicondx.
      ENDLOOP.
    ENDFORM.                    " build_bapi_conditions
    *&      Form  call_create_sales_ord_bapi
    *       Call the Sales Order Create BAPI
    FORM call_create_sales_ord_bapi .
      CLEAR g_vbeln_created.
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
          order_header_in    = st_bapisdhd1
        IMPORTING
          salesdocument      = g_vbeln_created
        TABLES
          return             = tbl_return
          order_items_in     = tbl_bapisditm
          order_items_inx    = tbl_bapisditmx
          order_partners     = tbl_bapiparnr
          order_schedules_in = tbl_bapischdl.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDFORM.                    " call_create_sales_ord_bapi
    *&      Form  update_sales_ord
    *       Update the newly created Sales Order with the Pricing Conditions
    *       from the Contract
    FORM update_sales_ord .
      CHECK g_valid_contract EQ 'X'.
      PERFORM get_contract_details.
      PERFORM build_bapi_conditions.
      PERFORM call_change_sales_ord_bapi.
    ENDFORM.                    " update_sales_ord
    *&      Form  get_contract_details
    *       Get Contract Details
    FORM get_contract_details .
    * Need to manually get the relevant Pricing Conditions as the BAPI
    * BAPISDORDER_GETDETAILEDLIST causes problems when we call the BAPI
    * BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE (I think
    * this is due to the fact that these BAPIs belong to the same Function
    * Group and there must be some common structures that are not cleared
    * causing us all sorts of grief when we try and call the next BAPI)
      DATA: tbl_konv TYPE STANDARD TABLE OF konv WITH HEADER LINE.
      DATA: tbl_komv TYPE STANDARD TABLE OF komv WITH HEADER LINE.
      DATA: tbl_vbak TYPE STANDARD TABLE OF vbak WITH HEADER LINE.
    * Pricing Condition Master
      DATA: BEGIN OF tbl_t685a OCCURS 0,
              kschl     LIKE t685a-kschl,
              kaend_wrt LIKE t685a-kaend_wrt,
            END OF tbl_t685a.
      SELECT *
             INTO TABLE tbl_vbak
             FROM vbak
             WHERE vbeln = c_contract.
      READ TABLE tbl_vbak INDEX 1.
      SELECT *
             INTO TABLE tbl_konv
             FROM konv
             WHERE knumv = tbl_vbak-knumv AND
                   kposn = c_item.
      CHECK sy-subrc EQ 0.
    * We now need to make sure we only bring across the Condition Types that
    * are EDITABLE. If we bring across non editable conditions (such as
    * 'ZPR1') the Change Sales Order BAPI will fail
      SELECT kschl kaend_wrt
             INTO TABLE tbl_t685a
             FROM t685a
             FOR ALL ENTRIES IN tbl_konv
             WHERE kappl     EQ 'V'             AND  "Sales
                   kschl     EQ tbl_konv-kschl  AND
                   kaend_wrt EQ 'X'             AND  "Value is Editable
                   kmanu     NE 'D'.                 "Process manually
    * Prepare for Binary Search
      SORT tbl_t685a BY kschl.
      LOOP AT tbl_konv.
        READ TABLE tbl_t685a WITH KEY kschl = tbl_konv-kschl BINARY SEARCH.
        IF sy-subrc EQ 0.
          MOVE-CORRESPONDING tbl_konv TO tbl_komv.
          APPEND tbl_komv.
        ENDIF.
      ENDLOOP.
      CHECK NOT tbl_komv[] IS INITIAL.
    * Map KOMV into the more BAPI friendly BAPISDCOND structure
      CALL FUNCTION 'MAP_INT_TO_EXT_STRUCTURE'
        TABLES
          fxvbak        = tbl_vbak
          fxkomv        = tbl_komv
          fxbapikomv    = tbl_bapisdcond
        EXCEPTIONS
          entry_missing = 1
          OTHERS        = 2.
    ENDFORM.                    " get_contract_details
    *&      Form  call_change_sales_ord_bapi
    *       Call the Change Sales Order BAPI
    FORM call_change_sales_ord_bapi .
      DATA: st_head_chg      LIKE bapisdh1x,
            st_logic_switch  TYPE bapisdls.
      CHECK NOT g_vbeln_created IS INITIAL.
      CHECK g_valid_contract EQ 'X'.
      st_head_chg-updateflag     = 'U'.
      st_logic_switch-cond_handl = 'X'.
      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument    = g_vbeln_created
          order_header_inx = st_head_chg
          logic_switch     = st_logic_switch
        TABLES
          return           = tbl_return_chg
          conditions_in    = tbl_bapicond
          conditions_inx   = tbl_bapicondx.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDFORM.                    " call_change_sales_ord_bapi
    *&      Form  write_output_report
    *       Produce Output Report
    FORM write_output_report .
      IF NOT g_vbeln_created IS INITIAL.
        WRITE:/ 'Success! Sales Order', g_vbeln_created, 'was created!'.
      ELSE.
        WRITE:/ 'Failure! Sales Order was not created!'.
      ENDIF.
      SKIP.
      WRITE:/ 'Sales Order Create Log'.
      LOOP AT tbl_return.
        WRITE:/ tbl_return-type, tbl_return-id, tbl_return-number,
                tbl_return-message.
      ENDLOOP.
      SKIP.
      WRITE:/ 'Sales Order Change Log'.
      LOOP AT tbl_return_chg.
        WRITE:/ tbl_return_chg-type, tbl_return_chg-id,
                tbl_return_chg-number, tbl_return_chg-message.
      ENDLOOP.
    ENDFORM.                    " write_output_report
    *&      Form  validate_contract
    *       Make sure that the Contract is Valid
    FORM validate_contract .
      DATA: l_gueen  LIKE vbak-gueen,
            l_prsdt  LIKE vbkd-prsdt.
      SELECT SINGLE  vbak~gueen vbkd~prsdt
             INTO (l_gueen, l_prsdt)
             FROM vbak
             INNER JOIN vbkd
             ON vbak~vbeln = vbkd~vbeln
             WHERE vbak~vbeln = c_contract AND
                   vbkd~posnr = '000000'.
      IF sy-datum LE l_gueen.
    * Contract is valid! Set Order Price Date
        g_valid_contract  = 'X'.
        g_cont_price_date = l_prsdt.
      ENDIF.
    ENDFORM.                    " validate_contract
    Hope this helps.
    Cheers,
    Pat.

  • Sales order creation with reference to quote using BAPI

    Hi All,
    I am trying to create a sales order with reference to quote using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
    I am passing the Quote number and preceding doc.category (B) at the header level and
    at item level I am passing the quote number and the line item number in the quote for REF_DOC and REF_DOC_IT.
    The order is created but there seems to be some issue with the document flow.
    I do not see the Reference Doc number at the header level from the Sales order document flow whereas I can see the Reference Doc for each line item.
    In VBFA I can see the Ref.Doc number at the header level along with the Ref.Doc at the line item level.
    Why do you think it is not showing at the header level from Sales Document Document Flow?
    Is there any bug in the standard BAPI or is there any OSS note?
    Any answer would be greatly appreciated.
    Thanks
    Sandeep

    hi,
    Are you giving different quotation numbers in the different line items, if that is the case you will not get that in the header document flow, as it cann't point to all the quotations.
    Thanks,
    Mahesh.

Maybe you are looking for

  • Sony HVR-M25E not recognized anymore in FCP 6.0.3 update

    Hello, The HVR-25ME is no longer recognized for Print to video. At First I thought i might be a Leopard Problem but it's the same in Tiger. The HVR-M25E Sony HDV recorder was recognized with 6.0 but no longer in 6.0.3. Any ideas? Thank you for your t

  • Calling a WDA on a field's F4 help.. pls reply

    Hi friends, I have a WDA1, with a table of item list. coloumns --  item no:  product no: status: I need to give a F4 input help for product no: .. it should call a other WDA2(this is for product search. I already did this). so once product F4 button

  • Addition of new column into SAP query program

    Hi freinds, There is a query program(joins EKKO,EKPO) which contains columns like vendor,purchase doc,item,material and material description etc.. I need to insert a new column 'Supplying plant' in 2nd position after vendor column...When I try to add

  • IMac G5 vs Intel Mac Mini

    Hi guys, My question is actually the title to the thread... which is faster? I have a 20inch iMac G5 Rev A and am debating selling it, putting an intel mini into a spare cube case and running two monitors from it or something - or at least one big on

  • Webi snapshot not displaying selected drillfilters of report

    I am using business objects enterprise xi 3.1 fixpack 1.5 (12.1.5.1096)  on the Java Platform. I have created a web intelligence report with drillfilters that  used as a dropdown selection at the top of the report.  one contains a list of countries f