CSAP_MAT_BOM_MAINTAIN question:
1. The exception is not necessarily e. For example, "ROL does not support decimal decimals" is a W, but it appears in the exception. The reason is that the error is raised elsewhere, and then the program continues to execute. The message returned is the last message that may be non-E. For example, when deleting a BOM component, it returns I 29 862 item & & & is deleted. This is not an error message, but if the header is modified at this time, an error E 29 282 will be reported when the header field can be modified. The header can only be displayed. The input is ignored, indicating that some fields cannot be modified and an error is raised, but the returned message is a message for deleting the project, and it will not be submitted in the end. Check the code at the head
2. "BOM header can only be displayed. Input is ignored", no bom is modified, if a new change number is passed in at this time, an error will be reported. 29 031
demo
form frm_bom_create
using
pv_matnr
pv_werks
pv_stlan
pv_stlal
pv_zjdbs "add by cuijunhu for lucky 20160811
pv_stktx
changing
pv_rc
pv_msg
.
data: o_stko type stko_api02.
data: lt_stpo type table of stpo_api02 with header line.
data: lt_item type table of stpo_api03 with header line.
data: stko like stko_api01.
date: datav (10),
stlalr type stalt, "optional BOM number for expansion
stlalm type stalt. "Optional BOM number for modification
perform cunit_output changing mara-meins.
stko-base_unit = mara-mine.
* stko-base_quan = '1'.
stko-bom_status = '01' .
stko-alt_text = pv_stktx .
stko-zjdbs = pv_zjdbs. "add by cuijunhu for lucky 20160811
* stko-bom_text = pv_stktx.
loop at it_upload into wa_upload
where matnr = pv_matnr
and werks = pv_werks.
clear:lt_item .
check wa_upload-idnrk is not initial.
perform matn1_input changing wa_upload-idnrk.
*check
select single * from marc
where matnr = wa_upload-idnrk and
werks = wa_upload-werks.
if sy-subrc <> 0.
shift wa_upload-idnrk left deleting leading '0'.
pv_msg ='Material' && wa_upload-idnrk &&'Not in the factory' && wa_upload-werks &&'Maintenance'.
pv_rc ='E'.
exit.
endif.
perform numcv_input changing wa_upload-posnr.
lt_item-item_no = wa_upload-posnr.
lt_item-item_categ = wa_upload-postp.
lt_item-component = wa_upload-idnrk.
lt_item-comp_qty = wa_upload-menge.
lt_item-comp_unit = wa_upload-meins.
lt_item-item_text1 = wa_upload-potx1.
lt_item-item_text2 = wa_upload-potx2.
lt_item-sortstring = wa_upload-sortf."add by cuijunhu for lucky 20160811
lt_item-rel_engin = ''. "Sign: Project-related items
lt_item-rel_cost ='X'. "Mark: items related to cost accounting
lt_item-rel_prod ='X'. "Mark: Production-related items
append lt_item.
endloop.
check pv_rc not 'E'.
write sy-datum to datuv.
call function 'CSAP_MAT_BOM_MAINTAIN'
exporting
material = pv_matnr
plant = pv_werks
bom_usage = pv_stlan
alternative = pv_stlal
valid_from = datuv
i_stko = stko
fl_bom_create = 'X'
fl_new_item = 'X'
fl_complete = 'X'
fl_commit_and_wait = 'X'
fl_default_values = 'X'
importing
o_stko = o_stko
tables
t_stpo = lt_item
exceptions
error_message = 1
error = 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 into pv_msg.
pv_rc ='E'.
else.
pv_rc ='S'.
endif.
endform. " FRM_BOM_CREATE