Creating Sales Order, but picking up wrong ship-to-party

Hello Friends,
I am creating an urgent sales order by mentioning the sales organization, distribution channel and division.
I mention the sold-to-party X but do not enter the ship-to-party.
I know it selects the ship-to-party automatically based on the partner functions mentioned in the sales area data of the customer (sold-to-party X).
But my problem here is there are three ship-to-party mentioned, and it selects one. How does it determine which ship-to=party to determine?
Is it sorted in ascending order?

Hi Raj,
yes it does show a pop-up with multiple Ship-to-parties and i can select the required. I agree.
But actually i create sales order using a program, so the program calls BAPI_SALES_ORDER_CREATEFROMDATA which creates the sales order using the first entry in the partner functions pop-up by default.
I want to know how is it determined that which partner function is first? Is it in ascending order?
In the above screenshot, why does 16508 appear before 30597?

Similar Messages

  • Issue when creating sales order with Sold-to/Ship-to Party's state

    Hi All,
    we have issue while creating Sales Order with picking up of State tax
    for Ship-to-party & Sold-to-party.
    <b>When we create a sales order, for the sold to party 140052732 and
    ship to party 140052733 it is picking state tax. Which should not
    suppose to pick? Because the partner is marked as tax exemption</b>.
    Can any body tell me how can we solve this issue!
    Why this is happening!
    How to make not to pick tax when it is marked for tax exemtion.
    As i am not Functional guy i am not aware what is happening here!
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi Deep
    What do you mean by "It is picking up state tax"? Does it mean that in the pricing procedure it is picking up a condition type which is meant for state tax?
    If so go and check the condition record meant for it. Follow the following steps
    1) Go to Sales order
    2) Select the line item for which the state tax is being picked.
    3) In the condition tab select analysis.
    4) In Analysis you shall find the condition type meant for state tax.
    5) See which condition record has been found.
    6) Go to VK12, enter the state tax condition type and check the condition record for that state tax.
    7) If wrong correct it.
    8) If anything else come back to the post and inform the details
    Thanks
    Regards
    Sunil

  • Issue when creating sales order with Sold-to/Ship-to Party's state tax

    Hi All,
    we have issue while creating Sales Order with picking up of State tax
    for Ship-to-party & Sold-to-party.
    <b>When we create a sales order, for the sold to party 140052732 and
    ship to party 140052733 it is picking state tax. Which should not
    suppose to pick? Because the partner is marked as tax exemption</b>.
    Can any body tell me how can we solve this issue!
    Why this is happening!
    How to make not to pick tax when it is marked for tax exemtion.
    As i am not Functional guy i am not aware what is happening here!
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi Deep
    What do you mean by "It is picking up state tax"? Does it mean that in the pricing procedure it is picking up a condition type which is meant for state tax?
    If so go and check the condition record meant for it. Follow the following steps
    1) Go to Sales order
    2) Select the line item for which the state tax is being picked.
    3) In the condition tab select analysis.
    4) In Analysis you shall find the condition type meant for state tax.
    5) See which condition record has been found.
    6) Go to VK12, enter the state tax condition type and check the condition record for that state tax.
    7) If wrong correct it.
    8) If anything else come back to the post and inform the details
    Thanks
    Regards
    Sunil

  • Documentation on Creating Sales Order using Web Services

    hi,
    I can goto ESA Preview system using SAPGUI and create a sales order (using va01 transaction).
    I tried to do the similar thing using the WebService (Create Sales order), but have lots of problems.
    ->Fields used in WebServices are not in sync with what would be if you use the GUI. (example u enter sales region, buyer id, ship address and the items for a standard sales order.
    ->There is not much documentation on what the fields in the webservice mean. (e.g. what is the difference between BuyerParty and BuyerInternalId? )
    ->There are no sample combination of values that work. (Belive me it would take hours to figure out right combination of values needed..)
    Any hints would be appreciated
    Kiran
    http://erp.esworkplace.sap.com/socoview(bD1lbiZjPTgwMCZkPW1pbg==)/smdisplay.asp?id=138ABFEEA8A34999BFCEB31537EC8D65&fragID=&packageid=CBD4F2B708B8144DAEA05442D8FD491E&context=&iv=
    http://erp.esworkplace.sap.com/socoview(bD1lbiZjPTgwMCZkPW1pbg==)/smdisplay.asp?id=5640EE01E71B11DAB5240007E9102256&fragID=&packageid=CBD4F2B708B8144DAEA05442D8FD491E&iv=

    Hi...
    you can use Adaptive RFC methodology in web dynpro java to work with BAPIs..... these are standard bapi's provided
    Here are required Bapis... select which one you want....
    BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
    BAPI_ORDER_CHANGE_STATUS_GET Change status for order
    BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
    BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
    BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
    BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
    BAPI_SALESORDER_GETSTATUS Sales order: Display status
    BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order
    check this thread SALES ORDER creation using BAPI
    sample java program which will call SAP bapi function sales order create
    PradeeP

  • 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

  • Create Sales Order with Contract Accounts Receivable and Payable Set

    I have successfully created a Sales Order using BAPI BAPI_SALESORDER_CREATEFROMDAT2. Then, I need to set value to Contract Accounts Receivable and Payable in the Sales Order Header Data (Goto -> Header -> Accounting).
    How do I do that? Can I assign a value to Contract Accounts during creation of Sales Order using BAPI BAPI_SALESORDER_CREATEFROMDAT2?

    Hi Andrew Tan,
    iam trying to creats sales order but i cannot able to creats sales order.
    I had used BAPI_SALESORDER_CREATEFROMDAT2 to create
    iam getting an message as
    SALES_HEADER_IN has been processed successfully             
    SALES_ITEM_IN has been processed successfully               
    Order receipt/delivery not possible, credit customer blocked
    help me out of this problem
    Pleases send me the code for this creation.
    Waiting for your reply.
    Thanks,
    sayyed.

  • User Exit for correct ship-to Party while Creating Sales Order

    Dear Friends,
    Pls let me know which User Exit should I use to validate the Ship-to Party on the basis of Sold-to Party, while creating a sales order.
    In other words we wish to make sure that the user gives the correct Ship-to party corresponding to the Sold-to party, while creating a sales order.
    Regards,
    Alok.

    Dear Naveen,
    Thanks for replying.
    I do agree with you that SAP may validate the Ship-to Party in accordance with the Sold-to Party. But still the user may change  that Ship-to Party value and save the Sales Order with a wrong Ship-to Party.
    Here, my user wants a check/validation that no one should be able to save the sales order with wrong Ship-to Party other than the ones defined in Customer Master.
    Hope you got the issue now.
    Regards and thanks once again,
    Alok.

  • BAPI For Create Goods Issue for Sales order with picked quantity

    Hi friends,
            Is there any BAPI available to create Goods issue For sales order with picked quantity...............?
    we hv used BAPI_OUTB_DELIVERY_CREATE_SLS
    with sales order .......its creating delivery order but not doing goods issue with piked quantity........

    pls,reply its argent

  • While creating sales order I am getting  Sanctioned party list blocked  but I am able to create delivery, and PGI

    Dear GTS Experts,
    While creating sales order I am getting  Sanctioned party list blocked, but I am able to create delivery, and PGI.
    Where Is the wrong ?
    Thanks a lot
    Venu gopal

    Dear Venu
    Based on your message shown in the system, can you check the field in Control Settings for System Reaction in the Document type settings via Application Levels in the feeder system. This Field '' System Response in Feeder system if SAP GTS fails'' should be maintained with ''A''. I think in your case it could be 'Blank'' Thats why the system is allowing you to create the subsequent documents accordingly.
    Please let me know if any further inputs required.

  • Create sales order thru BDC but having problem with ZF partners

    I have a problem on the bdc program to create sales order with ZF partners.  When my users create sales order, they choose 'X' when the system pop up the zf partner screen,  the system will not create the ZF partner.  But when I run the bdc program without ZF partner, the system did not pop up the zf partner screen and allow me to run thru the whole creation process. But when I check the sales order it will pick up a default ZF no from customer master.  Is there anyone know how come the on line creation of sales order behave differently in BDC.

    I have a problem on the bdc program to create sales order with ZF partners.  When my users create sales order, they choose 'X' when the system pop up the zf partner screen,  the system will not create the ZF partner.  But when I run the bdc program without ZF partner, the system did not pop up the zf partner screen and allow me to run thru the whole creation process. But when I check the sales order it will pick up a default ZF no from customer master.  Is there anyone know how come the on line creation of sales order behave differently in BDC.

  • Alternative BOM picking at the time of creating sales order.

    Dear All,
    I have on requirment and it is as follows.
    I have 3 alternative BOMS for one material in same plant.Now sales order is created for this materila which alternatibe BOM will system pick.
    If there any possibility to customise alternative BOM picking at the time of creating sales order.Please let me know what settings do I need to configure for this.
    Thanks for your support and time.
    With Rgds,
    Babu

    hi,
    this is to inform you that,
    1. since you have 3 alternative BOM's.  so by default system will pick up that BOM which is first according to hirearchy level at the plant level.
    alternatively if the same material is going to be used for different purpose (PRODUCTION OR PLANNING), SECOND ALTRENATIVE bom will be picked.
    2. you will have to assign the BOM which you want to pick add it to the picking list (ASSEMBLY OF THE PRODUCTS/COMPONENTS).
    in CO27 - maintain the range of components at component level with plant as same for which you have already created a BOM.
    create a sales order according - that alternative BOM will be directly assigned to the sales order.
    please check and confirm.
    balajia

  • How to avoid XVBPA line item values while creating sales order

    Hi Friends
    I am creating Sales order using function module IDOC_INPUT_ORDERS, for that I am passing partner details through segment E1EDKA1.If I pass the same partner details(Partner number, name1,name4,city,postel code) which is same like customer master,
    I can able to book the order and entries are coming only one time in VBPA table(Header Item level).But if I change any value for the particular partner in the Input(For example Name4, there is no value in customer master but I added through program).Now its creating an order but its showing the entered partner informations in header level.When I checked the same in line item level, its not picking the values from header, its picking the values from customer master for that particular partner.
    So this line item also coming in VBPA table, because its different from header data.
    Anyone guide me, how to avoid this problem while booking order through program.
    Thanks
    Gowrishankar

    I am updating Ship-To-Party value in segment E1EDKA1 and calling IDOC_INPUT_ORDERS function module to create the sales order.
    In this case for the particular partner there is no NAME4 value in KNA1, I am passing some value through this segment E1EDKA1.
    So its creating an order with this new addresses , so its generating new ADRNR in VBPA header level.Thats fine.But the same time
    its not copying the same value from header to line item.
    In Line item level again its picking the address details from KNA1 for the particular partner number.So its showing Blank value in NAME4 field of line items.Its creating and spllitting issue, while creating delivery.
    Thanks
    Gowrishankar

  • Dump while creating sales order using BAPI

    Hi Experts,
    I am trying to create a sales order in my alv report using BAPI_SALESORDER_CREATEFROMDAT2. I get a dump while executing the program. Please suggest me where I am going wrong.
    |Source Code Extract                                                                               |
    |Line |SourceCde                                                                                |
    |    1|FORM FRM_KOND_BASIS_604.                                                                    |
    |    2|*{   INSERT         DEVK910738                                        1                     |
    |    3|                                                                                |
    |    4|data:  zuomqtyo   LIKE ekpo-menge,                                                          |
    |    5|       zuomqtyn   LIKE ekpo-menge,                                                          |
    |    6|       zqty1      type i,                                                                   |
    |    7|       zqty2(11)   type n.                                                                  |
    |    8|                                                                                |
    |    9|** Round up billing qty                                                                     |
    |   10|   if komp-zzLTKZA ne 'VAR'.                                                                |
    |   11|                                                                                |
    |>>>>>|      zqty1   = xkwert.                                                                     |
    |   13|      compute zqty2   = zqty1 / 1000.                                                       |
    |   14|      xkwert = zqty2 * 1000.                                                                |
    |   15|                                                                                |
    |   16|     exit.                                                                                |
    |   17|   endif.                                                                                |
    |   18|                                                                                |
    |   19|                                                                                |
    |   20|** Samples                                                                                |
    |   21|                                                                                |
    |   22|  if komp-MATKL = '5400'.                                                                   |
    |   23|                                                                                |
    |   24|    check not xkomv-kmein is initial.                                                       |
    |   25|    check not komp-vrkme  is initial.                                                       |
    |   26|                                                                                |
    |   27|** Make sure base is correct when sales unit and pricing unit differ                        |
    |   28|   if komp-vrkme ne xkomv-kmein.                                                            |
    |   29|                                                                                |
    |   30|     zuomqtyo = komp-MGAME.                                                                 |
    |   31|                                                                                |
    Thanks.

    John,
    Here is what I am doing.
    *Assign Header Data And Move To Header Data Final Table
              GS_ORDERHEADERIN-DOC_TYPE            = GC_AUART.
              GS_ORDERHEADERIN-SALES_ORG           = GC_SORG.
              GS_ORDERHEADERIN-DISTR_CHAN          = GC_DISTC.
              GS_ORDERHEADERIN-DIVISION            = GC_DIVI.
              GS_ORDERHEADERIN-ORD_REASON          = GC_AUGRU.
              GS_ORDERHEADERIN-REQ_DATE_H          = WA-USAGE_DATE.
              GS_ORDERHEADERIN-PURCH_DATE          = WA-USAGE_DATE.
              GS_ORDERHEADERIN-PURCH_NO_C          = WA-USAGE_DOC.
    *Assign Header Data And Move To Header Data Final Table
              GS_ORDERHEADERINX-DOC_TYPE           = GC_FLAG.
              GS_ORDERHEADERINX-SALES_ORG          = GC_FLAG.
              GS_ORDERHEADERINX-DISTR_CHAN         = GC_FLAG.
              GS_ORDERHEADERINX-DIVISION           = GC_FLAG.
              GS_ORDERHEADERINX-ORD_REASON         = GC_FLAG.
              GS_ORDERHEADERINX-REQ_DATE_H         = GC_FLAG.
              GS_ORDERHEADERINX-PURCH_DATE         = GC_FLAG.
              GS_ORDERHEADERINX-PURCH_NO_C         = GC_FLAG.
    *ASSIGN ITEMS DATA AND MOVE TO ITEMS DATA FINAL TABLE
            GS_ORDERITEMSIN-ITM_NUMBER         = WA-POSNR.
            GS_ORDERITEMSIN-MATERIAL           = WA-MATERIAL.
            GS_ORDERITEMSIN-TARGET_QTY         = WA-EXT_QTY.      "EXT_QTY is of type LFIMG
            GS_ORDERITEMSIN-TARGET_QU          = WA-EXT_UOM.      "EXT_UOM is of type VRKME
            APPEND GS_ORDERITEMSIN TO GT_ORDERITEMSIN.
            CLEAR GS_ORDERITEMSIN.
    *Assign Items Data And Move To Items Data Final Table
            GS_ORDERITEMSINX-ITM_NUMBER        = WA-POSNR.
            GS_ORDERITEMSINX-MATERIAL          = GC_FLAG.
            GS_ORDERITEMSINX-TARGET_QTY        = GC_FLAG.
            GS_ORDERITEMSINX-TARGET_QU         = GC_FLAG.
            APPEND GS_ORDERITEMSINX TO GT_ORDERITEMSINX.
            CLEAR GS_ORDERITEMSINX.
    *Assign Schedule Lines Data And Move To Schedule Lines Final Table
            GS_ORDER_SCHEDULES_IN-ITM_NUMBER   = WA-POSNR.
            GS_ORDER_SCHEDULES_IN-REQ_DATE     = WA-USAGE_DATE.
            GS_ORDER_SCHEDULES_IN-REQ_QTY      = WA-EXT_QTY.      "EXT_QTY is of type LFIMG
            APPEND GS_ORDER_SCHEDULES_IN TO GT_ORDER_SCHEDULES_IN.
            CLEAR  GS_ORDER_SCHEDULES_IN.
    *Assign Schedule Lines Data And Move To Schedule Lines Final Table
            GS_ORDER_SCHEDULES_INX-ITM_NUMBER  = WA-POSNR.
            GS_ORDER_SCHEDULES_INX-REQ_DATE    = GC_FLAG.
            GS_ORDER_SCHEDULES_INX-REQ_QTY     = GC_FLAG.
            APPEND GS_ORDER_SCHEDULES_INX TO GT_ORDER_SCHEDULES_INX.
            CLEAR  GS_ORDER_SCHEDULES_INX.
    *Assign Sold-To-Partner Data And Move To Final Partners Table
            GS_ORDERPARTNERS-PARTN_ROLE          = GC_SP.
            GS_ORDERPARTNERS-PARTN_NUMB          = GV_SOLD.
            APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
            CLEAR  GS_ORDERPARTNERS.
    *Assign Ship-To-Partner Data And Move To Partners Table
            GS_ORDERPARTNERS-PARTN_ROLE          = GC_SH.
            GS_ORDERPARTNERS-PARTN_NUMB          = GV_SHIP.
            APPEND GS_ORDERPARTNERS TO GT_ORDERPARTNERS.
            CLEAR  GS_ORDERPARTNERS.
    *Clear Global Variable Field Of Sales Document
              CLEAR:GV_SALESDOCUMENT.
    "Right after pressing F6 button after this. It gives me dump.
    *Call Function Module To Create Sales Order
              CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
                EXPORTING
                  ORDER_HEADER_IN     = GS_ORDERHEADERIN
                  ORDER_HEADER_INX    = GS_ORDERHEADERINX
                IMPORTING
                  SALESDOCUMENT       = GV_SALESDOCUMENT
                TABLES
                  ORDER_ITEMS_IN      = GT_ORDERITEMSIN
                  ORDER_ITEMS_INX     = GT_ORDERITEMSINX
                  ORDER_SCHEDULES_IN  = GT_ORDER_SCHEDULES_IN
                  ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX
                  ORDER_PARTNERS      = GT_ORDERPARTNERS
                  RETURN              = GT_BAPIRETURN.
    IF SY-SUBRC = 0.
    *Call Function Module For BAPI Commit
                CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                  EXPORTING
                    WAIT = GC_FLAG.
    ENDIF.
    All my BAPI tables have been filled with required data in them. But, still it is giving me a dump.
    I would really appreciate if some one could suggest me where I am going wrong.
    Thanks.

  • Web Service for "Creating Sales Order" by using BAPI

    Hello All,
    I am trying to create a WS for "Creating Sales Order". The corresponding BAPI that I am using for this purpose is BAPI_SALESORDER_CREATEFROMDAT1. I am able to create the Web Service and run the WSDL on WS Navigator.
    But there is a problem whil executing the Web Service. In the interface of WS, we can only enter item level details of "Order Partner". So when I enter the details and click on Execute, it returns me an error message "Please enter Ship to Party and Sold to Party". I have already given these details.
    Does any one have any idea of what is going wrong?
    Regards,
    Abhishek

    As you suggested i have passed the suggested parameters in item level..But this time i was not ablet to create the SO also..earlier i am able to creat SO but not line item, But now ia m not able to creat salesdocuement also.
    Return talbe filled with belwo messages.
    S V4                   233 SALES_HEADER_IN has been processed successfully   
    E V1                   320 No item category available (Table T184 ZKB  TEXT )
    E V4                   248 Error in SALES_ITEM_IN 000000                     
    W V1                   555 The sales document is not yet complete: Edit data 
    E V4                   219 Sales document  was not changed

  • Issue in creating sales order using BAPI's...?

    Hi Guru's,
    i had generated the sales order using the BAPI..but could please guide me how to declare the data declaratin same fields as globally and how to move internal table and how to append ....
    thanks in advance...
    REPORT z_bapi_salesorder_create.
    Sales document type
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    Sales organization
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    Distribution channel
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    Division.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    Sold-to
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    Ship-to
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    Material
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    Quantity.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    Plant
    PARAMETERS: p_plant TYPE werks_d 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.
    Start-of-selection.
    START-OF-SELECTION.
    Header data
    Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    Partner data
    Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    ITEM DATA
      itemx-updateflag = 'I'.
    Line item number.
      item-itm_number = '000010'.
      itemx-itm_number = 'X'.
    Material
      item-material = p_matnr.
      itemx-material = 'X'.
    Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    Quantity
      item-target_qty = p_menge.
      itemx-target_qty = '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 to create the sales order.
      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 the work.
       COMMIT WORK AND WAIT.
         call FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.

    *& Report  ZAREPAS30
    REPORT  zarepas30.
    DATA : gs_vbeln                   TYPE  vbak-vbeln,
           gs_order_header_in         TYPE  bapisdhd1,
           gs_order_header_inx        TYPE  bapisdhd1x,
           gt_order_items_in          TYPE  STANDARD TABLE OF bapisditm,
           gwa_itab1                  TYPE  bapisditm,
           gt_order_items_inx         TYPE  STANDARD TABLE OF bapisditmx,
           gwa_itab2                  TYPE  bapisditmx,
           gt_order_partners          TYPE  STANDARD TABLE OF bapiparnr,
           gwa_itab3                  TYPE  bapiparnr,
           gt_return                  TYPE  STANDARD TABLE OF bapiret2,
           gwa_itab4                  TYPE  bapiret2.
    Sales document type
      PARAMETERS: p_auart TYPE auart OBLIGATORY.
    Sales organization
      PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    Distribution channel
      PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    Division.
      PARAMETERS: p_spart TYPE spart OBLIGATORY.
    Requested Delivery Date
      PARAMETERS: p_edatu  TYPE edatu OBLIGATORY.
    Sold-to
      PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    Ship-to
      PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    Material
      PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    Quantity.
      PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    Plant
      PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    Start-of-selection.
      START-OF-SELECTION.
    Header data
    Sales document type
      gs_order_header_in-doc_type = p_auart.
      gs_order_header_inx-doc_type = 'X'.
    Sales organization
      gs_order_header_in-sales_org = p_vkorg.
      gs_order_header_inx-sales_org = 'X'.
    Distribution channel
      gs_order_header_in-distr_chan  = p_vtweg.
      gs_order_header_inx-distr_chan = 'X'.
    Division
      gs_order_header_in-division = p_spart.
      gs_order_header_inx-division = 'X'.
    Reguested Delivery Date
      gs_order_header_in-req_date_h = p_edatu.
      gs_order_header_inx-req_date_h = 'X'.
      gs_order_header_inx-updateflag = 'I'.
    Partner data
    Sold to
      gwa_itab3-partn_role = 'AG'.
      gwa_itab3-partn_numb = p_sold.
      APPEND gwa_itab3 TO  gt_order_partners .
    ship to
      gwa_itab3-partn_role = 'WE'.
      gwa_itab3-partn_numb = p_ship.
      APPEND gwa_itab3 TO  gt_order_partners .
    ITEM DATA
      gwa_itab2-updateflag = 'I'.
    Line item number.
      gwa_itab1-itm_number = '000010'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    Line item number.
      gwa_itab1-itm_number = '000020'.
      gwa_itab2-itm_number = 'X'.
    Material
      gwa_itab1-material = p_matnr.
      gwa_itab2-material = 'X'.
    Plant
      gwa_itab1-plant    = p_plant.
      gwa_itab2-plant   = 'X'.
    Quantity
      gwa_itab1-target_qty = p_menge.
      gwa_itab2-target_qty = 'X'.
      APPEND gwa_itab1 TO gt_order_items_in.
      APPEND gwa_itab2 TO gt_order_items_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
        order_header_in               = gs_order_header_in
        ORDER_HEADER_INX              = gs_order_header_inx
      IMPORTING
        SALESDOCUMENT                 = gs_vbeln
      tables
        RETURN                        = gt_return
        ORDER_ITEMS_IN                = gt_order_items_in
        ORDER_ITEMS_INX               = gt_order_items_inx
        order_partners                = gt_order_partners.
    Check the return table.
      LOOP AT gt_return into gwa_itab4 WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error occured while creating sales order '.
      ELSE.
    Commit the work.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        WRITE: / 'Document ', gs_vbeln, ' created'.
      ENDIF.

Maybe you are looking for