Application Development and Automation 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: 
Read only

bapi for sales order

Former Member
0 Likes
1,417

hi all ,

could any one give me the step by step procedure how to creat a sales order using bapi. i found BAPI_SALESORDER_CREATEFROMDAT2 this the bapi ... but iam not sure about the passing the parameters. please it would be help ful.

the fields which i have to upload are

order type - or

organisational data -1000 ,10 ,00.

sold to party - 1000

purchase oder number- 10

purchase order date - 31 03 2005

required dlivery date- 5 4 07

material - p-103

quantity 10

regards

reena

1 ACCEPTED SOLUTION
Read only

former_member404244
Active Contributor
0 Likes
1,380

Hi,

Short Text

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN

structure) and partner data (via the ORDER_PARTNERS table) as input

parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item

numbers manually, by filling in the relevant fields, or the system does

it, according to the settings for Customizing, by leaving the relevant

fields blank.

If you have configurable items, you must enter the configuration data in

the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and

ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one

hand, data for card identification, on the other, data for a transaction

which has taken place in an external system.

Once you have created the sales order successfully, you will receive the

document number (SALESDOCUMENT field). Any errors that may occur will be

announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the

system creates the sales area from the sold-to party or ship-to party,

who has been entered in the partner table. If a clear sales area cannot

be created, you will receive a system message, and the sales order will

not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the

relevant application must leave the commit, in order that can be

carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is

available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains

general information on the BAPIs in SD.

Plz chek the documentation in SE37 of this BAPI FM.

Regards,

Nagaraj

Hi,

Short Text

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN

structure) and partner data (via the ORDER_PARTNERS table) as input

parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item

numbers manually, by filling in the relevant fields, or the system does

it, according to the settings for Customizing, by leaving the relevant

fields blank.

If you have configurable items, you must enter the configuration data in

the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and

ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one

hand, data for card identification, on the other, data for a transaction

which has taken place in an external system.

Once you have created the sales order successfully, you will receive the

document number (SALESDOCUMENT field). Any errors that may occur will be

announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the

system creates the sales area from the sold-to party or ship-to party,

who has been entered in the partner table. If a clear sales area cannot

be created, you will receive a system message, and the sales order will

not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the

relevant application must leave the commit, in order that can be

carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is

available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains

general information on the BAPIs in SD.

Plz chek the documentation in SE37 of this BAPI FM.

Regards,

Nagaraj

8 REPLIES 8
Read only

former_member404244
Active Contributor
0 Likes
1,381

Hi,

Short Text

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN

structure) and partner data (via the ORDER_PARTNERS table) as input

parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item

numbers manually, by filling in the relevant fields, or the system does

it, according to the settings for Customizing, by leaving the relevant

fields blank.

If you have configurable items, you must enter the configuration data in

the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and

ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one

hand, data for card identification, on the other, data for a transaction

which has taken place in an external system.

Once you have created the sales order successfully, you will receive the

document number (SALESDOCUMENT field). Any errors that may occur will be

announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the

system creates the sales area from the sold-to party or ship-to party,

who has been entered in the partner table. If a clear sales area cannot

be created, you will receive a system message, and the sales order will

not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the

relevant application must leave the commit, in order that can be

carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is

available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains

general information on the BAPIs in SD.

Plz chek the documentation in SE37 of this BAPI FM.

Regards,

Nagaraj

Read only

0 Likes
1,380

hi Nagaraj,

thanx for the reply . can i get step by step procedure how to creat sales order.

it will be helpfull .

regards

reena

Read only

0 Likes
1,380

Hi,

Please check the code below:

DATA ok_code LIKE sy-ucomm.

DATA:

  • Order partners

li_order_partners TYPE STANDARD TABLE OF bapiparnr,

l_order_partners LIKE bapiparnr,

  • Structures for order header

l_order_header_in LIKE bapisdhd1,

l_order_header_inx LIKE bapisdhd1x,

  • Tables for order items

li_order_items_in TYPE STANDARD TABLE OF bapisditm,

l_order_items_in LIKE bapisditm,

li_order_items_inx TYPE STANDARD TABLE OF bapisditmx,

l_order_items_inx LIKE bapisditmx,

  • Return table from bapi call

