Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to use the Function module CSAI_BOM_MAINTAIN

Former Member
0 Likes
6,978

Hi Friends,

I want to use the FM CSAI_BOM_MAINTAIN to upload sub-items for a BOM. I also wanna make sure that the sub-items created/deleted for any line item, using this FM, must happen under the change number which i provide on the screen.

Pls help me with any test program or a code which u might have.

Thanks in advance..

Hozefa.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,958

hi there....

This function module is used to create/change BOM item for sales. But this FM is not released by SAP.

Due to which it gives problem while running but creates/changes the BOM.

Due to error, confirmation is required whether BOM is created or changed accordingly and so I have to use FM CSAI_BOM_READ for checking after using CSAI_BOM_MAINTAIN.

This is quite odd thing to do.

Try the FM CSAP_DOC_BOM_MAINTAIN.

CSAP_DOC_BOM_MAINTAIN

Functionality

Function module CSAP_DOC_BOM_MAINTAIN is used to process simple document structures.

This function module is primarily for changing structures, but can also be used to create structures.

If you only want to create structures, use function module CSAP_DOC_BOM_CREATE.

Restrictions:

1. You can currently process one variant only.

2. Changes to header data are not currently supported.

Please note:

There are two ways of identifying the item you want to change:

Enter the item category, item number, sort string, and object fields (depending on the item category, this can be material, document, or class data).

The field names of these fields start with ID_ and are in structure CSIDENT_02, which is part of structure STPO_API03.

You can select any fields to identify your item, but you must ensure that your entries identify one item only. Otherwise, you see an error message because no item can be found.

Enter the node and item counter.

These fields are only known if you have already read the structure.

You may see an error message in the log, telling you that the item cannot be changed. Either:

the item is not yet valid of the valid-from date

the item has been processed with another change number on the

valid-from date

You cannot change the item category of an existing item.

If you want to delete an item, identify the item in one of the ways described above and set the deletion indicator.

FL_BOM_CREATE (Default ' ')

If you set this indicator to 'X', a new document structure is created if the structure you want to change is not found and no other error occurs.

You can only add items if the data is available.

Items with a deletion indicator are ignored when you create a document structure.

FL_NEW_ITEM (Default ' ')

If you set this indicator to 'X', you create a new item if the item you enter is not found.

Items with a deletion indicator are ignored.

For sample code check the FM documentation.

Hope this helps.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 7, 2008 12:58 PM

Hi Friends,

I want to use the FM CSAI_BOM_MAINTAIN to upload sub-items for a BOM. I also wanna make sure that the sub-items created/deleted for any line item, using this FM, must happen under the change number which i provide on the screen.

Pls help me with any test program or a code which u might have.

Thanks in advance..

Hozefa.

7 REPLIES 7
Read only

Former Member
0 Likes
3,959

hi there....

This function module is used to create/change BOM item for sales. But this FM is not released by SAP.

Due to which it gives problem while running but creates/changes the BOM.

Due to error, confirmation is required whether BOM is created or changed accordingly and so I have to use FM CSAI_BOM_READ for checking after using CSAI_BOM_MAINTAIN.

This is quite odd thing to do.

Try the FM CSAP_DOC_BOM_MAINTAIN.

CSAP_DOC_BOM_MAINTAIN

Functionality

Function module CSAP_DOC_BOM_MAINTAIN is used to process simple document structures.

This function module is primarily for changing structures, but can also be used to create structures.

If you only want to create structures, use function module CSAP_DOC_BOM_CREATE.

Restrictions:

1. You can currently process one variant only.

2. Changes to header data are not currently supported.

Please note:

There are two ways of identifying the item you want to change:

Enter the item category, item number, sort string, and object fields (depending on the item category, this can be material, document, or class data).

The field names of these fields start with ID_ and are in structure CSIDENT_02, which is part of structure STPO_API03.

