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

Problem with BAPI_SALESORDER_CREATEFROMDATA .....!

Former Member
0 Likes
1,548

when i am calling BAPI_SALESORDER_CREATEFROMDATA in programme

ORDER_HEADER_IN has been processed successfully           

ORDER_ITEMS_IN has been processed successfully

ORDER_PARTENRS_IN also successfully processed .         

But the SALESDOCUMNET is not getting created .

                                                            

what should i do to correct the error and to create sales order.

regards     ,

Suresh

Moderator message - Enough spoon-feeding has been done. Let the OP try something on his own.

Message was edited by: Suhas Saha

6 REPLIES 6
Read only

former_member201275
Active Contributor
0 Likes
1,323

This BAPI is no longer maintained.

Use one of the following BAPIs to create sales documents:

- BAPI_INQUIRY_CREATEFROMDATA Create sales inquiries

- BAPI_QUOTATION_CREATEFROMDATA Create quotation

- BAPI_SALESORDER_CREATEFROMDAT1 Create sales orders

Read only

atul_mohanty
Active Contributor
0 Likes
1,323

Hi

Use BAPI - BAPI_SALESORDER_CREATEFROMDAT2.

Here are some sample code,

     data: v_salesdocument like  bapivbeln-vbeln,
    ls_order_header_in    
type bapisdhd1 ,
       ls_order_header_inx   
type bapisdhd1x,
       lt_return       
type table of bapiret2   with header line,
       lt_items_in     
type table of bapisditm  with header line,
       lt_items_inx    
type table of bapisditmx with header line,
       lt_partners     
type table of bapiparnr  with header line,
       lt_schedules_in 
type table of bapischdl  with header line,
       lt_schedules_inx
type table of bapischdlx with header line,
       lt_order_conditions_in
type table of bapicond with header line,
       lt_order_conditions_inx
type table of bapicondx with header line,
 

              ls_order_header_in-doc_type   = 'Z001'.
        ls_order_header_in-sales_org  =
'1000'.
        ls_order_header_in-distr_chan =
'20'.
        ls_order_header_in-division   =
'01'.
        ls_order_header_in-sales_off  =
'0010'.
        ls_order_header_in-purch_no_c =
'10000001'.
        ls_order_header_inx-updateflag =
'I'.
        ls_order_header_inx-doc_type   =
'X'.
        ls_order_header_inx-sales_org  =
'X'.
        ls_order_header_inx-distr_chan =
'X'.
        ls_order_header_inx-division   =
'X'.
        ls_order_header_inx-sales_off  =
'X'.
       ls_order_header_inx-purch_no_c =
'X'.

                lt_partners-partn_role = 'AG'.
         lt_partners-partn_numb =
'0000004000'.
       
append lt_partners.  

                lt_items_in-itm_number  = '000010'.
         lt_items_in-material    =
'000000000300000040'.
         lt_items_in-sales_unit  =
'ST'.
      
append lt_items_in.

                lt_items_inx-itm_number  = '000010'.
         lt_items_inx-material    =
'X'.
         lt_items_inx-sales_unit  =
'X'.
       
append lt_items_inx.

               lt_schedules_in-itm_number  = '000010'.
       lt_schedules_in-sched_line  =
'0001'.
       lt_schedules_in-req_qty     =
1000.
       lt_schedules_in-req_date    = sy-datum.
      
append lt_schedules_in.

      lt_schedules_inx-itm_number  =
'000010'.
      lt_schedules_inx-sched_line  =
'0001'.
      lt_schedules_inx-req_qty     =
'X'.
      lt_schedules_inx-req_date     =
'X'.
     
append lt_schedules_inx.

     call function 'BAPI_SALESORDER_CREATEFROMDAT2'
 
exporting

          order_header_in               = ls_order_header_in
    order_header_inx              = ls_order_header_inx

importing
   salesdocument                  = v_salesdocument
 
tables
  
return                         = lt_return
   order_items_in                 = lt_items_in
   order_items_inx                = lt_items_inx
    order_partners                = lt_partners
   order_schedules_in            = lt_schedules_in
   order_schedules_inx           = lt_schedules_inx
   order_conditions_in           = lt_order_conditions_in
   order_conditions_inx          = lt_order_conditions_inx

Call function 'BAPI_TRANSACTION_COMMIT'
  
exporting
    
wait          = 'X'.

Read only

0 Likes
1,323

Thanks For reply,

but when i am executing that BAPI in SE37 , the sales documnet is getting created. That means it has to be work in the programe also na?

please suggest with best one,bcz my Functional consultant is telling to work withBAPI_SALESORDER_CREATEFROMDATA to upload the DEBIT MEMO.

Regards,

Suresh

Read only

0 Likes
1,323

In SE37, execute the function module in sequence.

SE37 - Menu

Function modules -> Execute -> Test Sequences

1. BAPI_SALESORDER_CREATEFROMDAT2

2. BAPI_TRANSACTION_COMMIT

In SE38, Program

call FM 'BAPI_TRANSACTION_COMMIT' if there is no error in return internal table (example - lt_return in the above case)

Read only

jitendra_it
Active Contributor
0 Likes
1,323

Hello Suresh,

Please call BAPI_TRANSACTION_COMMIT after the sales order BAPI else results will not reflect in db.

Read only

0 Likes
1,323

I have used it . Please check the sample code.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDATA'

       EXPORTING

         ORDER_HEADER_IN = ORDER_HEADER_IN

*       ORDER_HEADER_INX = ORDER_HEADER_INX

       IMPORTING

         SALESDOCUMENT   = SALESDOCUMENT

*       SOLD_TO_PARTY   =

*       SHIP_TO_PARTY   =

*       BILLING_PARTY   =

*        RETURN          = RETURN

       TABLES

         ORDER_ITEMS_IN  = ORDER_ITEMS_IN

*       ORDER_ITEMS_INX = ORDER_ITEMS_INX

         ORDER_PARTNERS  = ORDER_PARTNERS

*       ORDER_ITEMS_OUT =

*       ORDER_CFGS_REF  =

*       ORDER_CFGS_INST =

*       ORDER_CFGS_PART_OF       =

*       ORDER_CFGS_VALUE         =

*       ORDER_CFGS_BLOB =

*       ORDER_CCARD     =



IF SALESDOCUMENT <> SPACE.

       DATA: LV_MSG(60).

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

      EXPORTING

          WAIT = 'X'.

Regards,

Suresh