2008 Mar 17 12:21 PM
Hi Experts ,
I am trying to change the quantity of the component in an existing BOM using the function module CSAP_MAT_BOM_MAINTAIN . But instead of changing the quantity of the component in the existing item , it is adding a new item with the changed quantity .
How to overcome this problem ..please help ...
Thanks.
2008 Mar 17 12:31 PM
Try using the FM CSAP_BOM_ITEM_MAINTAIN.
In the standard system, you need to use the following function modules to change a material BOM:
a. CSAP_MAT_BOM_OPEN
b. CSAP_BOM_ITEM_MAINTAIN
c. CSAP_MAT_BOM_CLOSE
For more information, check the below link.
[http://help.sap.com/saphelp_40b/helpdata/en/92/58b521417011d189ec0000e81ddfac/content.htm|http://help.sap.com/saphelp_40b/helpdata/en/92/58b521417011d189ec0000e81ddfac/content.htm]
Hope it helps.
Thanks,
Balaji
2008 Mar 17 12:31 PM
Try using the FM CSAP_BOM_ITEM_MAINTAIN.
In the standard system, you need to use the following function modules to change a material BOM:
a. CSAP_MAT_BOM_OPEN
b. CSAP_BOM_ITEM_MAINTAIN
c. CSAP_MAT_BOM_CLOSE
For more information, check the below link.
[http://help.sap.com/saphelp_40b/helpdata/en/92/58b521417011d189ec0000e81ddfac/content.htm|http://help.sap.com/saphelp_40b/helpdata/en/92/58b521417011d189ec0000e81ddfac/content.htm]
Hope it helps.
Thanks,
Balaji
2008 Mar 18 9:44 AM
Try the below code. It worked for me.
data: tstk1 type stko_api01.
*---- BOM header data structure
data: begin of tstk2.
include structure stko_api02.
data: end of tstk2.
*---- BOM items table
data: begin of tstp3 occurs 0.
include structure stpo_api03.
data: end of tstp3.
*---- Object dependencies table
* Basis data
data: begin of tdep2_data occurs 0.
include structure dep_data.
data: end of tdep2_data.
* Description
data: begin of tdep2_descr occurs 0.
include structure dep_descr.
data: end of tdep2_descr.
* Source
data: begin of tdep2_source occurs 0.
include structure dep_source.
data: end of tdep2_source.
* Sequence
data: begin of tdep2_order occurs 0.
include structure dep_order.
data: end of tdep2_order.
* Documentation
data: begin of tdep2_doc occurs 0.
include structure dep_doc.
data: end of tdep2_doc.
data: flg_warning like capiflag-flwarning.
*- Initialize database log
call function 'CALO_INIT_API'
exceptions
log_object_not_found = 1
log_sub_object_not_found = 2
other_error = 3
others = 4.
*- Fill item data
* Exception: items that can be identified uniquely via their item
* number
* 1. Item 0010: change quantity
clear tstp3.
tstp3-id_item_no = '0010'. "Item identification
tstp3-comp_qty = '5.000'.
append tstp3.
*- Change BOM
call function 'CSAP_MAT_BOM_MAINTAIN'
exporting
material = '000000000002126839'
plant = space
bom_usage = '1'
valid_from = '03/18/2008'
fl_bom_create = ' '
fl_new_item = ' '
i_stko = tstk1
importing
fl_warning = flg_warning
o_stko = tstk2
tables
t_stpo = tstp3
exceptions
others = 1.
Hope it helps. Reward points if helpful.
Thanks,
Balaji
2008 Mar 18 10:04 AM
Hi Balaji ,
Thanks for your reply .
Can u tell me where to see the Log of error message if the function module is not executed successfully .
In the Export Tab the parameter FL_WARNING gives the indication of error message . But actually where this error is logged , i am not able to find it out .
Please help .
Thanks ,
2008 Mar 18 10:10 AM
*- Initialize database log
call function 'CALO_INIT_API'
exceptions
log_object_not_found = 1
log_sub_object_not_found = 2
other_error = 3
others = 4.
The above piece of code initializes the DB log.
*- Change BOM
call function 'CSAP_MAT_BOM_MAINTAIN'
exporting
material = 'MAT100'
plant = '0001'
bom_usage = '1'
valid_from = '14.10.1996'
fl_bom_create = ' '
fl_new_item = ' '
i_stko = tstko
importing
fl_warning = flg_warning
o_stko = tstk2
tables
t_stpo = tstp3
exceptions
others = 1.
if sy-subrc eq 1.
*---- Error
* Please see log
endif.
if flg_warning eq 'X'.
*---- Please see log for information, warning messages, and success
* messages.
Endif.
So in case of error, see log for information, warning messages, and success messages.
Hope this helps.
Thanks,
Balaji.
2008 Mar 18 10:33 AM
Hi,
You may have to check with your Basis guys. But if you want to get the actual message yourself, comment out the below code.
*- Initialize database log
call function 'CALO_INIT_API'
exceptions
log_object_not_found = 1
log_sub_object_not_found = 2
other_error = 3
others
use the below code to see the message yourself on screen.
call function 'CSAP_MAT_BOM_MAINTAIN'
exporting
material = 'MAT100'
plant = '0001'
bom_usage = '1'
valid_from = '14.10.1996'
fl_bom_create = ' '
fl_new_item = ' '
i_stko = tstko
importing
fl_warning = flg_warning
o_stko = tstk2
tables
t_stpo = tstp3
exceptions
others = 1.
if sy-subrc eq 1.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if flg_warning eq 'X'.
*---- Please see log for information, warning messages, and success
* messages.
Endif.
Hope this helps. Reward points if helpful.
Thanks
Balaji
2008 Mar 18 10:20 AM
Ya , that's fine ....
But is there any transaction through which we can get this database log .
2016 Jul 07 11:03 AM
Hello,
You need to retrieve the GUIDX of the item number from the table STPO and then populate it in the T_STPO structure for the field ID_GUID of the module function.
For me it works. It updates the item line instead of creating a new one.
Plz try it.
To get the messages, you need to use the FM CALO_LOG_READ_MESSAGES.