Using BAPI to create sales order

Hi
  i use this BAPI 'BAPI_SALESORDER_CREATEBOS' to create SO, and This BAPI is with SAP E&C solution.
it is similar to BAPI_SALESORDER_CREATEFROMDAT2. and when i call this BAPI, it give the error 'only quantity 1 ST are permitted (item 000010)'. This because the material i use is service material and with unit 'ST' and only 1. it means one project i sell.
The partial code is as below.
  i_orderitemsin-itm_number = '000010'.
  i_orderitemsin-material = it_sdmaster-MATNR.
  I_ORDERITEMSIN-SHORT_TEXT = it_sdmaster-ARKTX.
  I_ORDERITEMSIN-TARGET_QU = 'ST '.
  I_ORDERITEMSIN-SALES_UNIT = 'ST '.
  I_ORDERITEMSIN-TARGET_QTY = '1.000'.
  I_ORDERITEMSIN-TARGET_QU = 'ST '.
  I_ORDERITEMSIN-TRG_QTY_NO = 1.
  I_ORDERITEMSIN-TRGQTY_DEN = 1.
  i_orderitemsin-pckg_no = v_package.
  APPEND i_orderitemsin .
  clear i_orderitemsin .
You see, i have input the unit(ST) and quantity(1). tks for ur advice.

I think you dont need to pass data in the fields TRG_QTY_NO and TRGQTY_DEN.
Refer the data element documentation of the above fields.
-Kiran

