Problem in creating sales order with BAPI_SALESDOCU_CREATEFROMDATA1.

Hi everybody
I am not able create a sales order with BAPI_SALESDOCU_CREATEFROMDATA1.i also did debugging.its not throwing  up any errors in return table. return table is empty. but when i check the  BAPI in se37 with same data its creating the sales order.
Here i am attaching my program.please kindly can anyone have a look and tell me whether i did anything wrong in  the program.
thx in advance.
*& Report  YORDERCREATE
REPORT  YORDERCREATE.
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: it_schedules_inx like bapischdlx occurs 0 with header line.
data: it_schedules_in like bapischdl occurs 0 with header line.
types: begin of itab,
auart like vbak-auart,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
spart like vbak-spart,
kunnr like kuagv-kunnr,
kunnr1 like kuwev-kunnr,
posnr like  vbup-posnr,
matnr like mara-matnr,
Tquan type string,
end of itab.
data: it-out type table of itab with header line.
data: menge(10) type c.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = 'C:\VA01.TXT'
  FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                      = it-out.
loop at it-out.
header-doc_type = it-out-auart.
headerx-doc_type = 'X'.
header-sales_org = it-out-vkorg.
headerx-sales_org = 'X'.
header-distr_chan = it-out-vtweg.
headerx-distr_chan = 'X'.
header-division = it-out-spart.
headerx-division = 'x'.
headerx-updateflag = 'I'.
*partner data
partner-partn_role = 'SP'.
partner-partn_numb = it-out-kunnr.
append partner.
partner-partn_role = 'SH'.
partner-partn_numb = it-out-kunnr1.
append partner.
*item data
itemx-updateflag = 'I'.
item-itm_number = it-out-posnr.
itemx-itm_number = 'X'.
item-material = it-out-matnr.
itemx-material = 'X'.
item-target_qty = it-out-tquan..
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
*loop at it-out.
*write:/ it-out-auart,it-out-vkorg.
*endloop.
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
  EXPORTING
   SALESDOCUMENT                 = v_vbeln
    SALES_HEADER_IN               = header
    SALES_HEADER_INX              = headerx
  SENDER                        = SENDER
  BINARY_RELATIONSHIPTYPE       = 'VORL'
  INT_NUMBER_ASSIGNMENT         = ' '
IMPORTING
   SALESDOCUMENT_EX              = v_vbeln
TABLES
   RETURN                        = return
   SALES_ITEMS_IN                = item
   SALES_ITEMS_INX               = itemx
   SALES_PARTNERS                = partner.
  SALES_SCHEDULES_IN            = SALES_SCHEDULES_IN
  SALES_SCHEDULES_INX           = SALES_SCHEDULES_INX
  SALES_CONDITIONS_IN           = SALES_CONDITIONS_IN
  SALES_CFGS_REF                = SALES_CFGS_REF
  SALES_CFGS_INST               = SALES_CFGS_INST
  SALES_CFGS_PART_OF            = SALES_CFGS_PART_OF
  SALES_CFGS_VALUE              = SALES_CFGS_VALUE
  SALES_CFGS_BLOB               = SALES_CFGS_BLOB
  SALES_CCARD                   = SALES_CCARD
  KEY_TABLE                     = KEY_TABLE
endloop.
loop at return where type  = 'E' or type = 'A'.
exit.
endloop.
if sy-subrc = 0.
write:/ 'error in creating document'.
else.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
   WAIT          = 'X'
IMPORTING
  RETURN        = RETURN
commit work and wait.
write:/ 'document',v_vbeln,'created'.
endif.

Hi Patrick,
Here are a couple of issues/recommendations:
1) Checkboxes must be populated by capital X (your headerx-division = 'x' is wrong)
2) Why you are using the COMMIT WORK AND WAIT statement? The CALL BAPI_TRANSACTION_COMMIT does exactly the same! Comment it out or better delete one of them!
3) Does one of your sales order tables (VBAK, VBAP, ....) have any customer appended fields? In this case you have to populate an additional value table and the related index table as well.
Check it out,
Heinz

