Hi All,
I am creating sales order through BAPI SD_SALESDOCUMENT_CREATE. I have passed header, headerx, business object, item, itemx, schedule, schedulex and partner data. But the sales order is not getting created.
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
sales_header_in = wa_order_header_bapi
sales_header_inx = wa_order_headerx_bapi
business_object = l_business_object
IMPORTING
salesdocument_ex = l_vbeln
TABLES
return = it_return_bapi
sales_items_in = it_order_items_bapi
sales_items_inx = it_order_itemsx_bapi
sales_partners = it_order_partners_bapi
sales_schedules_in = it_order_schedule
sales_schedules_inx = it_order_schedulex.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = g_return.
Please find the below details for the tables and work areas which are being passed to function module
wa_order_header_bapi-doc_type = l_auart. "order type
wa_order_header_bapi-sales_org = l_vkorg. "sales organisation
wa_order_header_bapi-distr_chan = l_vtweg. "distribution channel
wa_order_header_bapi-division = l_spart. "division
wa_order_header_bapi-req_date_h = sy-datum. "required delivery date
wa_order_header_bapi-purch_no_c = l_bstnk. " purchase order number
wa_order_headerx_bapi-updateflag = 'I'.
wa_order_headerx_bapi-doc_type = 'X'. "order type
wa_order_headerx_bapi-sales_org = 'X'. "sales organisation
wa_order_headerx_bapi-distr_chan = 'X'. "distribution channel
wa_order_headerx_bapi-division = 'X'. "division
wa_order_headerx_bapi-req_date_h = 'X'. "required delivery date
wa_order_headerx_bapi-purch_no_c = 'X'. " purchase order number
it_order_items_bapi-itm_number = '000010'.
it_order_itemsx_bapi-itm_number = '000010'.
it_order_itemsx_bapi-updateflag = 'I'.
it_order_schedule-itm_number = '000010'.
it_order_schedule-sched_line = '0001'.
it_order_schedulex-itm_number = '000010'.
it_order_schedulex-sched_line = '0001'.
it_order_schedulex-updateflag = 'I'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_itab-matnr
IMPORTING
output = gt_itab-matnr.
it_order_items_bapi-material = gt_itab-matnr.
it_order_items_bapi-target_qty = gt_itab-kwmeng.
it_order_items_bapi-plant = gt_itab-werks.
it_order_items_bapi-batch = gt_itab-charg.
it_order_items_bapi-store_loc = gt_itab-lgort.
it_order_items_bapi-dlv_prio = gt_itab-lprio.
APPEND it_order_items_bapi.
CLEAR it_order_items_bapi.
it_order_itemsx_bapi-material = 'X'.
it_order_itemsx_bapi-target_qty = 'X'.
it_order_itemsx_bapi-plant = 'X'.
it_order_itemsx_bapi-batch = 'X'.
it_order_itemsx_bapi-store_loc = 'X'.
it_order_itemsx_bapi-dlv_prio = 'X'.
APPEND it_order_itemsx_bapi.
CLEAR it_order_itemsx_bapi.
it_order_schedule-req_date = gt_itab-vdatu.
it_order_schedule-dlv_date = gt_itab-vdatu.
it_order_schedule-req_qty = gt_itab-kwmeng.
APPEND it_order_schedule.
CLEAR it_order_schedule.
it_order_schedulex-req_date = 'X'.
it_order_schedulex-dlv_date = 'X'.
it_order_schedulex-req_qty = 'X'.
APPEND it_order_schedulex.
CLEAR it_order_schedulex.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_itab-sold_to
IMPORTING
output = gt_itab-sold_to.
it_order_partners_bapi-partn_role = 'SP'.
it_order_partners_bapi-partn_numb = gt_itab-sold_to.
APPEND it_order_partners_bapi.
CLEAR it_order_partners_bapi.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = gt_itab-ship_to
IMPORTING
output = gt_itab-ship_to.
it_order_partners_bapi-partn_role = 'WE'.
it_order_partners_bapi-partn_numb = gt_itab-ship_to.
APPEND it_order_partners_bapi.
CLEAR it_order_partners_bapi.
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
sales_header_in = wa_order_header_bapi
sales_header_inx = wa_order_headerx_bapi
business_object = l_business_object
behave_when_error = 'P'
IMPORTING
salesdocument_ex = l_vbeln
TABLES
return = it_return_bapi
sales_items_in = it_order_items_bapi
sales_items_inx = it_order_itemsx_bapi
sales_partners = it_order_partners_bapi
sales_schedules_in = it_order_schedule
sales_schedules_inx = it_order_schedulex.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = g_return.
In the return table I get the below error :-
SALES_HEADER_IN has been processed successfully
SALES_ITEM_IN has been processed successfully
has been saved
and salesorder document is coming as blank when I execute the function module.
But after commiting BAPi, when I go to VA02, i can see the sales order created.
What is the problem with function module, if the sales order is getting craeted then why it is not returing the sales order number. How to overcome this situation.
The function module is giving me the sales order number when I try to execute it with some test program with the same data that is being passed in the above code. Do I need to use some SAP note for the same?
Regards,
Ekta