Similar Messages

  • How to use Bapi for creating sales order

    Dear All,
    I am facing problem in creating Sales orders using BAPI.
    Actually I am getting one file as an input and after validating the contents in the file i am preparing an internal table which has 6 fields - Customer number,PO Number,Material Number,Quantity,Price,Unit of measure.
    Now  my doubt is that while using BAPI_SALESORDER_CREATEFROMDAT2 , I am not getting how to pass PO Number and Customer number.
    Please Help.
    Regards,
    Shweta

    Hi shweta upadhyay
    I have gone through you are post i have done some coding for creating sales order using bapi , I think it is helpful for you.
    *& Report  YOBJ_BAPI_SALESORDER
    *& REPORT : CREATING SALES ORDER USING STANDARD BAPI
    *& AUTHOR : S.PAVAN KUMAR INUMARTHY
    REPORT  YOBJ_BAPI_SALESORDER.
    DATA : ORDER_HEADER_IN LIKE STANDARD TABLE OF BAPISDHD1 WITH HEADER LINE.
    DATA : ORDER_ITEMS_IN LIKE STANDARD TABLE OF BAPISDITM WITH HEADER LINE.
    DATA : ORDER_PARTNERS LIKE STANDARD TABLE OF BAPIPARNR WITH HEADER LINE.
    DATA : RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
    DATA : SALESDOCUMENT LIKE BAPIVBELN-VBELN.
    *APPENDING VALUES FOR HEADER.
    ORDER_HEADER_IN-DOC_TYPE = 'TA'.
    ORDER_HEADER_IN-SALES_ORG = '1000'.
    ORDER_HEADER_IN-DISTR_CHAN = '10'.
    ORDER_HEADER_IN-DIVISION = '00'.
    ORDER_HEADER_IN-SALES_GRP = '130'.
    ORDER_HEADER_IN-SALES_OFF = '1030'.
    APPEND ORDER_HEADER_IN.
    *APPENDING VALUES FOR ITEM
    ORDER_ITEMS_IN-MATERIAL = 'M-13'.
    ORDER_ITEMS_IN-PLANT = '1000'.
    ORDER_ITEMS_IN-SALES_UNIT = 'ST'.
    ORDER_ITEMS_IN-DIVISION = '07'.
    ORDER_ITEMS_IN-GROSS_WGHT = '28000'.
    ORDER_ITEMS_IN-NET_WEIGHT = '28000'.
    ORDER_ITEMS_IN-UNTOF_WGHT = 'KG'.
    ORDER_ITEMS_IN-VOLUME = '0.780'.
    ORDER_ITEMS_IN-VOLUNIT = 'M3'.
    APPEND ORDER_ITEMS_IN.
    *APPENDING VALUES FOR PARTNER
    ORDER_PARTNERS-PARTN_ROLE = 'AG'.
    ORDER_PARTNERS-PARTN_NUMB = '0000001000'.
    ORDER_PARTNERS-COUNTRY = 'DE'.
    ORDER_PARTNERS-TRANSPZONE = 'D000080000'.
    APPEND ORDER_PARTNERS.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
    *   SALESDOCUMENTIN               =
        ORDER_HEADER_IN               = ORDER_HEADER_IN
    *   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_ITEMS_IN
    *   ORDER_ITEMS_INX               =
        ORDER_PARTNERS                = ORDER_PARTNERS
    *   ORDER_SCHEDULES_IN            =
    *   ORDER_SCHEDULES_INX           =
    *   ORDER_CONDITIONS_IN           =
    *   ORDER_CONDITIONS_INX          =
    *   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_KEYS                    =
    *   EXTENSIONIN                   =
    *   PARTNERADDRESSES              =
              IF SY-SUBRC = 0.
              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    *           EXPORTING
    *             WAIT          =
    *           IMPORTING
    *             RETURN        =
               ENDIF.
    WRITE : 'SALES ORDER IS :', SALESDOCUMENT.
    This will be very helpful for you .
    this one is the correct answer I have tried it and I am posting it for you.
    Message was edited by: pavan inumarthy

  • BAPI For CREATE SALES ORDER WITH REFERENCE TO ORDER

    Hi ,
    I want to develop a new RFC for 'Creating Sales Order' with reference to another sales order -
    Is there any BAPI available for the same ? (Version 4.7) - I know its available for new create and change
    but couldn't find for create with reference to Order ...
    Thanks in advance ...
    Regards
    Rajesh.

    Hi,
    You can use this FM "/SAPNEA/SMAPI_ORDER_CREATE". I haven;t tried this but you can still give it a try. Mention the Reference Order Type and other data in the header work area and pass it to the FM.
    Reward if it's useful.
    Thanks,
    Anil

  • BAPI FOR CREATING SALES ORDER WITH REFFERENCE TO QUOTATION

    Hi All,
    I am creating sales order with refference to quotation by using bapi "BAPI_SALESORDER_CREATEFROMDATA".Able to create sales order but its not refferencing qutation.Is there any other bapi for this scenario.Please guide me.
    Regards,
    Suresh

    Hi ,
    Thank you for giving reply I tried by using bapi BAPI_SALESORDER_CREATEFROMDAT2 after execution it giving sales order number but when I am trying to see that sales order system is giving error message as document is not exist.
    Please guide me.
    Suresh

  • Bapi To create sales order with reference of sales order.

    Hi all,
          Having requerment To create sales order with reference of onother  open sales order.
    Example: there open sales order which having qty of 20 for that 10 qty as already billed , for remain  10 qty as to create the new sales order with reference to the excsiting one.
    Please guide me how do it.
    Regards,
    Santosh
    Edited by: santosh jajur on May 15, 2010 11:47 AM

    Hi Santhosh,
    check this thread.
    Re: Open Sales Order Migration
    The last part of the thread says done.
    hope you get a hint from that.
    Also this one
    Re: how to create open sales order using BAPI....?
    http://abaplovers.blogspot.com/2008/02/bapi-sales-order-create-code.html
    Regs,
    SuryaD.
    Edited by: SuryaD on May 15, 2010 9:09 PM
    Edited by: SuryaD on May 15, 2010 9:10 PM
    Edited by: SuryaD on May 15, 2010 9:11 PM

  • BAPI to create Sales Order with reference to contract

    Hi All,
    I am trying to create Sales Order with reference to Contract, but although the
    order gets created, it does not contain reference document information. 
    The BAPI I am using is BAPI_SALESORDER_CREATEFROMDAT2. 
    Would someone know which parameters I have to papulate,or have any other suggestion
    how to accomplish my task? 
    Thank you so much, 
    Mayank

    Hi - Try Filling these three fields in the Item details.
    REF_DOC
    REF_DOC_IT
    REF_DOC_CA
    Reward points if helpful

  • BAPI_SALESORDER_CREATEFROMDAT1 - using this to create Sales orders in R3

    Hi
       Does anyone out there - know the limitations of using this BAPI BAPI_SALESORDER_CREATEFROMDAT1 to create sales orders in R3 system - from a functional standpoint ? i.e any known issues - in terms of not being able to pass - all aspects of sales order data using the BAPI , any onscreen validations being done in VA01/VA02 not being done in the BAPI etc.
    Can this BAPI be used for sales order create/change ? Or is there any other BAPI out there that is better suited and more well rounded for sales order creation in R3 ?

    REPORT z_bapi_create_sales_order_test .
    * Order header:
    * - Order type: OR  Important you must use the german code TA
    * - Sales org: 1000
    * - Distrb. chan.: 10
    * - Division: 00
    * - Sold to party: 1032
    * - Ship to party: 1032
    * - Purch order: DG-19970626-3
    * Order item:
    * - Material: P-100
    * - Qty: 1
    DATA:
    * Order partners
    li_order_partners    TYPE STANDARD TABLE OF bapiparnr,
    l_order_partners     LIKE bapiparnr,
    * Structures for order header
    l_order_header_in    LIKE bapisdhd1,
    l_order_header_inx   LIKE bapisdhd1x,
    * Tables for order items
    li_order_items_in    TYPE STANDARD TABLE OF bapisditm,
    l_order_items_in     LIKE bapisditm,
    li_order_items_inx   TYPE STANDARD TABLE OF bapisditmx,
    l_order_items_inx    LIKE bapisditmx,
    * Return table from bapi call
    li_return TYPE STANDARD TABLE OF bapiret2,
    l_return  TYPE bapiret2,
    * Sales document number
      l_vbeln LIKE bapivbeln-vbeln,
    * Error flag
      l_errflag(1) TYPE c.
    START-OF-SELECTION.
    * Build partner information
      CLEAR l_order_partners.
      l_order_partners-partn_role = 'AG'.          "Remember German codes !
      l_order_partners-partn_numb = '0000001032'.
      APPEND l_order_partners TO li_order_partners.
    * Build order header
    * Update flag
      l_order_header_inx-updateflag = 'I'.
    * Sales document type
      l_order_header_in-doc_type    = 'TA'.        "Remember German codes !
      l_order_header_inx-doc_type   = 'X'.
    * Sales organization
      l_order_header_in-sales_org  = '1000'.
      l_order_header_inx-sales_org  = 'X'.
    * Distribution channel
      l_order_header_in-distr_chan = '10'.
      l_order_header_inx-distr_chan = 'X'.
    * Division
      l_order_header_in-division = '00'.
      l_order_header_inx-division = 'X'.
    * Purchase order
      l_order_header_in-purch_no_c = 'DG-19970626-300'.
      l_order_header_inx-purch_no_c = 'X'.
    * Build order item(s) - Only 1 is used in this example
      l_order_items_in-itm_number = '10'.
      l_order_items_inx-itm_number = '10'.
      l_order_items_in-material = 'P-100'.
      l_order_items_inx-material = 'X'.
      l_order_items_in-comp_quant = '1.000'.
      l_order_items_inx-comp_quant = 'X'.
      APPEND l_order_items_in TO li_order_items_in.
      l_order_items_inx-updateflag = 'I'.
      APPEND l_order_items_inx TO li_order_items_inx.
    * CALL Bapi
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
           EXPORTING
                order_header_in  = l_order_header_in
                order_header_inx = l_order_header_inx
                testrun          = 'X'
           IMPORTING
                salesdocument    = l_vbeln
           TABLES
                return           = li_return
                order_items_in   = li_order_items_in
                order_items_inx  = li_order_items_inx
                order_partners   = li_order_partners.
    END-OF-SELECTION.
    * Check and write Return table
      CLEAR l_errflag.
      WRITE: / 'Sales dcoument: ', l_vbeln.
      LOOP AT li_return INTO l_return.
        WRITE: / l_return-type, l_return-message(50).
        IF l_return-type = 'E'.
          l_errflag = 'X'.
        ENDIF.
      ENDLOOP.
    * No errors - Commit
      IF l_errflag  IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.

  • BAPIs to create sales orders for Returns and Debit Memo Request

    Hi,
    I have to create a sales order for document type Returns as well as a debit memo request.The BAPI 'BAPI_SALESORDER_CREATEFROMDAT2' is giving the following error message for Debit Memo Request document creation as well as for Returns.
    761 Unpermitted combination of business object BUS2032 and sales doc. category L
    I found BAPIs:
    ‘BAPI_CUSTOMERRETURN_CREATE’ for creating sales document of type ZDRE and SD document category ‘H’.
    ‘BAPI_DEBITREQUEST_PROXY_CREATE’ for creating sales document of type ZDDR and SD document category ‘L’.
    please let me know if anybody have used them. If so what values need to be passed to I_UPLOAD_ID,I_DESTIN,I_SFA_REL parameters of BAPI_DEBITREQUEST_PROXY_CREATE. Are there any alternative solutions using the Salesorder bapi.
    I have to create documents based on the flat file data no reference sales document numbers are available.
    Appreciate your help..
    Good Day
    Regards
    Bhargavi

    Look at the code done by me
    Program Name:                                                        *
    SAP Name    : ZAXXXXXX               Version    :                    *
    Programmer  : Chris Dong of ITDC                    *
    Description :                                                        *
    Includes        :                                                    *
    Function Modules: XX_XXXXXX                                          *
    Transactions    :                                                    *
    Programs        :                                                    *
    REPORT  XXXXXXXX LINE-SIZE  80
                     LINE-COUNT 65
                     MESSAGE-ID ZA
                     NO STANDARD PAGE HEADING.
    CLEAR l_order_partners.
    l_order_partners-partn_role = 'AG'.
    l_order_partners-partn_numb = '0001202491'.
    APPEND l_order_partners TO li_order_partners.
    CLEAR l_order_partners.
    l_order_partners-partn_role = 'WE'.
    l_order_partners-partn_numb = '0001202491'.
    APPEND l_order_partners TO li_order_partners.  
    Sales document type
    l_order_header_in-doc_type = 'ZDR'.  
    Sales organization
    l_order_header_in-sales_org = '1000'. 
    Distribution channel
    l_order_header_in-distr_chan = '01'.  
    Division
    l_order_header_in-division = '04'. 
    REF DOCUMENT
    l_order_header_in-REF_DOC = '9100000144'.
    order reason
    l_order_header_in-ord_reason = '925'.
    item number
    l_order_items_in-itm_number = '000001'. 
    material no
    l_order_items_in-material = '000000000007000012'. 
    Qty
    l_order_items_in-target_qty = '0000000000100.000'. 
    APPEND l_order_items_in TO li_order_items_in. 
    *BUS2094 Credit memo request " OSS NOTE 93091
    *BUS2096 Debit memo request " OSS NOTE 93091
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA'
    EXPORTING
    ORDER_HEADER_IN = l_order_header_in
    BUSINESS_OBJECT = 'BUS2096'
    WITHOUT_COMMIT = ' '
    CONVERT_PARVW_AUART = ' '
    IMPORTING
    SALESDOCUMENT = l_vbeln
    RETURN = li_return
    TABLES
    ORDER_ITEMS_IN = li_order_items_in
    ORDER_PARTNERS = li_order_partners
    Message was edited by:
            Chris Dong
    null

  • Using BAPI_ACTIVITYCRM_CREATEMULTI for creating sales order in CRM

    Hello Experts,
    I am creating a sales order using BAPI_ACTIVITYCRM_CREATEMULTI, But I am getting the following errors:
    1. Reference Object Type (ORGMAN) not allowed
    2. Reference Object Type (PARTNER) not allowed
    3. Incomplete interface data - No reference specified
    4. Item was not found
    Can you please help me with the mandatory fields, that has to be filled in the BAPI, and do I need to use Commit BAPI after this BAPI.
    Please I am in critical postion,
    Now I am able to create a sales order there is no data it like the partner number and Item.May be I am missing some important fileds.
    Please help.
    Thanks,
    Suma
    Edited by: Suma B on Aug 8, 2008 1:05 PM

    Hi,
    I am passing data using SE37 T-Code.
    I was told by the fucntioal guys that GUID will be generated by CRM, so we dont need to send that as an input.
    Still facing the same error...
    These are my input fields:
    REF_HANDLE
    REF_GUID
    R
    OBJECTNAME
    LOGICAL_KEY
    FIELDNAME
    C
    |
    0000000000
    ORDERADM_H
    PROCESS_TYPE
    0000000000
    ORDERADM_H
    POSTING_DATE
    0000000000
    ACTIVITY_H
    CATEGORY
    0000000000
    ACTIVITY_H
    PRIORITY
    0000000000
    ACTIVITY_H
    DIRECTION
    0000000000
    PARTNER
    000000000022XXXXXXX
    REF_PARTNER_FCT
    0000000000
    PARTNER
    000000000022XXXXXXX
    REF_PARTNER_NO
    0000000000
    PARTNER
    000000000022XXXXXXX
    PARTNER_FCT
    0000000000
    PARTNER
    000000000022XXXXXXX
    PARTNER_NO
    0000000000
    ORGMAN
    DIS_CHANNEL
    0000000000
    ORGMAN
    DIVISION
    0000000000
    ORGMAN
    SALES_ORG
    0000000000
    ORDERADM_I
    PRODUCT
    0000000001
    B
    SCHEDLIN
    00000000000000000000000000000000
    QUANTITY
    |
    This is error log:
    T
    ID
    NUM
    MESSAGE
    LOG_NO
    LOG_MS
    MESSAGE_V1
    MESSAGE_V2
    MESSAGE_V3
    MESSAGE_V4
    PARAMETER
    ROW
    FIELD
    SYSTEM
    |
    W
    CRM_ORDER
    004
    Referenced object type (ORGMAN) not allowed
    $000001
    000001
    ORGMAN
    ORDER
    0
    CR5CLNT100
    W
    CRM_ORDER
    004
    Referenced object type (PARTNER) not allowed
    $000001
    000002
    PARTNER
    ORDER
    0
    CR5CLNT100
    W
    CRM_ORDER
    005
    Incomplete interface data - No reference specified
    $000001
    000003
    ORDER
    0
    CR5CLNT100
    E
    CRM_ORDERADM_I
    006
    Item  was not found.
    $000001
    000004
    ORDER
    0
    CR5CLNT100
    E
    CRM_ORDER
    005
    Incomplete interface data - No reference specified
    $000001
    000005
    ORDER
    0
    CR5CLNT100
    S
    CRM_MESSAGES
    005
    A log has been generated for single document
    $000001
    000006
    MESSAGES
    0
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Sold-To Party
    $000002
    000001
    Sold-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Ship-To Party
    $000002
    000002
    Ship-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Bill-To Party
    $000002
    000003
    Bill-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Payer
    $000002
    000004
    Payer
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Sold-To Party
    00000000000000047612
    000001
    Sold-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Ship-To Party
    00000000000000047612
    000002
    Ship-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Bill-To Party
    00000000000000047612
    000003
    Bill-To Party
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    E
    COM_PARTNER
    119
    Enter   Payer
    00000000000000047612
    000004
    Payer
    PARTNER
    0
    PARTNER_NO
    CR5CLNT100
    |
    Thanks,
    Suma

  • Issue in BAPI for creating sales order

    Dear friends,
    BAPI_SALESORDER_CREATEFROMDAT2
    and
    BAPI_TRANSACTION_COMMIT
    The above standard BAPI's we are using to create SO through third party software and the commit bapi to commit the order in DB, but the issue is now, we have created one new condition type for determining
    1.Loading and Unloading point
    2.Inco1 and Inco2
    3.PayT.
    This will trigger when we are selecting the ORDER Reason, this is working fine when we create the Order manually in SAP, but through Third party software this is not triggering, it is taking its own values from the master.

    Hello Experts,
    I am having issue related to Item category determination.
    Your inputs will be greatly appreciated.
    We have a service order in which Item category is determining correctly. Let’s assume Material as “A” (Material type DIEN, Service,
    Freight , etc..) and item category ZITC
    is determined correctly.
    Let’s assume sales order type as ZSOR
    Now I would like to add another line item as miscellaneous
    charges for the same order and we have a material created for that purpose Let’s
    assume miscellaneous material as “B”
    (Material type DIEN, Service,
    Freight, etc..)
    Both the materials “A” & “B” have Item category Group as “LEIS” (Service w/o Delivery), in material master Sales org 2 view.
    In VOV4 we have config maintained as
             Sa Ty  | ItCGr | Usg | HLevItCa |DfItC
              ZSOR | LEIS |            |                 |ZITC
              ZSOR | LEIS | TEXT|                   | ZITC
    But when I add material “B” (miscellaneous charges)as a line item, I get the below error and item category is not determined.
    No item category
    available (Table T184 ZITC TEXT )
    Message no. V1320
    Thanks in advance

  • BAPI for creating sales order

    Hi Folks,
    I want to create a sales order using BAPI. Can any one tell me the name of that BAPI and how to use that BAPI.
    Siddarth

    Hi
    See tha sample code for sales order creation
    SALES ORDER INPUT CREATION.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
    *ITEM
    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.
    DATA DECLARATIONS.
    DATA: v_vbeln LIKE vbak-vbeln.
    DATA: header LIKE bapisdhead1.
    DATA: headerx LIKE bapisdhead1x.
    DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
    DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
    WITH HEADER LINE.
    DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
    WITH HEADER LINE.
    HEADER DATA
    header-doc_type = p_auart.
    headerx-doc_type = 'X'.
    header-sales_org = p_vkorg.
    headerx-sales_org = 'X'.
    header-distr_chan = p_vtweg.
    headerx-distr_chan = 'X'.
    header-division = p_spart.
    headerx-division = 'X'.
    headerx-updateflag = 'I'.
    PARTNER DATA
    partner-partn_role = 'AG'.
    partner-partn_numb = p_sold.
    APPEND partner.
    partner-partn_role = 'WE'.
    partner-partn_numb = p_ship.
    APPEND partner.
    ITEM DATA
    itemx-updateflag = 'I'.
    item-itm_number = '000010'.
    itemx-itm_number = 'X'.
    item-material = p_matnr.
    itemx-material = 'X'.
    item-plant = p_plant.
    itemx-plant = 'X'.
    item-target_qty = p_menge.
    itemx-target_qty = 'X'.
    item-target_qu = 'EA'.
    itemx-target_qu = 'X'.
    item-item_categ = p_itcat.
    itemx-item_categ = 'X'.
    APPEND item.
    APPEND itemx.
    Fill schedule lines
    lt_schedules_in-itm_number = '000010'.
    lt_schedules_in-sched_line = '0001'.
    lt_schedules_in-req_qty = p_menge.
    APPEND lt_schedules_in.
    Fill schedule line flags
    lt_schedules_inx-itm_number = '000010'.
    lt_schedules_inx-sched_line = '0001'.
    lt_schedules_inx-updateflag = 'X'.
    lt_schedules_inx-req_qty = 'X'.
    APPEND lt_schedules_inx.
    Call the BAPI
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
    EXPORTING
    sales_header_in = header
    sales_header_inx = headerx
    IMPORTING
    salesdocument_ex = v_vbeln
    TABLES
    return = return
    sales_items_in = item
    sales_items_inx = itemx
    sales_schedules_in = lt_schedules_in
    sales_schedules_inx = lt_schedules_inx
    sales_partners = partner.
    Check the return table.
    LOOP AT return WHERE type = 'E' OR type = 'A'.
    EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
    WRITE: / 'Error in creating document'.
    ELSE.
    COMMIT WORK AND WAIT.
    WRITE: / 'Document ', v_vbeln, ' created'.
    ENDIF.
    Regards

  • BAPI for Creating Sales Order For Variant Configuration Materials

    Dear Gurus,
    Before posting this thread, we have referred many SDN threads, OSS notes and other sites for any sort of help..but no success..All threads and other referrals are not much of help as they are kind of incomplete( Perhaps, we are unable to understand them..no offense).
    Few checked threads on this subjects are:
    http://scn.sap.com/thread/34590
    http://scn.sap.com/thread/851070
    http://scn.sap.com/community/abap/blog/2014/04/23/update-vc-variant-configuration-data-using-standard-bapi-in-sales-order
    http://scn.sap.com/community/abap/blog/2014/07/15/creating-orders-with-variant-configured-items-using-bapisalesordercreatefromdat2
    http://scn.sap.com/community/abap/blog/2014/04/23/update-vc-variant-configuration-data-using-standard-bapi-in-sales-order
    http://scn.sap.com/thread/120144
    OSS: 549563
    Well, we're using the BAPI (BAPI_SALESORDER_CREATEFROMDAT2) which creates the sales order successfully but without the characteristic values in line items.
    We're passing data to the following parameters - ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_VALUE to create the variant config but not able to see it getting created.
    Pls find attached BAPI coding document for your reference.
    If you could throw any light on this issue will be of great help for us.
    Thank You in Advance!!!
    Reg,
    Jagan-SD.

    Jagan nath
    Try below.
    you would need miimum of 3 segments to pass variant config data using this bapi
    ORDER_CFGS_REF for each configurable item
    POSEX = ITEM #
    CONFIG_id , root_id - Start with 1 and increment it for each configurable line item
    ORDER_CFGS_INST
    CONFIG_ID - from above
    INST_ID - Start with 1 and increment it for each configurable line item
    OBJ_TYPE = "MARA'
    CLASS_TYPE = '300'
    OBJ_KEY = material #
    ORDER_CFGS_VALUE
    CONFIG_ID for the item, INST_ID for the item
    charc for characteristic value
    VALUE for characteristic value
    Reference thread
    How to Fill Configuration Data in BAPI BAPI_SALESORDER_CREATEFROMDAT2
    Hope it will solve your issue.
    Thanks
    Ritesh

  • BAPI to create sales order with reference to another sales order

    hi all,
    is there a bapi that allows you to create a sales order with reference to another sales order?
    thanks,
    V

    Hi Valencia,
    I think the normal BAPI (BAPI_SALESORDER_CREATEFROMDAT1)will do. You will have to fill the fields REF_DOC, REF_DOC_IT, REF_DOC_CA of the table ORDER_ITEMS_IN (and make sure that Customizing settings allow you to copy from order to order).
    Regards,
    John.

  • BAPI to create sales order

    Hi friends i am facing problem in this code , i tried a lot but still some errors are coming  can you please suggest how to remove the errors, anwers will be rewarded , thanks in advance
    *& Report  Z_TEST_BAPI
    REPORT  Z_TEST_BAPI.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
    header line.
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LINE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
            SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
           PURCH_DATE(10),
            PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
            PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
            ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
           CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
            TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
           ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
           MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    *data: tab like alsmex_tabline occurs 0 with header
    *line.
    DATA: gd_currentrow type i.
    data : PURCHASEORDER like ekko-ebeln.
    Data: tot_rec type i,     "Total Records
         gd_update type i,   "Main Table Increement Counter
         gd_lines type i,    "Success Table increement Counter
         w_textout like t100-text. "VARIABLE TO GET ERRORLOG
    data : begin of it_success occurs 0,
            SALESDOCUMENT LIKE BAPIVBELN-VBELN,  "PROJECT
          end of it_success.
    data : begin of it_error occurs 0,
            srno(4),
            err_msg(73) TYPE c,    "TO RETREIVE ERROR MESSAGES
         end of it_error.
    data : srno(4).
    DATA : SALESDOCUMENT LIKE  BAPIVBELN-VBELN.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                     = p_infile
       FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = tab.
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    **perform open_group.
    sort tab by row col.
    Get first row retrieved
    read table tab index 1.
    Set first row retrieved to current row
    gd_currentrow = tab-row.
    loop at tab.
    Reset values for next row
       if tab-row ne gd_currentrow.
         append tab .
         clear tab.
         gd_currentrow = tab-row.
       endif.
       SHIFT TAB-VALUE LEFT DELETING LEADING SPACE.
       case tab-col.
         when '0001'.
           TAB-SRNO = tab-value.
         when '0002'.
           TAB-DOC_TYPE = tab-value.
         when '0003'.
           TAB-SALES_ORG = tab-value.
         when '0004'.
           TAB-DISTR_CHAN = tab-value.
         when '0005'.
           TAB-DIVISION = tab-value.
         when '0006'.
           TAB-REQ_DATE_H =  tab-value.
         when '0006'.
           TAB-PURCH_DATE = tab-value.
         when '0007'.
           TAB-PMNTTRMS = tab-value.
         when '0008'.
           TAB-PURCH_NO_C = tab-value.
           when '0009'.
           TAB-ITM_NUMBER = tab-value.
          when '0010'.
           TAB-CUST_MAT22 = tab-value.
         when '0011'.
           TAB-PLANT  = tab-value.
         when '0012'.
           TAB-TARGET_QTY = tab-value.
         when '0013'.
           TAB-PARTN_ROLE = tab-value.
         when '0014'.
           TAB-PARTN_NUMB = tab-value.
       endcase.
    endloop.
    append tab.
    clear tab.
      sort tab by SRNO.
      LOOP AT TAB.
       concatenate tab-REQ_DATE_H+4(4)
    *tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
    *tab-REQ_DATE_H.
       concatenate tab-PURCH_DATE+4(4)
    *tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
    *tab-PURCH_DATE.
        SRNO = TAB-SRNO.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-PARTN_NUMB
          IMPORTING
            OUTPUT = tab-PARTN_NUMB.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-MATERIAL
          IMPORTING
            OUTPUT = tab-MATERIAL.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                input         = tab-ITM_NUMBER
             IMPORTING
               OUTPUT        = tab-ITM_NUMBER .
        IF TAB-SRNO = SRNO.
          ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
          ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
          ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
    ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
         ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
          ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
          ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
          ORDER_HEADER_IN-DIVISION  = tab-DIVISION.
          ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
           ORDER_ITEMS_IN-MATERIAL = TAB-MATERIAL.
         ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
          ORDER_ITEMS_IN-PLANT      = TAB-PLANT.
          APPEND ORDER_ITEMS_IN.
          ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
          ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
          APPEND ORDER_PARTNERS.
         ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
          append ORDER_SCHEDULES_IN.
        ENDIF.
        AT END OF SRNO.
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
               SALESDOCUMENTIN               =
                 ORDER_HEADER_IN               = ORDER_HEADER_IN
               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_ITEMS_IN
               ORDER_ITEMS_INX               =
                 ORDER_PARTNERS                = ORDER_PARTNERS
                 ORDER_SCHEDULES_IN            = ORDER_SCHEDULES_IN
               ORDER_SCHEDULES_INX           =
               ORDER_CONDITIONS_IN           =
               ORDER_CONDITIONS_INX          =
               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_KEYS                    = ORDER_KEYS
               EXTENSIONIN                   =
               PARTNERADDRESSES              =
          IF SALESDOCUMENT <> SPACE.
            commit work.
            ADD 1 TO gd_update.
            it_success-SALESDOCUMENT = SALESDOCUMENT.
            append it_success.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ELSE.
            loop at return.
              it_error-SRNO = tab-SRNO.
              it_error-err_msg = return-MESSAGE .
              Append it_error.
            ENDLOOP.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ENDIF.
        endat.
      endloop.
      DESCRIBE TABLE it_success LINES gd_lines.
      IF gd_lines GT 0.
        Display result report column headings
        PERFORM display_column_headings.
        Display result report
        PERFORM DISPLAY_SUCESS.
      ENDIF.
    IF SUCESS FAILS Display Error Report
      DESCRIBE TABLE it_error LINES gd_lines.
      IF gd_lines GT 0.
        PERFORM errorheadings.
        PERFORM errorreport.
      ENDIF.
    *&      Form  display_column_headings
          text
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'records inserted sucessfully:'(013).
      WRITE:/ sy-uline(15).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
               (10) 'Sales order'(004), sy-vline.
      WRITE:/ sy-uline(15).
    ENDFORM.                    "display_column_headings
    *Subroutine to display SUCESS REPORT
    FORM DISPLAY_SUCESS.
      FORMAT COLOR COL_NORMAL.
      LOOP AT it_success.
        WRITE:/      sy-vline,
            (10)  it_success-SALESDOCUMENT, sy-vline.
        CLEAR it_success.
      ENDLOOP.
      WRITE:/ sy-uline(15).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                               "DISPLAY_REPORT
    *&      Form  errorreport
          text
    FORM errorreport.
      LOOP AT it_error.
        WRITE:/      sy-vline,
                (10) it_error-SRNO, sy-vline,
                 (40) it_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    endform.                    "errorreport
    *&      Form  ERRORHEADINGS
          text
    FORM ERRORHEADINGS.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
    WRITE:2 'The following records failed during
    *update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'ERROR.'(009), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    "ERRORHEADINGS
    **&      Form  value_help
          text
    -->  p1        text
    <--  p2        text
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_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.
    endform.
    test data
    1     TA     PB01     01     00     0004     45     10     852     B001     10     AG     8101000000

    Hello,
    You need to call BAPI_TRANSACTION_COMMIT instead of the commit after each BAPI call to commit the data to the database.
    Usually you also have to fill in the _INX structures for header item and schedule line to indicate what fields are to be changed.
    Hope that helps,
    Michael

  • Problem when using BAPI to create return order

    Hi All,
    I need urgent Information.
    I am using BAPI_CUSTOMERRETURN_CREATE and BAPI_CUSTOMERRETURN_CHANGE to create and change quantity of return order. In both cases I am getting the result that quantity value is not getting updated.
    are these BAPIs are correct to fulfil my requirement, if yes could you please clarify?
    other wise, can I use BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE?
    and could you please some details about quantity change in Outbound delivery?
    I am using BAPI_OUTB_DELIVERY_CHANGE for this

    Hi
    <u>You need to do exeute a BAPI_TRANSACTION_COMMIT after the succesful execution of both the function modules BAPI_CUSTOMERRETURN_CREATE and BAPI_CUSTOMERRETURN_CHANGE.</u>
    <b>I mean, please insert CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  function module in the program, after each function module call</b>. 
    Hope this will help.
    Please reward suitable points.
    Regards
    - Atul

Maybe you are looking for

  • Exporting slices from multiple states doesn't name the 1st state

    I've tried various setups in the File > HTML Setup > Document Specific options for setting state names for exported slices, and i've tried the defaults. Whenever I have a page with multiple states, and i want to export a slice from each state, when i

  • Can i use a usb to see films stored

    ok i want know if i can use the usb connection to view videos stored on the usb.

  • ASDM and privilege level (using TACACS)

    Hi experts, Initial question:     How can I force ASDM to ask for the enable password when the user click on Apply ? Environment description: I have an ASA 5510 connected to an ACS 5.0. Security policy: I want the user defined on my ACS to be able to

  • Blank screen when attempting to view PDF

    Using a browser, I go to an link that gets an .fdf file (https://server.com/file.fdf). Inside the fdf file is a /F (https://server.com/file.pdf) call. If the install of Acrobat Reader 9.3.3/9.3.4 has been done straight from the web, a yellow bar appe

  • Why can't I download Adobe Premiere?

    Hi, I'm a subscriber of Adobe Creative Cloud. Up to now I had (almost) no problems. Today I tried to download Adobe Premiere, which is shown in my list of apps and services on the web. When I click on the download link next to the Premiere Icon the A