Similar Messages

  • A problem about create sales order with reference to contract.

    Hello,everyone,
    when I create sales order va01,there is user exit in MV45AFZB to check the vbkd-bstkd,unique and fixed  length.
    but there is no such in contract  creation va41.
    when I create a contract and copy the data to sales order ,the check code is prevent me from copying
    message error:the vbkd-bstkd check is wrong.
    how to solve the problem, if I have to use the check in sales order.

    The Simple thing may be put a check at contract stage it self, then whatever data is in contract will copy in sales order. So you wont face this problem.
    Thanks,
    Raja

  • Problem while creating Sale Order with Reference

    Hi Friends,
    While creating a Sale Order with Reference, I am unable to copy few fields from Profit Segement(CO - PA Data) in Account assignment Tab.
    Any solution how to copy all field values which are in Reference Sale Order Number.
    Regards,
    sg.

    Hi,
    Go to VOFM you will find out data transfer routine.
    Over here go for the order data transfer routine and select your data transfer routine which you use.
    Now check you field name and table name for that particular field which was not copying.
    It will be better if you ask your abaper for this.
    You have to make changes over here only for data transfer routine.
    Hope so this will help you out.
    Regards
    Raj.

  • Problem with BOM Quant while creating Sales order with reference using BAPI

    Dear All,
    I am facing problem with creating a slaes order with reference to other sales order by using BAPI_SALESORDER_CREATEFROMDAT2 .
    Sales order is getting created but
    1. It exploding the BOM means the line items which are not there in the reference SO also coming in the new SO ( all BOM items are coming )
    2. Schedule line for BOM header item is getting copied to all sub items of BOM.
    Can any one help me out to prevent the above deviations in creating Sales order with reference by using BAPI_SALESORDER_CREATEFROMDAT2.
    Note: while passing the parameters to BAPI_SALESORDER_CREATEFROMDAT2
    all the data related to items is exactly the same as in the original Sales Order.
    Thanks in advnace.
    Regards,
    John

    Hi All,
    Can any one help me !!!!!!!!!!
    please

  • Avoid substitute material.., while creating sales order with BAPI?

    Hi experts.
    I use BAPI_SALESDOCU_CREATEFROMDATA1 function module to create a sales order.
    Material A has a substitute material B with substitute reason 0005.
    So if I use material A when creating sales order with above BAPI function, the order is created with material B.
    I don't want to substitute the material automatically. I want to create the sales order with material A.
    What should I do? Help me please.
    Thanks in Advance.

    Hi bvrn Reddy,
    I know, your message is almost two years old, but, did you find a solution? I'm facing the same problem. The material A has B as substitute, but in va01 a popup appears (its customizing inside the substitution reason, strategy = A). Of course, we have no popup inside the bapi, but there must be a way to decide which material the bapi should use. At the moment I only get the substitute, never the old mat (even there is something in stock).
    Maybe you've got a helpful hint for me, thanks!
    Ben

  • Error while creating sales order with ref to contract

    while creating sales order, with refernce to contract system is giving a message
    Configuration not possible for material : Reason 3 --> Help
    Message no. V1360
    and the message is as follwed can any one explain
    Diagnosis
    This may have been caused by one of the following:
    1. The configuration profile for the material allows or requires the bill of materials to be exploded during order processing. However, a plant has not been specified in the item.
    2. The configuration profile of the material allows or requires the bill of materials to be exploded during order processing, but the order quantity in the item must be greater than 0.
    3. A configuration profile has not been maintained
    or
    A configuration is not permitted for the material
    or
    4. The configuration profile of the material allows or requires the bill ofmaterials to be exploded during order processing. However, the system could not determine a date because important data is missing from the item (see incompletion log).

    Hi
    I think you have both Variant configuration and BOM.
    Pls ensure the following.
    1. BOM masterdata is maintained for the variants
    2. Variant configuration is configured correctly
    Configuration profile is created for the material
    Knowledge base object and run time version are available
    3. Maintain materials as not relevant for delivery or dont give delivery quantity as 0
    Once you are sure that these are in proper shape, you can start creating order. The problem wont come.
    Reward points if it helps you.

  • Create Sales Order With Reference to Billing Document Using BAPI_SALESORDER

    Hi,
    How can i create a sales order With Reference to Billing Document Using BAPI_SALESORDER_CREATEFROMDAT2?
    Thanks in advance,
    Alejandro.

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

  • Problem in importing Sales Order with udf in the rows

    Dear All,
    I am having problem in importing Sales Order with udf in the rows. I mean it is getting imported but the udf values in the rows is not getting updated. But the udf values in the header is getting updated. I am using SAP 8.8 Pl 10.
    Can anyone guide me what to do in this scenario?
    Regards,
    Gary

    So , Login to DTW .
    with the Desired Database and Login Credentials.
    Goto - > Templates - > Customized Templates
    Select The Object .
    Right Click on the object needed and choose Create Template for the Structure .
    Then use this template for import .
    Hope it helps
    Thanks
    Ashish Ranjan

  • Error while creating sales order with ref using SD_SALESDOCUMENT_CREATE

    Hi
    I am creating sales order with reference using function module SD_SALESDOCUMENT_CREATE , while creating i am getting error
    Document doesn't have document category even thougth i am passing document category in header as well as item lavel.
    In VBUK table there is no value for VGTYP.
    Can you please help me how to resolve it.
    Thanks & regards
    kiran

    Problem resolved by passing   REFDOC_CAT in the FM along with  SD_DOC_CAT.
    Thanks

  • 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

  • Create sales order with reference to 10 quotation

    Create sales order with reference to 10 quotation I want to put all quotation means take reference in one sales order how I can do it because when tried va01 and taken reference of question it allow to put only one question number how can I do it for multiple question
    Ahmed

    Hi Raj,
    If you come back to initial screen after coping the first quotation ,then system will ask you whetehr to save or cancel the data,if we select save then it will be saved immediately,else it will cancel.So ,it is not possible to copy more than one quaotation in standard SAP.The only option is to deveop a BDC with the help of abaper.
    We can only create this when header data is same in all the quotations.
    Regards,
    Pasapula.
    Edited by: Pasapula on Jul 24, 2009 9:48 AM

  • Creating Sales Order with reference to Quotation from different Sales Area

    Hi,
    I would like to inform you that our customer (GE ENERGY OC) from Europe have a requirement where they want to create sales orders with reference to quotation that is from different sales area. Standard SAP functionality doesn't allow this feature, hence requesting your help to give me an update in this regard.
    Please treat this as urgent as they have to do business cutover where they are in the process of completing open sales orders.
    Thanks
    Ashfaq
    Mobile: +91-98857-07558
    E-Mail: [email protected]

    Hi RadhaKrishna,
    In standard system it is not possible to create sales order from a quotation whose sales are is different.
    However I think this is possible by using some user exit in sales order. I have never tried this.
    Regards
    srini

  • Create sales order with reference to contract

    Hi,
    I have to create sales orders with reference to a contract. When I do the recording on lsmw the line items in the sales order are assigned a number from sap. I need to keep the line item numbers the same as per the contract.
    Any advice appreciated.
    Regards,
    Warren.

    found answer

  • Create sales order with reference to archived billing

    Hello,
    Is it possible to create sales order with reference to archived billing?
    Thanks in advance and kind regards

    Hi,
      I think it is possible only return sales orders.
    regards
    karunakar

  • 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

Maybe you are looking for