Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CREATEFROMDAT2 sales order not created

Former Member
0 Kudos

Hi All,

I am testing(se37) this bapi BAPI_SALESORDER_CREATEFROMDAT2 for sales order creation and its creating a sales order but when i check that sales order in VBAK table or VA03 its says sales order doesnt exist

I am providing header table,order line item ,order partner and order condition.

in return table this are the msg i am getting



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                   261 Van Sales - Domestic 11177115 has been saved (no delivery created)

4th message is a warning and i am not sure what does that mean.

regards

vivek

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you are testing it using SE37. Goto SE37 -> Function Module -> Test -> Test Sequences:

Enter the Function Module in the below order

1.BAPI_SALESORDER_CREATEFROMDAT2

2.BAPI_TRANSACTION_COMMIT

Execute the Function Module and SO will get saved.

Nit.

11 REPLIES 11

Former Member
0 Kudos

Hi,

As your trying to create order in se37, though it is created, but databse action is not committed in se37.

That's why it is not opning in VA03/VA02

Try this with program, then call FUNCTION 'BAPI_TRANSACTION_COMMIT.

Then ur order no. will be shown in VA02/VA03

Thanks & Regards,

Anagha Deshmukh

0 Kudos

After calling Bapi to create Sales order you need a call to BAPI_TRANSACTION_COMMIT your code, to save the SO in the database.

Former Member
0 Kudos

Hi,

If you are testing it using SE37. Goto SE37 -> Function Module -> Test -> Test Sequences:

Enter the Function Module in the below order

1.BAPI_SALESORDER_CREATEFROMDAT2

2.BAPI_TRANSACTION_COMMIT

Execute the Function Module and SO will get saved.

Nit.

Former Member
0 Kudos

See the follwoing example to create sales order this exampl i will give in two part

U CAN PASS Complete delivery = 'X'

PART - I

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.

Edited by: krupa jani on May 12, 2009 11:47 AM

Former Member
0 Kudos

PART-II

  • 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'.

Edited by: krupa jani on May 12, 2009 11:45 AM

Former Member
0 Kudos

Hi,

check with your functional consultant whether you are providing all the data required for creating the sales order

Former Member
0 Kudos

PART-III

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'.

*

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

  • 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.

Edited by: krupa jani on May 12, 2009 11:46 AM

former_member183990
Active Contributor
0 Kudos

hey after using this function module

use BAPI_TRANSACTION_COMMIT and no need to pass any parameters

it will work for sure

cheers

s.janagar

former_member188827
Active Contributor
0 Kudos

executing bapi in se37 only calls test enviornment.that is it will generate a new document number but in actual no document is created.that is it does not update database.call the bapi in your program.it 'll work

Former Member
0 Kudos

Hi,

In the initial screen of SE37 click on the Function Module Menu and choose the option Test. Under Test choose the option Test Sequences. A dialog box will appear. In the first line enter 'BAPI_SALESORDER_CREATEFROMDAT2' and in the 2nd 'BAPI_TRANSACTION_COMMIT' and execute. Now the rest of the steps are same as before.

Hope this resolves ur query.

Regards,

Nikhil Kayal

Former Member
0 Kudos

thx