2016 Sep 23 3:07 PM
Hi!
I need create alternative of BOM via BAPI, I tried with CSAP_MAT_BOM_CREATE but it's only create the first BOM. If the BOM already exist the bapi don't create alternative.
Other BAPI that I tryed is CSAP_MAT_BOM_MAINTAIN, but it's only modify the list. (In the bapi I'm setting the value 'X' in parameters fl_new_item and fl_bom_create, but continue without to create alternative of BOM).
What is the correct use of CSAP_MAT_BOM_MAINTAIN?
Any idea or example of how create alternative of BOM via BAPI?
Thanks!
2016 Sep 23 7:05 PM
Hi Duvan,
Indeed, CSAP_MAT_BOM_CREATE documentation states that it can only create BOM Alternative 1.
However, there could be a possibility via the FM's hihlighted in the following, very interesting OSS Note
488765 - Do-it-yourself EWB programming
The note itself is describing the overall process in detail and has sample ABAP code attached.
As far as BOM header is concerned, it should be worth checking the FM's in the function group CSCL_BOM.
Function Module CS_CL_S_MAT_BOM_CREATE could be the one, I believe.
I do hope this could be of any help.
Thank you and regards,
Flavio
2016 Sep 26 7:23 AM
Dear Duvan Corrales,
I don't have any problem using CSAP_MAT_BOM_MAINTAIN for creating Alternative BOM.
Please try to populate data like below :
lx_stko1-base_quan
lx_stko1-base_unit
lx_stko1-bom_text
lx_stko1-alt_text
CLEAR lx_stpo3.
lx_stpo3-item_categ
lx_stpo3-item_no
lx_stpo3-component
lx_stpo3-item_node
lx_stpo3-item_count
lx_stpo3-comp_qty
lx_stpo3-comp_unit
lx_stpo3-item_text1
lx_stpo3-item_text2
lx_stpo3-rel_prod
lx_stpo3-valid_from
lx_stpo3-valid_to
lx_stpo3-created_on.
lx_stpo3-created_by
lx_stpo3-changed_on.
lx_stpo3-changed_by
lx_stpo3-bom_alt
APPEND lx_stpo3 TO lt_stpo3.
CALL FUNCTION 'CALO_INIT_API'
EXPORTING
* FLAG_DB_LOG_ON = 'X'
* FLAG_MSG_ON = 'X'
* FLAG_API_API_CALL_ON = 'X'
flag_collect_msg_on = 'X'
* external_log_no = ld_log_no
* DEL_LOG_AFTER_DAYS = '10'
* DATA_RESET_SIGN = '!'
EXCEPTIONS
log_object_not_found = 1
log_sub_object_not_found = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'
EXPORTING
material = ld_material
plant = ld_plant
bom_usage = ld_bom_usage
alternative = ld_alternative
valid_from = ld_valid_from
change_no = ld_change_no
* REVISION_LEVEL =
i_stko = lx_stko1
* FL_NO_CHANGE_DOC = ' '
fl_commit_and_wait = 'X'
* FL_CAD = ' '
fl_bom_create = 'X'
fl_new_item = 'X'
* FL_COMPLETE = ' '
* FL_DEFAULT_VALUES = 'X'
* FL_IDENTIFY_BY_GUID = ' '
* IMPORTING
* FL_WARNING =
* O_STKO =
TABLES
t_stpo = lt_stpo3
* T_DEP_DATA =
* T_DEP_DESCR =
* T_DEP_ORDER =
* T_DEP_SOURCE =
* T_DEP_DOC =
* T_DOC_LINK =
* T_DMU_TMX =
* T_LTX_LINE =
* T_STPU =
EXCEPTIONS
error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
fc_icon = c_red.
"now we have to care about the application log
CALL FUNCTION 'CALO_MSG_APPEND_DB_LOG'
EXCEPTIONS
log_object_not_found = 1
log_subobject_not_found = 2
log_internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
ELSE.
CALL FUNCTION 'CALO_LOG_READ_MESSAGES'
TABLES
messages_and_parameters = lt_messages
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
ELSE.
READ TABLE lt_messages INTO lx_messages
WITH KEY msg_type = 'A'.
IF sy-subrc <> 0.
READ TABLE lt_messages INTO lx_messages
WITH KEY msg_type = 'E'.
ENDIF.
IF sy-subrc = 0.
LOOP AT lt_messages INTO lx_messages WHERE msg_type = 'A' OR msg_type = 'E'.
MESSAGE ID lx_messages-msg_id TYPE lx_messages-msg_type NUMBER lx_messages-msg_no
WITH lx_messages-msg_v1 lx_messages-msg_v2
lx_messages-msg_v3 lx_messages-msg_v4 INTO ld_message .
IF fc_message IS INITIAL.
fc_message = ld_message.
ELSE.
CONCATENATE fc_message ld_message INTO fc_message SEPARATED BY ';'.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Regards,
Yance