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: 

error BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

hi..........

error in uploading item details.

can you guide me how to upload item details using BAPI_SALESORDER_CREATEFROMDAT2 method........

thanks & regards

prabhakar

Edited by: Prabhakar on Mar 25, 2010 5:33 PM

4 REPLIES 4

Former Member
0 Kudos

search the forum.. you can find the sample pgm...

Former Member
0 Kudos

Try sending Schedule line data

Former Member
0 Kudos

Try this:

REPORT z_bapi_create_sales_order_test .

  • Order header:

  • - Order type: OR Important you must use the german code TA

  • - Sales org: 1000

  • - Distrb. chan.: 10

  • - Division: 00

*

  • - Sold to party: 1032

  • - Ship to party: 1032

  • - Purch order: DG-19970626-3

*

  • Order item:

  • - Material: P-100

  • - Qty: 1

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.

START-OF-SELECTION.

*----


  • Build partner information

*----


CLEAR l_order_partners.

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

l_order_partners-partn_numb = '0000001032'.

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 = 'TA'. "Remember German codes !

l_order_header_inx-doc_type = 'X'.

  • Sales organization

l_order_header_in-sales_org = '1000'.

l_order_header_inx-sales_org = 'X'.

  • Distribution channel

l_order_header_in-distr_chan = '10'.

l_order_header_inx-distr_chan = 'X'.

  • Division

l_order_header_in-division = '00'.

l_order_header_inx-division = 'X'.

  • Purchase order

l_order_header_in-purch_no_c = 'DG-19970626-300'.

l_order_header_inx-purch_no_c = 'X'.

*----


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

*----


l_order_items_in-itm_number = '10'.

l_order_items_inx-itm_number = '10'.

l_order_items_in-material = 'P-100'.

l_order_items_inx-material = 'X'.

l_order_items_in-comp_quant = '1.000'.

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

*----


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.

END-OF-SELECTION.

*----


  • Check and write Return table

*----


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.

*----


  • No errors - Commit

*----


IF l_errflag IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

0 Kudos

hi reddy ..........

can we upload data form flat file .............

if possible how to pass item details.........