06-29-2022 7:30 AM
Hi everyone,
I work on a program about customer order's bom. This program add a new material in customer order's bom. System send a automatic message when i add a new material. I want to accept this message without user action. How can I reach and reply to this message in the background?
Used FM's;
CO_XT_COMPONENT_ADD and CO_XT_ORDER_PREPARE_COMMIT
This message pop's up when CO_XT_ORDER_PREPARE_COMMIT FM's run.
I need to chosee first button automaticly.
Part of my codes;
* BAPI to add components to Production Order
CALL FUNCTION 'CO_XT_COMPONENT_ADD'
EXPORTING
is_order_key = itab-aufnr
i_material = lv_material
is_requ_quan = ls_requ_quan
i_operation = lv_operation
i_sequence = lv_sequence
is_storage_location = ls_storage_location
is_storage_locationx = ls_storage_locationx
"i_batch = lv_batch
"i_batchx = lv_batchx
i_postp = lv_postp
i_posno = lv_positionno
IMPORTING
es_bapireturn = ls_return
e_error_occurred = lv_error.
IF lv_error = space.
CLEAR: lv_numc,
ls_return.
* Modify POSNR via ASSIGN before DB update to correct the blank
* item number in Components due to incompatible types of I_POSNO
* (type CIF_R3RES-POSITIONNO) and RESB-POSNR
ASSIGN ('(SAPLCOBC)RESB_BT[]') TO <ft_resb_bt>.
LOOP AT <ft_resb_bt> ASSIGNING <fs_resb_bt>.
lv_numc = sy-tabix * 10.
<fs_resb_bt>-posnr = lv_numc.
"<fs_resb_bt>-vornr = itab-vornr.
CLEAR lv_numc.
ENDLOOP.
* Commit transaction
CALL FUNCTION 'CO_XT_ORDER_PREPARE_COMMIT'
IMPORTING
es_bapireturn = ls_return
e_error_occurred = lv_error.
IF ( ls_return-type = 'S' OR
ls_return-type = 'W' OR
ls_return-type = 'I' ) OR
ls_return IS INITIAL.
* Commit data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CALL FUNCTION 'CO_XT_ORDER_INITIALIZE'.
ELSE.
CLEAR: lv_error,
ls_return.
* Data Rollback
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.