2013 Jul 31 3:33 PM
Hi,
I use BAPI_SALESORDER_CREATEFROMDAT2 to create sales orders from external system.
It is working so far but I have problems transferring cost centers.
Normally the cost center in SAP ERP is derived from customizing assignment to order reason (vbak-augru).
In my case the cost center in VA01 is entered directly in the Account Assignment subscreen (order item field COBL-KOSTL).
Field KOSTL is not supported in the BAPI but I followed the instructions from the field documentation EXTENSIONIN of the BAPI and several threads in SCN about it.
I have extended BAPE_VBAP and BAPE_VBAPX accordingly. KOSTL is already available in VBAPKOM and VBAPKOMX.
When I run my program the sales order is created with all data but cost center is still missing.
What might be the reason?
Here is the essential part of the coding:
DATA: lt_extension TYPE TABLE OF bapiparex,
ls_extension TYPE bapiparex,
ls_bape_vbap TYPE bape_vbap,
ls_bape_vbapx TYPE bape_vbapx.
.
.
.
IF NOT ls_alv-kostl IS INITIAL.
ls_bape_vbap-posnr = ls_items-itm_number.
ls_bape_vbap-kostl = ls_alv-kostl.
ls_extension-structure = 'BAPE_VBAP'.
ls_extension+30 = ls_bape_vbap.
APPEND ls_extension TO lt_extension.
CLEAR ls_extension.
ls_bape_vbapx-posnr = ls_items-itm_number.
ls_bape_vbapx-kostl = abap_true.
ls_extension-structure = 'BAPE_VBAPX'.
ls_extension+30 = ls_bape_vbapx.
APPEND ls_extension TO lt_extension.
ENDIF.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = ls_header
IMPORTING
salesdocument = lv_order
TABLES
return = lt_return
order_items_in = lt_items
order_partners = lt_partner
order_schedules_in = lt_schedules
order_conditions_in = lt_conds
order_keys = lt_keys
extensionin = lt_extension.
Thanks in advance
Volker
2013 Jul 31 3:35 PM
Hi Volker,
Please check user exit USEREXIT_MOVE_FIELD_TO_COBL in Program MV45AFZB.
This is processed for dialog and bapi sales order creation/update.
Add this coding:
if ch_cobl-kostl is initial and not us_vbapkom-kostl is initial.
ch_cobl-kostl = us_vbapkom-kostl.
endif.
There might be other checks you have to do to distinguish between online and BAPI processing.
/Michael
Hi,
I use BAPI_SALESORDER_CREATEFROMDAT2 to create sales orders from external system.
It is working so far but I have problems transferring cost centers.
Normally the cost center in SAP ERP is derived from customizing assignment to order reason (vbak-augru).
In my case the cost center in VA01 is entered directly in the Account Assignment subscreen (order item field COBL-KOSTL).
Field KOSTL is not supported in the BAPI but I followed the instructions from the field documentation EXTENSIONIN of the BAPI and several threads in SCN about it.
I have extended BAPE_VBAP and BAPE_VBAPX accordingly. KOSTL is already available in VBAPKOM and VBAPKOMX.
When I run my program the sales order is created with all data but cost center is still missing.
What might be the reason?
Here is the essential part of the coding:
DATA: lt_extension TYPE TABLE OF bapiparex,
ls_extension TYPE bapiparex,
ls_bape_vbap TYPE bape_vbap,
ls_bape_vbapx TYPE bape_vbapx.
.
.
.
IF NOT ls_alv-kostl IS INITIAL.
ls_bape_vbap-posnr = ls_items-itm_number.
ls_bape_vbap-kostl = ls_alv-kostl.
ls_extension-structure = 'BAPE_VBAP'.
ls_extension+30 = ls_bape_vbap.
APPEND ls_extension TO lt_extension.
CLEAR ls_extension.
ls_bape_vbapx-posnr = ls_items-itm_number.
ls_bape_vbapx-kostl = abap_true.
ls_extension-structure = 'BAPE_VBAPX'.
ls_extension+30 = ls_bape_vbapx.
APPEND ls_extension TO lt_extension.
ENDIF.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = ls_header
IMPORTING
salesdocument = lv_order
TABLES
return = lt_return
order_items_in = lt_items
order_partners = lt_partner
order_schedules_in = lt_schedules
order_conditions_in = lt_conds
order_keys = lt_keys
extensionin = lt_extension.
Thanks in advance
Volker
2013 Jul 31 3:35 PM
Hi Volker,
Please check user exit USEREXIT_MOVE_FIELD_TO_COBL in Program MV45AFZB.
This is processed for dialog and bapi sales order creation/update.
Add this coding:
if ch_cobl-kostl is initial and not us_vbapkom-kostl is initial.
ch_cobl-kostl = us_vbapkom-kostl.
endif.
There might be other checks you have to do to distinguish between online and BAPI processing.
/Michael
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |