Error: Can't Add a New Sales Order: -10  Exchange rate not updated,

Hi,
I'm trying to add several Sales Orders contained in a XML document, whose root element corresponds to the Sales Person created that XML. Anyway, after I fill a Sales Order Document Object with the info in the XML and try to add it the following error appears: "Exchange rate not updated  [RDR1.U_Desc4][line: 2] , 'USD'" Which is strange because this company handles most of its transactions in MXP Currency. I will post the piece of Code that fills the object hoping it helps:
For Each xndSalesOrder In xmlSalesOrder.Item("SalesMan").ChildNodes
                oSalesOrder = Me.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
                oSalesOrder.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
                With xndSalesOrder.Item("HEADER")
                    oSalesOrder.CardCode = .Item("Deudor").InnerText
                    oSalesOrder.DocDate = DateTime.Parse(.Item("FechaCont").InnerText, Nothing)
                    oSalesOrder.DocDueDate = DateTime.Parse(.Item("FechaEnt").InnerText, Nothing)
                    oSalesOrder.Comments = .Item("Observaciones").InnerText
                    oSalesOrder.DocRate = 11
                    oSalesOrder.DocCurrency = "MXP"
                    'oSalesOrder.ContactPersonCode = .Item("Contacto").InnerText
                    'User Fields
                    oSalesOrder.UserFields.Fields.Item("U_RefOV").Value = _
                        xndSalesOrder.Attributes.Item(0).InnerText
                    oSalesOrder.UserFields.Fields.Item("U_Referencia2").Value = .Item("Referencia").InnerText
                    oSalesOrder.UserFields.Fields.Item("U_FechaReferencia").Value = _
                        DateTime.Parse(.Item("FechaReferencia").InnerText, Nothing)
                End With
                With xndSalesOrder.Item("LINEAS")
                    For Each xndLinea In .ChildNodes
                        If intContLineas >= 1 Then                             oSalesOrder.Lines.Add()
                        End If
                        oSalesOrder.Lines.ItemCode = xndLinea.Item("Articulo").InnerText
                        oSalesOrder.Lines.Quantity = CDbl(xndLinea.Item("Cantidad").InnerText)
                        oSalesOrder.Lines.Price = CDbl(xndLinea.Item("Precio").InnerText)
                        oSalesOrder.Lines.TaxCode = xndLinea.Item("Impuesto").InnerText
                        oSalesOrder.Lines.DiscountPercent = CDbl(xndLinea.Item("DescuentoTotal").InnerText)
                        oSalesOrder.Lines.SalesPersonCode = xmlSalesOrder.Item("SalesMan").Attributes.Item(0).InnerText
                        oSalesOrder.Lines.Currency = "MXP"
                        'User Fields
                        oSalesOrder.Lines.UserFields.Fields.Item("U_Promocion").Value = _
                            xndLinea.Item("AplicaProm").InnerText 'Valores posibles: Si, No
                        oSalesOrder.Lines.UserFields.Fields.Item("U_Desc1").Value = _
                            CInt(xndLinea.Item("Descuento1").InnerText)
                        oSalesOrder.Lines.UserFields.Fields.Item("U_Desc2").Value = _
                            CInt(xndLinea.Item("Descuento2").InnerText)
                        oSalesOrder.Lines.UserFields.Fields.Item("U_Desc3").Value = _
                            CInt(xndLinea.Item("Descuento3").InnerText)
                        'If xndLinea.Item("AplicaProm").InnerText = "Si" Then
                        oSalesOrder.Lines.UserFields.Fields.Item("U_Desc4").Value = _
                            CInt(xndLinea.Item("Descuento4").InnerText) 'This is the UDF that's giving me problems!!!
                        'End If
                        intContLineas += 1
                    Next
                   If oSalesOrder.Add() <> 0 Then
                        Me.Company.GetLastError(intErrorAdd, sErrMsgAdd)
                        If (0 <> intErrorAdd) Then
                            FillLog("Sales Order Error: " & CStr(intErrorAdd) & "," & sErrMsgAdd)
                        End If
                        xmlLogSalesOrder.Item
                    End If
                End With
            Next
If you look at the code I've even tried the solution of hardcoding the DocRate and the Currency as seen in a similar post about the DTW.
Sorry if code is in Spanglish, its quite late around here. I hope you can help me because it's kind of an urgent matter and I can't seem to find a solution for it.
Other useful data: SAP BO 2005 Patch 4.
Thanks in advance...
Alfredo Gargari