You can select any fields to identify your item, but you must ensure that your entries identify one item only. Otherwise, you see an error message because no item can be found.

Enter the node and item counter.

These fields are only known if you have already read the structure.

You may see an error message in the log, telling you that the item cannot be changed. Either:

the item is not yet valid of the valid-from date

the item has been processed with another change number on the

valid-from date

You cannot change the item category of an existing item.

If you want to delete an item, identify the item in one of the ways described above and set the deletion indicator.

FL_BOM_CREATE (Default ' ')

If you set this indicator to 'X', a new document structure is created if the structure you want to change is not found and no other error occurs.

You can only add items if the data is available.

Items with a deletion indicator are ignored when you create a document structure.

FL_NEW_ITEM (Default ' ')

If you set this indicator to 'X', you create a new item if the item you enter is not found.

Items with a deletion indicator are ignored.

For sample code check the FM documentation.

Hope this helps.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 7, 2008 12:58 PM

Read only

Former Member
0 Likes
3,958

Hi Prem,

Thank you so much for your response, but my problem is not to change the BOM items.

I want to insert and delete sub-items for a particular BOM line item using a change number ( which can be different from the change number in BOM header ).

I've tried almost all the function modules, but nothing seems to be helpful.

The FMs CAD_DISPLAY_BOM_WITH_SUB_ITEMS and CAD_CHANGE_BOM_WITH_SUB_ITEMS work absolutely fine, except for the change number thing.

For all changes that these two FMs do, the change number remains the same as in the BOM header and not the one that i want them to use.

Read only

Read only

0 Likes
3,958

No, i only have add-delete sub-items in existing BOMs... I dont have to create any BOMs.

Read only

Former Member
0 Likes
3,958

Hi Hozefa,

This sample code is to add new items to a Equipment BOM that already exits.

REPORT  z_csai_bom_maintain.

DATA: gs_csin TYPE csin,

       gs_stko TYPE stkob,

       gs_stzu TYPE stzub.

DATA: gt_stpo TYPE TABLE OF stpob,

       gt_stko TYPE TABLE OF stkob,

       gs_stpo TYPE stpob.

CONSTANTS: c_x      TYPE char01 VALUE 'X'.

PARAMETERS: pa_equnr TYPE equnr OBLIGATORY.

START-OF-SELECTION.

   gs_csin-stlty = 'E'.

   gs_csin-stlan = '4'.

   gs_csin-werks = 'C002'.

   gs_csin-equnr = pa_equnr.

   CALL FUNCTION 'CSAI_BOM_READ'

     EXPORTING

       ecsin              = gs_csin

* IMPORTING

*   FL_WARNING         =

    TABLES

      t_stpob            = gt_stpo

      t_stkob            = gt_stko

*   T_DEP_DATA         =

*   T_DEP_DESCR        =

*   T_DEP_ORDER        =

*   T_DEP_SOURCE       =

*   T_DEP_DOC          =

* EXCEPTIONS

*   ERROR              = 1

*   OTHERS             = 2

             .

   IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   READ TABLE gt_stko INTO gs_stko INDEX 1.

   gs_csin-trtyp = 'B'. "Update

   gs_csin-stlnr = gs_stko-stlnr.

   gs_csin-aennr = gs_stko-aennr.

   gs_csin-datuv = gs_stko-datuv.

****New Item.

   gs_stpo-stlty = 'M'.

   gs_stpo-postp = 'L'.

   gs_stpo-idnrk = '000000000040003006'.

   gs_stpo-menge = 7.

   gs_stpo-meins = 'ST'.

   gs_stpo-rvrel = c_x.

   APPEND gs_stpo TO gt_stpo.

   CALL FUNCTION 'CSAI_BOM_MAINTAIN'

     EXPORTING

*   FL_BOM_CREATE                      = ' '

*      fl_new_item                        = c_x

*      fl_complete                        = c_x

       ecsin                              = gs_csin

       estkob                             = gs_stko

       estzub                             = gs_stzu

