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_SIMULATE doesn't return data when used in my own FM

Former Member
0 Kudos

I've written this code to get schedule line data from the BAPI_SALESORDER_SIMULATE. Normally this data is returned in the table ORDER_SCHEDULE_EX.

When I test the BAPI in SE37 it gives the expected result, but when I use it in my function module the table doesn't contain any data.

DATA:  doc_type TYPE AUART,

         req_qty TYPE WMENGC,

         partn_role TYPE PARVW,

         partn_numb TYPE KUNNR.

   DATA: itab_order_head_in type TABLE OF BAPISDHEAD,

         wa_order_head_in type BAPISDHEAD,

         itab_order_items_in TYPE TABLE OF BAPIITEMIN,

         wa_order_items_in TYPE BAPIITEMIN,

         itab_order_partners TYPE TABLE OF BAPIPARTNR,

         wa_order_partners TYPE BAPIPARTNR,

         itab_sched_ex TYPE STANDARD TABLE OF BAPISDHEDU,

         wa_sched_ex type BAPISDHEDU,

         wa_atp TYPE ZMOB_ATP,

         itab_incomp type TABLE OF BAPIINCOMP,

         wa_incomp TYPE BAPIINCOMP.

   doc_type = 'OR'.

   wa_order_head_in-doc_type = doc_type.

*  INSERT wa_order_head_in INTO TABLE itab_order_head_in.

   wa_order_items_in-material = P_MATNR.

   wa_order_items_in-plant = P_PLANT.

*  wa_order_items_in-store_loc = P_SLOC.

   req_qty = 999999.

   wa_order_items_in-req_qty = req_qty.

   wa_order_items_in-req_date = P_DATE.

   INSERT wa_order_items_in INTO TABLE itab_order_items_in.

   partn_role = 'SP'.

   wa_order_partners-partn_role = partn_role.

   partn_numb = 1.

   wa_order_partners-partn_numb = partn_numb.

   INSERT wa_order_partners INTO TABLE itab_order_partners.

   CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'

     EXPORTING

       ORDER_HEADER_IN     = wa_order_head_in

*     CONVERT_PARVW_AUART = ' '

*    IMPORTING

*     SALESDOCUMENT       =

*      SOLD_TO_PARTY       =

*     SHIP_TO_PARTY       =

*     BILLING_PARTY       =

*     RETURN              =

     TABLES

       ORDER_ITEMS_IN      = itab_order_items_in

       ORDER_PARTNERS      = itab_order_partners

*     ORDER_SCHEDULE_IN   =

*     ORDER_ITEMS_OUT     =

*     ORDER_CFGS_REF      =

*     ORDER_CFGS_INST     =

*     ORDER_CFGS_PART_OF  =

*     ORDER_CFGS_VALUE    =

*     ORDER_CFGS_BLOB     =

*     ORDER_CCARD         =

*     ORDER_CCARD_EX      =

       ORDER_SCHEDULE_EX   = itab_sched_ex

*     ORDER_CONDITION_EX  =

*      ORDER_INCOMPLETE    = itab_incomp

*     MESSAGETABLE        =

*     EXTENSIONIN         =

*     PARTNERADDRESSES    =

   LOOP AT itab_sched_ex INTO wa_sched_ex.

     wa_atp-matnr = P_MATNR.

     wa_atp-plant = P_PLANT.

*    wa_atp-store_loc = P_SLOC.

     wa_atp-req_qty = wa_sched_ex-req_qty.

     wa_atp-date1 = wa_sched_ex-req_date.

     wa_atp-confir_qty1 = wa_sched_ex-confir_qty.

   ENDLOOP.

ENDFUNCTION.

When I loop trough itab_sched_ex (which shoul contain the schedule line data), it's empty. As I said before, when testing BAPI_SALESORDER_SIMULATE it in se37 (with the same paramters), it works perfectly.

Does somebody have an idea? I would really appreciate your help.

Thanks!

1 ACCEPTED SOLUTION

custodio_deoliveira
Active Contributor
0 Kudos

Hi Adam,

No, I don't know what the problem is, but I suggest you add the RETURN in IMPORTING and the MESSAGETABLE in TABLES, so you can see any error that may be happening.

cheers,

Custodio

5 REPLIES 5

custodio_deoliveira
Active Contributor
0 Kudos

Hi Adam,

No, I don't know what the problem is, but I suggest you add the RETURN in IMPORTING and the MESSAGETABLE in TABLES, so you can see any error that may be happening.

cheers,

Custodio

0 Kudos

Hi Custodio

Thank you very much for the reply, it was very helpful!

I added the MESSAGETABLE, and it turned out that there was a problem with the doc_type (had to be 'TA' instead of 'OR'). I also had to convert the customer number to '0000000001'.

Now it finally works.

Thanks!

0 Kudos

I'm glad you find a solution. Not sure why you marked your answer as helpful. Maybe you should mark my and Akit's as helpful and yours as correct?

Cheers,

Custodio

Former Member
0 Kudos

Hi Adam,

Add the return parameter and debug to see the issue.

BR.

0 Kudos

Hi Ankit

Thank you for your reply.

It was the messagetable that showed me the issue. Now I've solved it.

KR