li_return TYPE STANDARD TABLE OF bapiret2,

l_return TYPE bapiret2,

    • Sales document number

l_vbeln LIKE bapivbeln-vbeln,

  • Error flag

l_errflag(1) TYPE c.

DATA: BEGIN OF lt_itab OCCURS 0,

vbeln(10),

augru(3),

bstkd(10),

ean11(18),

END OF lt_itab.

*

START-OF-SELECTION.

CALL SCREEN 100.

*----


  • Build partner information

*----


CLEAR l_order_partners.

l_order_partners-partn_role = 'AG'. "Remember German codes !

l_order_partners-partn_numb = itab-st.

APPEND l_order_partners TO li_order_partners.

*

*----


  • Build order header

*----


    • Update flag

l_order_header_inx-updateflag = 'I'.

  • Sales document type

l_order_header_in-doc_type = 'YR30'.

l_order_header_inx-doc_type = 'X'.

  • customer reference

l_order_header_in-ord_reason = lt_itab-augru.

l_order_header_inx-ord_reason = 'X'.

  • Distribution channel

l_order_header_in-refdoctype = lt_itab-vbeln.

l_order_header_inx-doc_type = 'X'.

  • Purchase order

l_order_header_in-purch_no_c = lt_itab-bstkd.

l_order_header_inx-purch_no_c = 'X'.

*----


  • Build order item(s) - Only 1 is used in this example

*----


l_order_items_in-ean_upc = lt_itab-ean11.

l_order_items_inx-ean_upc = lt_itab-ean11.

l_order_items_in-material = itab-matnr.

l_order_items_inx-material = 'X'.

l_order_items_in-comp_quant = itab-qty.

l_order_items_inx-comp_quant = 'X'.

APPEND l_order_items_in TO li_order_items_in.

l_order_items_inx-updateflag = 'I'.

APPEND l_order_items_inx TO li_order_items_inx.

*----


  • CALL Bapi

*----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'CREATE'.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

order_header_in = l_order_header_in

order_header_inx = l_order_header_inx

testrun = 'X'

IMPORTING

salesdocument = l_vbeln

TABLES

return = li_return

order_items_in = li_order_items_in

order_items_inx = li_order_items_inx.

order_partners = li_order_partners.

PERFORM error.

  • WHEN 'EXIT'.

  • LEAVE PROGRAM.

  • ENDCASE.

*ENDMODULE. " USER_COMMAND_0100 INPUT

ENDFORM. " call_bapi

*----


  • Check and write Return table

*----


FORM error.

DATA: l_errflag(1) TYPE c,

  • Return table from bapi call

li_return TYPE STANDARD TABLE OF bapiret2,

l_return TYPE bapiret2.

LEAVE TO LIST-PROCESSING.

CLEAR l_errflag.

  • WRITE: / 'Sales dcoument: ', l_vbeln.

LOOP AT li_return INTO l_return.

WRITE: / l_return-type, l_return-message(50).

IF l_return-type = 'E'.

l_errflag = 'X'.

ENDIF.

ENDLOOP.

PERFORM commit.

ENDFORM. " ERROR INPUT

*----


  • No errors - Commit

*----


FORM commit.

DATA: l_errflag(1) TYPE c.

IF l_errflag IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

ENDFORM. " COMMIT INPUT

Regards

Kannaiah

Read only

0 Likes
1,380

hi kannaiah ,

thanx for your response . it was helpful. do u have any screen shots for creating sales oder creation step by step.

thanx

reena

Read only

0 Likes
1,380

Hi,

I am unable to understand what exactly you require ?

If you hardcode the values, then you can generate the sales order.

Test BAPI_SALESORDER_CREATEFROMDAT2 with the mandatory fields.

Give me ur email id, i will send the screen shots.

Regards

kannaiah

Read only

0 Likes
1,380

when i enter the test data directly inthe bapi.... its shows enter ship to party or sold to party inspite of me entering sold to party in the header ....

please help

reena

Read only

0 Likes
1,380

my email id is [email protected]

reena

Read only

0 Likes
1,380

Hi,

I have sent the email with screen shot document. Remove the update flag and try it.

Regards

kannaiah