Hi Alfredo,
Have you tried to add the same salesorder by hand, I think you wil first get a form with exchange rates.
I think you should add a check to your program to check for an update currency rate (the sbobob function GetCurrencyRate does this for you).
GetCurrencyRate MethodDescription
Returns a Recordset object that contains the currency rate for a specified date and currency code.
See Currency Bobs sample.
Syntax
Public Function GetCurrencyRate( _
   ByVal Currency As String, _
   ByVal Date As Date _
) As Recordset
Parameters
Currency
Specifies the currency code.
Date
Specifies the date for the currency exchange rate.
Return Type
A Recordset object that contains one field named CurrencyRate that holds the rate value.
SAP Business One returns 0 if the system cannot find the exchange rate.
Regards,
Ad

Similar Messages

  • How can I create a new sales order template

    Hello,
    how can I create a new sales order template in SAP CRM 7.0 (Web UI)? I want to use this sales order template in scenario ´'Mass Generation of Sales Orders via Marketing Projects'.
    Thanks for your support in advance.
    Best regards,
    anvan

    Hi,
    Did you set up this scenario? I want something similar, but I want an ERP order to be created. Do you know if that is possible? Do you have som tips?
    regards Camilla

  • How can I create a new sales order template in SAP CRM 7.0

    Hello,
    how can I create a new sales order template in SAP CRM 7.0 (Web UI)? I want to use this sales order template in scenario ´'Mass Generation of Sales Orders via Marketing Projects'.
    Thanks for your support in advance.
    Best regards,
    anvan

    Hi,
    Did you set up this scenario? I want something similar, but I want an ERP order to be created. Do you know if that is possible? Do you have som tips?
    regards Camilla

  • DTW Error -- "Exchange Rate Not Updated"

    After resolving my other document loading errors identified by the DTW, I now receive the same error for every record that I try to load for Purchase Invoices, Sales Orders and Sales Invoices.  It is…
    <b>Exchange rate not updated, ‘USD’  Notice: all records are rollbacked.</b>
    Any idea how to fix this?  I'm confused since I built the company with both Local and System Currencies as “US Dollar”, the Default Account Currency is the “Local Currency”, and the document load includes the DocCurrency field (set to "USD").
    I need to get this data loaded soon.  Any help would be greatly appreciated!
    Kind Regards,
    Scott

    My issues have been resolved...
    (1) The GL account must be an "expense" account.  The data migration that I am performing is pulling from another system that stores these transaction in a different way.  Therefore, even though the accounts from the source ERP system to B1 have been mapped correctly, I had to use a different "expense" account as the GL account associated with transactions in B1.
    (2) The DocType was, indeed, necessary to handle Service-type Purchase Invoices.  However, the DTW requires that the DocType value be set to '0' (for Items) or '1' (for Services).  This differs from the 1-character designation stored in the database table OPCH, a 'I' (for Items) and 'S' (for Services).  I would make a humble suggestion to SAP to setup the DTW accepted field values the same as are found in the database (or, at least, have a single and comprehensive resource for knowing what these accepted values should be).
    and, as noted above...
    (3) The DocCurrency and DocRate fields were required to load my data.  I suspicion that DocCurrency is required for all loads.  However, DocRate may not be since it could be set in the Exchange Rate form within B1.  Since my setup used the LC as the default currency AND I am using USD for both LC and SC, I believe it was necessary for me to use the DocRate field for this load.  This is another eccentricity that I would suggest SAP enclose within some sort of documentation about the DTW tool.
    The use of the DTW can be significantly simplified for customers with documentation and examples on its use.  The existing documentation is deficient.  Otherwise, I find it a nice tool to ease the data migration process for setting up Companies.
    Should anyone have further questions on my experience with this issue or other DTW-related topics, I would be pleased to reply with my experiences.  My contact information is available through my profile on this site.
    Kind Regards,
    Scott

  • Can we add a new column in report which is not in table.

    Hi All,
    Can we create a new column in report which is not in table.
    I have two columns in my table completion_date, manufacture_date. If the difference between the completion_date and manufacture_date is 0, -1, 1 then the new column of the report will say on time against each record or else will display late. Any suggestion how to proceed on this
    Regards
    Edited by: User_Apex on May 16, 2011 5:54 AM

    Standard report then, NOT an interactive report (which if you were using, you could build a computation and report on that)..
    Then the adding a column in the query would be your best best...
    Thank you,
    Tony Miller
    Webster, TX
    There are two kinds of pedestrians -- the quick and the dead.
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Runtime error when I add materials to Sales order

    Hi All,
    The user attempted to add materials to Order 4002262638.    When adding 05302 and 05804 to the sales order, SAP
    went to the hourglass and then created the Timed out Runtime Error message.
    The Error at SAP Standard program LZVA_PRO_ALLOF01 at statement,
    When I press enter after giving materials its getting timed out due to long execution time. Looks the select query is taking lot of execution time.
    SELECT DISTINCT vbap~vbeln
             vbap~posnr
             vbap~kwmeng
        FROM vbap INNER JOIN vbak ON vbapvbeln = vbakvbeln
                  INNER JOIN vbep ON vbapvbeln = vbepvbeln
                                 AND vbapposnr = vbepposnr
        INTO TABLE lt_vbap
        WHERE vbak~kunnr  IN r_hienr  AND
              vbap~prodh  IN r_prdha  AND
              vbap~abgru  EQ space    AND
              vbep~wadat  LE gv_datbi AND
              vbep~wadat  GE gv_datab AND
              vbep~edatu  NE '00000000' AND
            vbep~bmeng GT 0 AND
              vbap~kwmeng GT 0.
    Please let me know your ideas.
    Thanks in advance,
    Rama

    Hi,
    Check if some user exits have been written in the includes attached to main porogram in sales order.
    May be the exits arent properly written or activated
    Regards,
    Dhananjay

  • Can we add Delivery texts/Sales order text in VL10 report

    Hi,
    Is it possible to have delivery texts/sales order texts on VL10 report.
    Please let me know if there is a way to do it.I've looked at the note198137.
    Thanks in advance.
    Regards,
    Rekha

    Yes I am aware of the fact that text is accessed thru read_text FM .....
    My question is what parameters/ field values can we plug in STXH/STXL to get info that a particular "text" entry exists in this table. I have a sales order which has few texts, I want to know if they have an entry in STXH and STXL about their text i.d.s....
    Let me put it this way - What ever entry exists in STXH for this sales Order I want to see that. What parameters of this sales order do I pass in this Table STXH to see that entry ??
    I hope this is clear now

  • Sales order request date could not updated by the interface.

    Hi Experts.
    Please refer to following scenario:
    1.Sales order line with quantity 1000.
    2.Customer wants to split the order quantity to 200 & 800, by the same time, need to specify the request date for the newly added line (With quantity 800)
    But the request date always defaulted from the order header level.
    Refer to the following scripts:
    INSERT INTO oe_headers_iface_all
    order_source_id,
    orig_sys_document_ref,
    operation_code,
    created_by,
    creation_date,
    last_updated_by,
    last_update_date,
    change_reason,
    ORG_ID,
    CHANGE_SEQUENCE,
    FORCE_APPLY_FLAG
    VALUES
    0, -- order_source_id
    'OE_ORDER_HEADERS_ALL372793', -- orig_sys_document_ref
    'UPDATE', -- operation_code
    12613, -- created_by
    SYSDATE, -- creation_date
    12613, -- last_updated_by
    SYSDATE, -- last_update_date
    'SYSTEM',
    204,
    2,
    'Y'
    INSERT INTO oe_lines_iface_all
    order_source_id,
    orig_sys_document_ref,
    orig_sys_line_ref,
    orig_sys_shipment_ref,
    operation_code,
    ordered_quantity,
    created_by,
    creation_date,
    last_updated_by,
    last_update_date,
    change_reason,
    org_id,
    CHANGE_SEQUENCE,
    inventory_item_id,
    OVERRIDE_ATP_DATE_CODE
    VALUES
    (0, -- order_source_id
    'OE_ORDER_HEADERS_ALL372793', -- orig_sys_document_ref
    'OE_ORDER_LINES_ALL687228', -- orig_sys_line_ref
    'OE_ORDER_LINES_ALL687228.1', -- orig_sys_shipment_ref
    'UPDATE', -- operation_code
    800,
    12613, -- created_by
    SYSDATE, -- creation_date
    12613, -- last_updated_by
    SYSDATE, -- last_update_date
    'SYSTEM',
    204,
    2,
    245205,
    'Y'
    INSERT INTO oe_lines_iface_all
    order_source_id,
    orig_sys_document_ref,
    orig_sys_line_ref,
    split_from_shipment_ref,
    split_from_line_ref,
    operation_code,
    ordered_quantity,
    created_by,
    creation_date,
    last_updated_by,
    last_update_date,
    org_id,
    CHANGE_SEQUENCE,
    inventory_item_id,
    REQUEST_DATE,
    OVERRIDE_ATP_DATE_CODE
    VALUES
    (0, -- order_source_id
    'OE_ORDER_HEADERS_ALL372793', -- orig_sys_document_ref
    'LT_TESTLINE', -- orig_sys_line_ref
    'OE_ORDER_LINES_ALL687228.1', -- split_from_shipment_ref
    'OE_ORDER_LINES_ALL687228', -- orig_sys_line_ref of the line for which you want to split the line
    'INSERT', -- operation_code
    200,
    12613, -- created_by
    SYSDATE, -- creation_date
    12613, -- last_updated_by
    SYSDATE, -- last_update_date
    204,
    2,
    245205,
    '22-NOV-2014',
    'Y');
    3.SO has been splitted to 2 lines:
    1.1. 800 request date 12-NOV-2014
    1.2  200 request date 12-NOV-2014
    Christy

    Hi
    Sorry , for keeping messing up :
    38.45.0 is referring to Invoice row level base key
    logic is saying  Delivery number is equal to invoice row level base key
    If you look at the link and Gagan answer ,your problem should have been solved .
    Please close this thread if your problem is solved .
    Thann you
    Bishal
    Definitely need a coffee to start my day
    Edited by: BIshal Adhikari on Jul 9, 2009 6:44 AM
    Edited by: BIshal Adhikari on Jul 9, 2009 6:44 AM

  • Can't add a new POP or Exchange Account since SL

    My existing accounts upgraded and are working fine, but I can't add any new POP account or Exchange account since the upgrade.
    Mail won't save the password for the new account in any of the preference settings. When I finish the set-up Mail keeps asking me to type in my password. When I do it keeps giving me a message saying the password was rejected by the server.
    I repaired keychain access and deleted any keychains associated with the new account I was trying to add. Didn't help. I had my ISP open port 25 while on the phone with them. Didn't work. I've gone into the Advanced Tab and edit server list and tried every setting possible. Tried with authentication and without. I've tried it from a new desktop and from the one where my existing accounts are. I've tried turning the new account which is working on my iphone off and then adding it to Mail. No luck.
    I don't know code. Any other work around suggestions?

    I can't add the new account to even get to the point where I could send or receive. I go through the entire set up but the account never goes online. Once i have it all set up is where I started playing around with the port settings, etc. Still have never been able to get it online. The account works fine on my iphone. An account with the same isp provider that was already working in Mail before SL is working fine. I upgraded a new imac that I bought in July and a 3 year old one. Same problem on both. Can't add a new POP AT&T Yahoo account or an Exchange account to Mail 4.0. I've read other threads and tried several different trouble shooting suggestions. I repaired the keychain. I've deleted the passowrd from keychain and tried re-entering them. The password never saves in the Mail preferences for the new account I am trying to add. At the same time every time I am prompted to type in the password it tell me the password is rejected. I tried changing the username like you mentioned. Tried just the user name alone and with the extension "@att.net". Didn't help.
    Any other ideas?

  • Can't specify the customer to use a new sales order type ,why?

    I created a new sales order type, finished the configeration.. but when I use it to create a order by t_code VA01 ,input the order type and sales area ,then enter, why the sold-to-party and ship-to-party are inmodifiable? i can't specify the customer... where is the problem?
    appreciate you help.thank you !

    Hi Sue,
             I think u havent did the Partner determination for that Sales document.  If you create ur own sales doc type in VOV8 ,new entries.
    U need to maintain the Partner determination for that sales doc type.
    this is the same,the way u maintaint the customer partner determination.
    If you dont maintain this , in VA01 screen, u cant able to enter Sold to & ship to parties as it will be in display mode. I think the same error ur getting know as per ur issue.
    This will def solve ur issue as i faced n overcome long back.
    *reward points ,if helpful

  • How can I add a new line item for production order?

    HI all,
    How can I add a new line item for production order through BAPI/FM? Thanks in advance.

    Hi Mil,
      Unfortunetly SAP is not in front of me.
    But if possible go to BAPI transaction , check for any production order's bapi for CHANGE purpose. Where you will be able to add your new line.
    Reward if useful!

  • Can we create new sales order for RMA?

    Hi
    We have processed one sales order eg.ABC in INR instead of USD and we have closed it. Later we found that the order entry was wrong (that is the currency was wrongly entered in INR instead of USD) and created a new sales order eg. XYZ for RMA of that material and entered the sales order number ABC and invoice number as reference under returns tab. Now if I go to take the receipt of the new sales order created for RMA that for XYZ , I was not able to see that order number XYZ from the list of values in Receiving Transactions under Customer tab.
    Can anyone please give me an idea on how to open an closed order and to cancel the existing order so that i can take back the material in the same closed order i.e, ABC after reopening it and cancel the new sales order i.e, XYZ created for RMA.
    Thanks in advance
    Prem.

    You have mentioned that the sales order is closed. Does it mean that the lines are interfaced to AR ? Is the invoice generated? Is the shipment done?

  • Can anyone tell me how to insert the new sales order lines using API.

    Hi,
    I am trying to Insert new sales order lines using oe_order_pub.Process_Order API, but i am unable to insert.
    Help me on this.
    Thanks in Adavance
    Shravan Kumar.

    Hi,
    Have you checked this link?
    http://download-west.oracle.com/docs/cd/B25516_08/current/acrobat/115omapi.zip
    it has extensive information on OM APIs
    Regards
    Prashant Pathak

  • Sales order cancelled and new sales order with added components

    Hi all,
    There is a MTO scenario.Lets say a product X was to be made .Now when the production was complete,the sales order got cancelled and a new sales order was generated for same product with 2 new components to be added,lets say A and B.
    So now i have to use the finished good x and new components A and B for the new sales order.How will the costing of new product be done and how do i maintain the BOM?

    Dear,
    You have to create the new material code for your new product as it is having two new components. For that new product say Y you need to add the X, A and B.
    As you have already manufactured the X so system will not create any procurement proposal for it and you can consume the X while manufacturing the Y and it cost also get capture to the Y. This is standard Practice.
    Hope clear to you.
    Regards,
    R.Brahmankar

  • Creation of new Sales order

    Hi,
           While creating a new Sales Order(tcode VA01) depending on the material, Item category will be generated and depending on the Item category purchase requisition screen(ME51n) will be automatically opened and PR will be created.
    Now to automate this process, BAPI_SALESORDER_CREATEFROMDAT1 will be called to create the sales order. But the requirement is that we need to pass Requisitioner and Vendor to the BAPI for creation of PR.
    But in this BAPI there is no option/field to pass Requisitioner and Vendor. So is there any other BAPI/Function Module where a new Sales order is created and also we can pass Requisitioner and Vendor required for creation of new PR.

    REPORT  ZSALESORDER.
    Parameters
    Sales document type
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d .
    SELECTION-SCREEN END OF LINE.
    Complete Deliver
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_autlf.
    PARAMETERS: p_autlf TYPE autlf DEFAULT 'X'.
    SELECTION-SCREEN END OF LINE.
    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.
    DATA: lt_schedules_ink    TYPE STANDARD TABLE OF bapisdhead1
                             WITH HEADER LINE.
    Initialization.
    INITIALIZATION.
    v_text   = 'Order type'.
    v_text1  = 'Sales Org'.
    v_text2  = 'Distribution channel'.
    v_text3  = 'Division'.
    v_text4  = 'Sold-to'.
    v_text5  = 'Ship-to'.
    v_text6  = 'Material'.
    v_text7  = 'Quantity'.
    v_text9  = 'Plant'.
    v_text10 = 'Complete delivery'.
    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'.
    *Complete delivery
        header-COMPL_DLV = p_autlf.
        header-COMPL_DLV = 'X'.
    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'.
    item category
      itemx-ITEM_CATEG = 'X'.
      APPEND item.
      APPEND itemx.
      ITEM DATA
      itemx-updateflag = 'I'.
    Line item number.
      item-itm_number = '000020'.
      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.
      Fill schedule lines
      lt_schedules_in-itm_number = '000020'.
      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  = '000020'.
      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.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.

Maybe you are looking for