I am using BAPI_SALESORDER_CHANGE to copy a SO item to a new item. The new item is an exact copy of the previous one with small differences like the values in the item details configuration.
I am trying to fulfill the tables order_cfgs_ref, order_cfgs_inst and order_cfgs_value. But the execution of the BAPI is ending with a DUMP.
- Code: Select all
DATA: lv_posnr type posnr value '000010',
lv_posnr2 type posnr value '000020'.
CALL FUNCTION 'BAPI_SALESORDER_GETDETAILBOS'
EXPORTING
salesdocument = gv_vbeln " VBELN
TABLES
ordercfgscurefs = st_ordercfgscurefs
ordercfgscucfgs = st_ordercfgscucfgs
ordercfgscuins = st_ordercfgscuins
ordercfgscuprts = st_ordercfgscuprts
ordercfgscuvals = st_ordercfgscuvals
orderconditem = st_orderconditem.
READ TABLE st_ordercfgscurefs INTO ls_ordercfgscurefs WITH KEY posex = lv_posnr.
IF sy-subrc = 0.
CLEAR ls_order_cfgs_ref.
ls_order_cfgs_ref-posex = p_posnr_next_phase.
ls_order_cfgs_ref-config_id = ls_ordercfgscurefs-config_id.
CLEAR ls_ordercfgscucfgs.
READ TABLE st_ordercfgscucfgs INTO ls_ordercfgscucfgs WITH KEY posex = lv_posnr.
IF ls_ordercfgscucfgs-root_id IS NOT INITIAL.
ls_order_cfgs_ref-root_id = ls_ordercfgscurefs-inst_id.
ENDIF.
APPEND ls_order_cfgs_ref TO pt_order_cfgs_ref.
ENDIF.
ls_logic_switch-pricing = 'C'.
ls_order_header_inx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = gv_vbeln
order_header_in = ls_order_header_in
order_header_inx = ls_order_header_inx
logic_switch = ls_logic_switch
TABLES
return = lt_return
order_item_in = lt_order_item_in
order_item_inx = lt_order_item_inx
order_cfgs_ref = lt_order_cfgs_ref
order_cfgs_inst = lt_order_cfgs_inst
order_cfgs_value = lt_order_cfgs_value
.
It is ending by a dump:
ABAP programming error
MESSAGE_TYPE_X
CL_CBASE_SPECIAL_ERP==========CP
LO-VC
If I am copying the item without trying to copy the item detail configuration, the field CUOBJ of VBAP is not fulfilled. It is not possible to change the value of the configuration because no configuration is assign to the item.
When the field cuobj of the new item is assigned, I can copy/create all the configurations without any problem.
My question is, how can we assign a right value to the new item field VBAP-CUOBJ ?
Or, how can I copy the item detail configuration to the new item.
Regards