Skip to Content
0
Former Member
Nov 20, 2013 at 12:22 AM

BAPI_SALESORDER_SIMULATE doesn't return data when used in my own FM

319 Views

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!