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

Prob with Update BOM ?

Former Member
0 Likes
1,666

Hi ,

I'm working on BOM Update with the following BPAI's, while maintaining im getting error...,

Please check my sample code...

PARAMETERS : p_matnr  LIKE mara-matnr,

             p_plant  LIKE marc-werks,

             p_bomusg LIKE mast-stlan,

             p_altbom LIKE mast-stlal,

             p_idnrk TYPE stpo-idnrk,

             p_vald4m LIKE csap_mbom-datuv.

DATA:        l_stko    LIKE  stko_api02,

             l_warning TYPE  capiflag-flwarning,

             l_stpo    LIKE  TABLE OF   STPO_API02,

             e_stpo    LIKE STPO_API02,

             l_matnar  TYPE csap_mbom-matnr,

             l_msg     TYPE msg.

DATA : wa_stko TYPE stko_api02,

       wa_stpo TYPE stpo_api02.

CLEAR : l_stko, l_stpo.

REFRESH l_stpo.

l_matnar = p_matnr.

CALL FUNCTION 'CSAP_MAT_BOM_OPEN'

  EXPORTING

    material   = l_matnar

    plant      = p_plant

    bom_usage  = p_bomusg

    valid_from = p_vald4m

  IMPORTING

    o_stko     = l_stko

    fl_warning = l_warning

  TABLES

    t_stpo     = l_stpo

  EXCEPTIONS

    error      = 1.

IF sy-subrc <> 0.

  CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

      id     = sy-msgid

      lang   = sy-langu

      no     = sy-msgno

      v1     = sy-msgv1

      v2     = sy-msgv2

      v3     = sy-msgv3

      v4     = sy-msgv4

    IMPORTING

      msg    = l_msg

    EXCEPTIONS

      OTHERS = 0.

  IF sy-msgty = 'E'.

    WRITE : l_msg.

  ENDIF.

ENDIF.

LOOP AT l_stpo INTO wa_stpo.

wa_stpo-CHANGED_ON = sy-datum.

wa_stpo-CHANGED_BY = sy-uname.

wa_stpo-component = p_idnrk.

wa_stpo-comp_qty = '991111'.

wa_stpo-valid_to = '31.12.9999'.

wa_stpo-change_no = wa_stpo-change_no + 1.

  CALL FUNCTION 'CSAP_BOM_ITEM_MAINTAIN'

    EXPORTING

      i_stpo     = wa_stpo

    IMPORTING

      o_stpo     = wa_stpo

      fl_warning = l_warning

    EXCEPTIONS

      error      = 1

      OTHERS     = 2.

  IF sy-subrc <> 0.

  ENDIF.

  ENDLOOP.

*Close and COMMIT

  CALL FUNCTION 'CSAP_MAT_BOM_CLOSE'

    EXPORTING

      fl_commit_and_wait = 'X'

    IMPORTING

      fl_warning         = l_warning

    EXCEPTIONS

      error              = 1

      OTHERS             = 2.

  IF sy-subrc <> 0.

  ENDIF.

Please suggest me what is going wrong....,

Regards,

Lokesh.

6 REPLIES 6
Read only

paul_bakker2
Active Contributor
0 Likes
1,250

Um, you forgot to mention: what error message are you getting?

cheers

Paul Bakker

Read only

0 Likes
1,250

Hi,

Sorry for that.

Actually there is no error coming up. Instead, sy-subrc value turns 1 after execution of 'CSAP_BOM_ITEM_MAINTAIN'.

thanks ,

Lokesh.

Read only

former_member15255
Active Participant
0 Likes
1,250

Hello Lokeshwar,

This is just a suggestion why dont you try with this function module 'CSAP_MAT_BOM_MAINTAIN'

Regards

Suresh Nair

Read only

0 Likes
1,250

Hi suresh ,

I tried with this FM also it is inseting new item but its not updating...

Read only

0 Likes
1,250

Hello Lokeswar,

Please refer to the help documentation of function module for methods used for updating.

Please note:

  • The item to be changed can be identified in two ways:
  • via the fields item category, item number, sort string, and object (depending on the item category, this can be material, document data, or class data).
    The names of these identifying fields begin with 'ID_' and are contained in structure CSIDENT_02. Structure CSIDENT_02 is part of structure STPO_API03.
    You can use any combination of these fields to identify the item, provided the fields identify the item uniquely. Otherwise you see the error message 'Item cannot be identified uniquely'.
  • via the BOM node and BOM item counter
    These fields are only known to the system if you have read the BOM before. If you identify the item in this way, you should therefore use function modules CSAP_MAT_BOM_OPEN, CSAP_BOM_ITEM_MAINTAIN, or CSAP_MAT_BOM_CLOSE to change the BOM.
  • If the error message 'Item cannot be changed' appears in the log, this can be for the following reasons:
    - The item is not valid on the valid-from date - it becomes valid at a
      later date.
    - The item has already been changed on the same valid-from date
      with a different change number.
  • You cannot change the item category of an item that exists already in the system.
  • To delete an item, you must identify it as described above for the change function and set the deletion indicator.
  • FL_BOM_CREATE (default ' ')
    If you set this indicator to 'X', the system creates a new BOM if it cannot find the BOM you want to change and there is no other error.
    Items can only be created if sufficient data exists to do this.
    The system ignores items with a deletion indicator when creating a BOM.
  • FL_NEW_ITEM (default ' ')
    If you set this indicator to 'X', the system creates a new item if it cannot find the item with the identification entered.
    The system ignores items with a deletion indicator

Regards

Suresh Nair

Read only

Former Member
0 Likes
1,250

Check the same by entering valid from date in your code. Also check you are passing same structure in

EXPORTING

      i_stpo     = wa_stpo

    IMPORTING

      o_stpo     = wa_stpo

Regards,

Rahul