05-05-2011 2:21 PM
Hello,
I try to use the BAPi BAPI_SALESORDER_CREATEFROMDAT2 to make a order.
I execute it in SE80. I write some fields, that i thought necessary. When i execute, i have the result :
S - V4 - 233 - SALES_HEADER_IN has been processed successfully
S - V4 - 233 - SALES_ITEM_IN has been processed successfully
S - V4 - 233 - SALES_CONDITIONS_IN has been processed successfully
W - V1 - 555 - The sales document is not yet complete: Edit data
S - V1 - 311 - Order sales xxxx saved
But when i look at VA03, i don't find the order.
I suppose that one field fails. But which one ?! How can i have more explinations about which field fails ? After the "Sales_Condition", which one is created ? (Partner ? ...) How can i find the created order sale when it isn't completed ?
Thanks a lot for your help.
Dlfine.
05-05-2011 2:24 PM
Did you commit the changes with BAPI_TRANSACTION_COMMIT? Do you meant that you used the SE37 test workbench? If so, you need to use a test sequence, not just a single call...
05-05-2011 2:28 PM
Thx for your answer.
Yes, i made it. But in VA03, i have the message that the document doesn't exist or isn't archieved.
D.
05-05-2011 2:32 PM
The document would be there if you had committed it. Since you get the 'save' message, it should be there. However, you can check the INCOMPLETE_LOG table in the subsequent call to SD_SALESDOCUMENT_CREATE in debug - that will tell you which fields still need to be maintained (or simply check your header and item incompletion config for the field lists).
05-05-2011 2:59 PM
Sorry, but i never made that.
When i execute with debug, i look the table INCOMPLETE_LOG. But nothing is coming, and the execution was ended before i saw something in the table. How can i do ?
Thx.
D.
05-05-2011 3:41 PM
Hey,
I entered 2 new fields, and now i have
S - V4 - 233 - SALES_HEADER_IN has been processed successfully
S - V4 - 233 - SALES_ITEM_IN has been processed successfully
S - V4 - 233 - SALES_CONDITIONS_IN has been processed successfully
S - V1 - 311 - Order sales xxxx saved
But nothing in tx VA03 !! I look in tables also (VB*) and i find nothing about this order xxxx.
D.
Edited by: Delphine Bernard on May 5, 2011 4:42 PM
05-05-2011 4:09 PM
Hi,
Hope you are not putting the check mark in BAPI import parameter - "TESTRUN".
Also try putting value "I" in the BAPI import parameter ORDER_HEADER_INX-UPDATEFLAG.
Details are :
Controls processing functions with the value in the UPDATEFLAG field
(change indicator).
The following entries are available:
' ' : Create a new sales document
I: Create a new sales document
U: Change an existing sales document
D: Delete an existing sales document
Regards,
Harish
05-05-2011 6:11 PM
Also try putting value "I" in the BAPI import parameter ORDER_HEADER_INX-UPDATEFLAG.
That structure doesn't need to be specified/used at all to create a document.
@Poster: In the BAPI call, there is a call to the base SD document create function that I mentioned before. You need to 'Execute' over that call to get the result of the function and then check the table contents. You can also stop the BAPI in debug mode with a watchpoint on the incomplete message number or set a breakpoint anywhere the XVBUV table is available such as the 'save prepare' user exit or the 'check' user exits.
If you would post some code snippets it might help as well.
05-05-2011 7:53 PM
Judging by the messages alone, the order should have been saved successfully but it would be considered 'incomplete'. You should be able to view the order in VA03 and should be able to view what fields are incomplete (there is a menu).
It does look very much that the changes are not being committed, but you're saying that there is a COMMIT after BAPI. Did you check for update termination in SM13?
Otherwise this seems like a real mystery to me and may warrant a message to SAP.
05-12-2011 3:04 PM
Hi,
I made several tests. I try to check what happen in ST05 when i execute the bapi. It looks like the data are put in tables VDMOD and DBDATA. But after it isn't transfered into the real tables.
I made a test to an other bapi, and the save is correct except for the data in VDMOD and VBDATA.
Do we active something for the transfert from WDMOD/VDDATA to the real tables ?
Thanks a lot for your help.
DB
05-12-2011 3:24 PM
I guess the table name is VBMOD. Not sure how to explain it in a forum post, but, in a nutshell, I don't think this is an issue. It does look like COMMIT actually fails for some reason.
Try using COMMIT WORK AND WAIT and then check for sy-subrc.
Also check the user exits (MV45AFZZ and such), maybe there is something programmed incorrectly that is messing up with COMMIT.
05-12-2011 3:41 PM
Do you have partner data added? alright, whatever the reason may be... Here is working code for me based on my configuration. You may have different configuration and might required more info. Talk to your SD if you cannot find the required info or create a sales order online and write the required fields and add them to bapi... here is the code.
DATA *****
Export
data: wa_bapisdhd1 type bapisdhd1.
*import
data: wa_vbeln type bapivbeln-vbeln,
wa_bapisdhd type bapisdhd,
wa_bapisdhdst type bapisdhdst.
Tables
data: it_bapiret2 type table of bapiret2,
wa_bapiret2 like line of it_bapiret2,
it_bapisditm type table of bapisditm,
wa_bapisditm like line of it_bapisditm,
it_bapiparnr type table of bapiparnr,
wa_bapiparnr like line of it_bapiparnr,
it_bapischdl type table of bapischdl,
wa_bapischdl like line of it_bapischdl,
it_bapisdtext type table of bapisdtext,
wa_bapisdtext like line of it_bapisdtext,
it_bapiccard type table of bapiccard,
wa_bapiccard like line of it_bapiccard.
data: it_bapiret type table of bapiret2.
start-of-selection.
wa_bapisdhd1-doc_type = 'OR'. "Order type
wa_bapisdhd1-sales_org = 'S000'. " Sales org
wa_bapisdhd1-distr_chan = '00'. " Distribution channel
wa_bapisdhd1-division = '01'. "Division
wa_bapisdhd1-req_date_h = sy-datum. "Required date
wa_bapisdhd1-purch_date = sy-datum. " PO date
wa_bapisdhd1-name = 'testing'. "Customer name or contact name whatever in the sales order
wa_bapisdhd1-purch_no_c = '1223'. "PO number
wa_bapisdhd1-currency = 'USD'.
wa_bapisdhd1-ship_type = 'XX'. "Shipping type
clear: wa_bapisditm.
wa_bapisditm-itm_number = '000010'.
wa_bapisditm-po_itm_no = '10'.
wa_bapisditm-material = '000000000000000000'. "Add you material number
wa_bapisditm-plant = 'XXX'. "Plant
wa_bapisditm-sales_unit = 'EA'.
wa_bapisditm-target_qty = '1.000'.
wa_bapisditm-target_qu = 'EA'.
append wa_bapisditm to it_bapisditm.
clear: wa_bapiparnr.
wa_bapiparnr-partn_role = 'SP'.
wa_bapiparnr-partn_numb = '0001000000'. "Sold to party
append wa_bapiparnr to it_bapiparnr.
clear: wa_bapiparnr.
wa_bapiparnr-partn_role = 'SH'.
wa_bapiparnr-partn_numb = '0001000000'. "Ship to party
append wa_bapiparnr to it_bapiparnr.
clear: wa_bapischdl.
wa_bapischdl-itm_number = '000010'.
wa_bapischdl-sched_line = '0001'.
wa_bapischdl-req_date = sy-datum.
wa_bapischdl-req_qty = '1.000'.
append wa_bapischdl to it_bapischdl.
clear: wa_bapisdtext.
wa_bapisdtext-text_id = '0001'.
wa_bapisdtext-langu = sy-langu.
append wa_bapisdtext to it_bapisdtext.
clear: wa_bapisdtext.
wa_bapisdtext-text_id = '0001'.
wa_bapisdtext-langu = sy-langu.
append wa_bapisdtext to it_bapisdtext.
call function 'BAPI_SALESORDER_CREATEFROMDAT2'
exporting
order_header_in = wa_bapisdhd1
int_number_assignment = 'X'
behave_when_error = 'P'
convert = 'X'
testrun = 'X'
importing
salesdocument = wa_vbeln
tables
return = it_bapiret2
order_items_in = it_bapisditm
order_partners = it_bapiparnr
order_schedules_in = it_bapischdl
order_text = it_bapisdtext. .
" you can write your own - Write your own logic.
loop at it_bapiret2 into wa_bapiret2 where type = 'E'.
Exit.
endloop.
if sy-subrc <> 0.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
05-19-2011 4:12 PM
Hi,
Thanks for your help. I found the solution. I forgot to maintain the session between my BAPi and the BAPI of Commit. Now, i can see my order !
Have a nice day.
DB.