*   FL_NO_CHANGE_DOC                   = ' '

*   FL_COMMIT_AND_WAIT                 = ' '

*   FL_NO_COMMIT_WORK                  = ' '

*   FL_ALE                             = ' '

*   FL_DEFAULT_VALUES                  = 'X'

*   FL_NEW_ROMEN                       = 'X'

*   FL_RECURSIVE                       = ' '

*   FL_IMPLICIT_SUBITEM_DELETION       =

* IMPORTING

*   FL_WARNING                         =

*   ASTKOB                             =

*   ASTZUB                             =

   TABLES

     t_stpob                            = gt_stpo

     et_stpob                           = gt_stpo

*   T_STPUB                            =

*   T_LTX_ITM                          =

*   T_LTX_BOM                          =

* EXCEPTIONS

*   ERROR                              = 1

*   OTHERS                             = 2

             .

   IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

Best Regards,

Sergio Calvo.

Read only

0 Likes
3,958

I am using this FM CSAI_BOM_MAINTAIN to update Material BOM.

It works fine most of the time. But I am facing a random sporadic issue where sometimes it does not add a new line item. The reason is unpredictable as If I use the same set of data again, it adds the new line item.

I have used the flag fl_new_item to solve this. But not sure if that would fix it. As it is random issue, not sure if that would work every single time.

My requirement is to add a new line item to a Material BOM or change an existing line item. I need to do it for Alternative BOM  1,2 ,3.... to 91. I did not find any other FM which will take care of the change number as well as Alternative BOM.

Request your suggestion.

This is bit urgent. Request you to reply as soon as possible.

Read only

george_guo2
Member
0 Likes
3,958

Here is the program I using to add equipment bom item and subitem.

gs_ecsin-datuv  = lv_date .

gs_ecsin-aennr  = 'E0001001608'.

gs_estzub-ztext = 'EBOM Create '.

gs_ecsin-stlnr  = gs_stko-stlnr.

gs_ecsin-trtyp = 'B'.

*Update STPo

lt_stpob-stlty = 'E'.

lt_stpob-idnrk = '30000-02'.

lt_stpob-postp = 'L'.

lt_stpob-meins = 'EA'.

lt_stpob-menge = '1.000'.

lt_stpob-datuv = lv_date.

append lt_stpob.

lt_stpub-pointer = '00000001'.

lt_stpub-stlty = 'E'.

lt_stpub-stlnr = gs_stko-stlnr.

lt_stpub-upmng = '1.000'.

lt_stpub-uposz = '0001'.

lt_stpub-ebort = '0945'.

lt_stpub-uptxt = '123456'.

lt_stpub-vbkz  = 'I'.

append lt_stpub.

call function 'CSAI_BOM_MAINTAIN'

exporting

*fl_bom_create                      = 'X'

*   FL_NEW_ITEM                        = ' '

*   FL_COMPLETE                        = ' '

ecsin                              = gs_ecsin

estkob                             = gs_stko

estzub                             = gs_estzub

*   FL_NO_CHANGE_DOC                   = ' '

fl_commit_and_wait                 = 'X'

*   FL_NO_COMMIT_WORK                  = ' '

*   FL_ALE                             = ' '

*   FL_DEFAULT_VALUES                  = 'X'

*   FL_NEW_ROMEN                       = 'X'

*   FL_RECURSIVE                       = ' '

*   FL_IMPLICIT_SUBITEM_DELETION       =

* IMPORTING

*   FL_WARNING                         =

*   ASTKOB                             =

*   ASTZUB                             =

tables

   t_stpob                            = lt_stpob

*   et_stpob                           = lt_stpob

   t_stpub                            = lt_stpub

*   T_LTX_ITM                          =

*   T_LTX_BOM                          =

exceptions

error                              = 1

others                             = 2

.

Regards,

George