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

BOM Cretion error with BAPI : BAPI_MATERIAL_BOM_GROUP_CREATE

Former Member
0 Likes
1,139

Dear All,

Desc:

Here i am trying to create a BOM with differnet componants :

i am getting the below error while creating the BOM in varient alternative..

W BAPI1080 028

Error/warning when checking the structure of the BOM group with ID=BOMGROUP1

A BAPI1080 010

Variant/alternative 01 can only occur once with the function NEW

A BAPI1080 010

Variant/alternative 01 can only occur once with the function NEW

A BAPI1080 010

Variant/alternative 01 can only occur once with the function NEW

Please find the below code:

Code:

  • To get SC details

  • Get Plant details

SELECT * FROM y27d_dc_marc

INTO TABLE l_t_y27d_dc_marc

WHERE instnr = '552'. "instnr

IF sy-subrc = 0.

SORT l_t_y27d_dc_marc BY werks.

ENDIF.

IF l_t_y27d_dc_marc IS NOT INITIAL.

  • Get all Regions

SELECT * FROM y27d_dc_dt_plant

INTO TABLE l_t_y27d_dc_dt_plant

FOR ALL ENTRIES IN l_t_y27d_dc_marc

WHERE werks = l_t_y27d_dc_marc-werks.

ENDIF.

  • Read the SC Details

READ TABLE l_t_y27d_dc_dt_plant

INTO l_r_y27d_dc_dt_plant

WITH KEY werks_typ = g_c_sc. "SC

IF sy-subrc = 0.

  • Populate SC details

g_f_sc_plant = l_r_y27d_dc_dt_plant-werks.

ENDIF.

  • Material BoM Group Header Data

l_r_bomgroup-bom_group_identification = 'BOMGROUP1'.

l_r_bomgroup-object_type = 'BGR'.

l_r_bomgroup-object_id = 'BOMGROUP1'.

l_r_bomgroup-bom_usage = '1'. " YOU COULD CHANGE THE BOM USAGE TO YOUR needs

  • Plant assignment for the corresponding group

l_r_bomgroup-created_in_plant = g_f_sc_plant. "'0470'.

l_r_bomgroup-ltxt_lang = sy-langu.

l_r_bomgroup-technical_type = 'M'. " bomgroup-technical_type = wstzu-stlty.

l_r_bomgroup-bom_text = 'Test for BOM YSPR'.

APPEND l_r_bomgroup TO l_t_bomgroup.

CLEAR l_r_bomgroup.

DATA : l_f_var_alter TYPE stalt,

l_f_var_alter_cnt TYPE stalt.

  • Get BOM Item details

SELECT * FROM y27d_dc_bom

INTO TABLE l_t_bom_item

WHERE instnr = '552'.

IF sy-subrc = 0.

  • DESCRIBE TABLE l_t_bom_item LINES l_f_var_alter.

  • Populate item data

LOOP AT l_t_bom_item INTO l_r_bom_item.

  • Varient alternative for all the corresponding componants

l_f_var_alter = sy-tabix.

  • Details of the items of the variants

l_r_itemdata-bom_group_identification = 'BOMGROUP1'.

l_r_itemdata-object_type = 'ITM'.

l_r_itemdata-object_id = l_r_bom_item-bcomponant. "'MDTRAW2011'

l_r_itemdata-item_no = l_r_bom_item-bitemno."'0010'.

l_r_itemdata-item_cat = l_r_bom_item-bitemcat. "'L'.

l_r_itemdata-component = l_r_bom_item-bcomponant. "'MDTRAW2011'.

l_r_itemdata-comp_qty = l_r_bom_item-bquan."'2'.

l_r_itemdata-valid_from_date = sy-datum.

APPEND l_r_itemdata TO l_t_itemdata.

CLEAR l_r_itemdata.

  • Item componant assignment to a variant/alternative

l_r_variants-bom_group_identification = 'BOMGROUP1'.

l_r_variants-object_type = 'BOM'.

l_r_variants-object_id = l_r_bom_item-bcomponant. "'MDTRAW2011'. "'BOM1'.

l_r_variants-alternative_bom = '01'.

l_r_variants-bom_status = '01'.

l_r_variants-base_qty = '100'.

l_r_variants-valid_from_date = sy-datum.

l_r_variants-function = 'NEW'.

APPEND l_r_variants TO l_t_variants.

CLEAR l_r_variants.

  • Item componant assignment to linked items

  • Linking items to the corresponding variants

l_r_itemlink_to_var-bom_group_identification = 'BOMGROUP1'.

l_r_itemlink_to_var-sub_object_type = 'ITM'.

l_r_itemlink_to_var-sub_object_id = l_r_bom_item-bcomponant. "'MDTRAW2011'. "componant linked with varient

l_r_itemlink_to_var-super_object_type = 'BOM'.

l_r_itemlink_to_var-super_object_id = l_r_bom_item-bcomponant. "'MDTRAW2011'. "componant linked with varient

l_r_itemlink_to_var-valid_from_date = sy-datum.

l_r_itemlink_to_var-function = 'NEW'.

APPEND l_r_itemlink_to_var TO l_t_itemlink_to_var.

CLEAR l_r_itemlink_to_var.

ENDLOOP.

ENDIF.

  • Get the Header details

SELECT SINGLE * FROM y27d_dc_mara

INTO l_r_bom_head_mara

WHERE instnr = '552'. "instnr

IF sy-subrc = 0.

  • Populate header data

l_r_bom_head-bom_group_identification = 'BOMGROUP1'.

l_r_bom_head-material = l_r_bom_head_mara-matnr. "'MDT01022011'.

l_r_bom_head-plant = g_f_sc_plant. "'0470'.

l_r_bom_head-bom_usage = '1'. "'5'.

l_r_bom_head-alternative_bom = '01'.

APPEND l_r_bom_head TO l_t_bom_head.

CLEAR l_r_bom_head.

ENDIF.

  • Create BOM

CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'

EXPORTING

all_error = 'X'

TABLES

bomgroup = l_t_bomgroup "BOM group

variants = l_t_variants "Varients

items = l_t_itemdata "Item details

materialrelations = l_t_bom_head "Header details

itemassignments = l_t_itemlink_to_var "Item lineked to Varient

return = l_t_return.

LOOP AT l_t_return INTO l_r_return WHERE type CA 'AEX'.

l_f_error = 'X'.

ENDLOOP.

IF l_f_error = space.

  • Processing successful --> Commit work on PDM system

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

  • Error in processing --> Rollback work on PDM system

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ENDIF.

LOOP AT l_t_return INTO l_r_return.

WRITE:/ l_r_return-type, l_r_return-id, l_r_return-number,

l_r_return-message.

ENDLOOP.

could you please help me to come out of this problem.

1 REPLY 1
Read only

vinod_vemuru2
Active Contributor
0 Likes
790

Hi,

Did you try creating manually through CS01 with the same data? There could be a customization setting to restrict like this.

Thanks,

Vinod.