‎2006 Dec 19 8:09 AM
Hi i am using Bapi to upload Bill of Material
the BOM is 'BAPI_MATERIAL_BOM_GROUP_CREATE'
i am using the follwing tables to populate into BOM
*itab_bomgrp, for BAPI1080_BGR_C
*itab_variants, for BAPI1080_BOM_C
*itab_items, for BAPI1080_ITM_C
*itab_matrel, for BAPI1080_MBM_C
*itab_itemassign, for BAPI1080_REL_ITM_BOM_C
*itab_subitemassignments, for BAPI1080_REL_SUI_ITM_C
*itab_ltext, for BAPI1080_TXT_C
*itab_return. for BAPIRET2
which are of same structures that are in the BAPI
after splitting the data from files into related internal tables
i populated the data into internal table in the following fashion
LOOP AT itab_stko INTO wa_stko.
CLEAR : wa_variants, wa_matrel, wa_bomgrp, wa_items, wa_ltext.
IF sy-tabix = 1.
ENDIF.
READ TABLE itab_stko1 INTO wa_stko1 WITH KEY stlnr = wa_mast-stlnr
stlal = wa_mast-stlal
BINARY SEARCH.
*IF the BOM already exists in the Target system
*If YES, transfer the data into other internal tables.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING wa_stko1 TO wa_stko2.
APPEND wa_stko2 TO itab_stko2.
If NO, pass the required data into corresponding BAPI Structures.
ELSE.
READ TABLE itab_mast INTO wa_mast WITH KEY stlnr = wa_stko-stlnr
stlal = wa_stko-stlal.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
*--Bom Group Table
wa_bomgrp-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_bomgrp-object_type = 'BGR'.
wa_bomgrp-object_id = wa_mast-stlnr.
wa_bomgrp-technical_type = ''.
wa_bomgrp-bom_usage = wa_mast-stlan.
wa_bomgrp-created_in_plant = wa_mast-werks.
wa_bomgrp-langu_iso = ' '.
READ TABLE itab_stzu INTO wa_stzu WITH KEY stlnr = wa_mast-stlnr.
IF sy-subrc EQ 0.
wa_bomgrp-bom_group = wa_stzu-exstl.
wa_bomgrp-auth_group = wa_stzu-stlbe.
wa_bomgrp-bom_text = wa_stzu-ztext.
ENDIF.
wa_bomgrp-ltxt_lang = wa_stko-ltxsp.
COLLECT wa_bomgrp INTO itab_bomgrp.
CLEAR wa_bomgrp.
**--Bom variants Table
wa_variants-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_variants-object_type = 'BOM'.
CONCATENATE 'VAR' wa_stko-stlnr wa_stko-stlal INTO wa_variants-object_id.
wa_variants-alternative_bom = wa_mast-stlal.
wa_variants-bom_status = wa_stko-stlst.
wa_variants-deletion_ind = wa_stko-loekz.
wa_variants-base_qty = wa_stko-bmeng.
MOVE wa_stko-bmeng TO wa_variants-base_qty.
wa_variants-base_unit = wa_stko-bmein.
wa_variants-base_unit_iso =''.
wa_variants-lab_design = wa_stko-labor.
wa_variants-ltxt_lang = wa_stko-ltxsp.
wa_variants-langu_iso = ''.
wa_variants-alt_text = wa_stko-stktx.
wa_variants-valid_from_date = wa_stko-datuv.
wa_variants-change_no = wa_stko-aennr.
wa_variants-function = 'NEW'.
*--Material relationship Table
wa_matrel-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_matrel-material = wa_mast-matnr.
wa_matrel-plant = wa_mast-werks.
wa_matrel-bom_usage = wa_mast-stlan.
wa_matrel-alternative_bom = wa_mast-stlal.
wa_matrel-lot_size_from = wa_mast-losvn.
wa_matrel-lot_size_to = wa_mast-losbs.
MOVE wa_mast-losvn TO wa_matrel-lot_size_from.
MOVE wa_mast-losbs TO wa_matrel-lot_size_to.
LOOP AT itab_stpo INTO wa_stpo WHERE stlnr = wa_stko-stlnr AND stlal = wa_stko-stlal.
wa_items-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_items-object_type = 'ITM'.
CONCATENATE 'ITM' wa_stpo-stlnr wa_stpo-stlal wa_stpo-stlkn INTO wa_items-object_id.
wa_items-item_id = wa_stpo-itmid.
wa_items-item_cat = wa_stpo-postp.
wa_items-res_item_cat = wa_stpo-potpr.
wa_items-sort_string = wa_stpo-sortf.
wa_items-component = wa_stpo-idnrk.
wa_items-document_type = wa_stpo-dokar.
wa_items-document_number = wa_stpo-doknr.
wa_items-document_version = wa_stpo-dokvr.
wa_items-document_part = wa_stpo-doktl.
wa_items-class_type = wa_stpo-klart.
wa_items-class_num = wa_stpo-class.
wa_items-reqd_comp = wa_stpo-clobk.
wa_items-sel_cond = wa_stpo-kzclb.
wa_items-multselect = wa_stpo-clmul.
wa_items-ltxt_lang = wa_stko-ltxsp.
* wa_items-langu_iso = sy-uzeit.
wa_items-item_text1 = wa_stpo-potx1.
wa_items-item_text2 = wa_stpo-potx2.
wa_items-comp_qty = wa_stpo-menge.
MOVE wa_stpo-menge TO wa_items-comp_qty.
wa_items-comp_unit = wa_stpo-meins. "'KG'.
wa_items-comp_unit_iso = ''.
wa_items-fixed_qty = wa_stpo-fmeng.
wa_items-vsi_no = wa_stpo-roanz.
wa_items-vsi_size1 = wa_stpo-roms1.
wa_items-vsi_size2 = wa_stpo-roms2.
wa_items-vsi_size3 = wa_stpo-roms3.
wa_items-vsi_size_unit = wa_stpo-romei.
wa_items-vsi_size_unit_iso = ''.
wa_items-vsi_qty = wa_stpo-romen.
wa_items-vsi_formula = wa_stpo-rform.
wa_items-comp_scrap = wa_stpo-ausch.
MOVE wa_stpo-ausch TO wa_items-comp_scrap.
wa_items-opr_scrap = wa_stpo-avoau.
wa_items-net_scrap_ind = wa_stpo-netau.
wa_items-spare_part = wa_stpo-erskz.
wa_items-mat_provision = wa_stpo-beikz.
wa_items-eng_rel = wa_stpo-sanko.
wa_items-prod_rel = wa_stpo-sanfe.
wa_items-pm_rel = wa_stpo-sanin.
wa_items-pm_assembly = wa_stpo-stkkz.
wa_items-cost_rel = wa_stpo-sanka.
wa_items-sales_rel = wa_stpo-rvrel.
wa_items-bulk_mat = wa_stpo-schgt.
wa_items-pur_group = wa_stpo-ekgrp.
wa_items-purch_org = wa_stpo-ekorg.
wa_items-delivery_days = wa_stpo-lifzt.
wa_items-vendor_no = wa_stpo-lifnr.
wa_items-gr_pr_time = wa_stpo-webaz.
wa_items-price = wa_stpo-preis.
wa_items-currency = wa_stpo-waers.
wa_items-currency_iso = ' '.
wa_items-price_unit = wa_stpo-peinh.
wa_items-rec_allowed = wa_stpo-rekrs.
wa_items-lead_time_offset = wa_stpo-nlfzt.
wa_items-distr_key_for_comp_consumption = wa_stpo-verti.
wa_items-purity = wa_stpo-csstr.
wa_items-co_product = wa_stpo-kzkup.
wa_items-iss_st_loc = wa_stpo-lgort.
wa_items-alt_item_strategy = wa_stpo-alpst.
wa_items-alt_item_prio = wa_stpo-alprf.
wa_items-alt_item_group = wa_stpo-alpgr.
wa_items-usage_prob = '5'.
wa_items-cost_element = wa_stpo-sakto.
wa_items-follow_up_group = wa_stpo-nfgrp.
wa_items-discon_group = wa_stpo-nfgrp.
wa_items-supplyarea = wa_stpo-prvbe.
wa_items-spproctype = wa_stpo-itsob.
wa_items-expl_type = wa_stpo-dspst.
wa_items-lead_time_offset_opr = wa_stpo-nlfzv.
wa_items-lead_time_offset_opr_unit = wa_stpo-nlfmv.
wa_items-lead_time_offset_opr_unit_iso = ''.
wa_items-ref_point = wa_stpo-rfpnt.
wa_items-valid_from_date = wa_stpo-datuv.
wa_items-change_no = wa_stpo-aennr.
wa_itemassign-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_itemassign-sub_object_type = 'ITM'.
wa_itemassign-sub_object_id = wa_items-object_id.
wa_itemassign-super_object_type = 'BOM'.
wa_itemassign-super_object_id = wa_variants-object_id.
wa_itemassign-valid_from_date = wa_stko-datuv.
wa_itemassign-change_no = wa_stpo-aennr.
wa_itemassign-function = 'NEW'.
APPEND wa_itemassign TO itab_itemassign.
APPEND wa_items TO itab_items.
CLEAR wa_items.
CLEAR wa_itemassign.
ENDLOOP.
APPEND wa_variants TO itab_variants.
APPEND wa_matrel TO itab_matrel.
*
READ TABLE itab_bom_mzu INTO wa_bom_mzu WITH KEY bom_group_identification = wa_variants-bom_group_identification.
IF sy-subrc = 0.
wa_ltext-bom_group_identification = wa_bom_mzu-bom_group_identification.
wa_ltext-object_type = wa_bom_mzu-object_type.
wa_ltext-object_id = wa_bom_mzu-object_id.
wa_ltext-format_col = wa_bom_mzu-format_col.
wa_ltext-text_line = wa_bom_mzu-text_line.
APPEND wa_ltext TO itab_ltext.
*
READ TABLE itab_bom_mko INTO wa_bom_mko WITH KEY bom_group_identification = wa_bom_mzu-bom_group_identification.
IF sy-subrc = 0.
wa_ltext-bom_group_identification = wa_bom_mko-bom_group_identification.
wa_ltext-object_type = wa_bom_mko-object_type.
wa_ltext-object_id = wa_bom_mko-object_id.
wa_ltext-format_col = wa_bom_mko-format_col.
wa_ltext-text_line = wa_bom_mko-text_line.
APPEND wa_ltext TO itab_ltext.
CLEAR wa_ltext.
*
READ TABLE itab_bom_mpo INTO wa_bom_mpo WITH KEY bom_group_identification = wa_bom_mko-bom_group_identification.
IF sy-subrc = 0.
wa_ltext-bom_group_identification = wa_bom_mpo-bom_group_identification.
wa_ltext-object_type = wa_bom_mpo-object_type.
wa_ltext-object_id = wa_bom_mpo-object_id.
wa_ltext-format_col = wa_bom_mpo-format_col.
wa_ltext-text_line = wa_bom_mpo-text_line.
APPEND wa_ltext TO itab_ltext.
CLEAR wa_ltext.
ENDIF.
ENDIF.
ENDIF.
*
wa_subitemassignments-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_subitemassignments-sub_object_type = 'ITM'.
wa_subitemassignments-sub_object_id = 'SIM'.
wa_subitemassignments-super_object_type = 'SUI'.
wa_subitemassignments-super_object_id = 'SIMP'.
APPEND wa_subitemassignments TO itab_subitemassignments.
*
**perform hard_code_test_data.
Perform for the Upadate Bapi
PERFORM update_bapi.
ENDIF.
ENDLOOP.
but i am not able to create BOM
can any one please help me in finding the solution
‎2006 Dec 19 12:13 PM
Hi Shankar
Tell me what error you are getting after this process.Think you know before using Binary search you have to sort the internal tables.You haven't done it in your program.Give me a docu for the exact error that you are getting.
Biju K sharma
‎2006 Dec 19 12:22 PM
Hi
the Error i am getting is
1. W type Error/Warning when checking BOM group
2 A Type Deviating from the BOM group
Even i sorted the ibternal table
‎2006 Dec 19 12:52 PM
Hi Sharma,
i am getting this error also
No instance of object type BOMGroup has been created. External reference: 4
Error/warning when checking the structure of the BOM group with ID=
Basic data for (BOM) group available twice
Error/warning when checking the structure of the BOM group with ID=
Basic data for (BOM) group available twice
‎2006 Dec 20 6:29 AM
Hi Shankar
Check your group identification number and conform whether it is valied or not. And Just give 'CREATE' instead of 'NEW'.And once more check all these parameters.Basic data must be availabe only once.So you have to put this piece of code outside of the given loop.
"LOOP AT itab_stko INTO wa_stko."
wa_itemassign-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_itemassign-sub_object_type = 'ITM'.
wa_itemassign-sub_object_id = wa_items-object_id.
wa_itemassign-super_object_type = 'BOM'.
wa_itemassign-super_object_id = wa_variants-object_id.
wa_itemassign-valid_from_date = wa_stko-datuv.
wa_itemassign-change_no = wa_stpo-aennr.
wa_itemassign-function = 'NEW'.
"No instance of object type BOMGroup has been created. External reference: 4"
This error is coming because u have given "NEW'..Try with 'CREATE'.
Just try this and reply still u have some error.
Biju K Sharma
‎2006 Dec 20 6:30 AM
Hi Shankar
Check your group identification number and conform whether it is valid or not. And Just give 'CREATE' instead of 'NEW'.And once more check all these parameters.Basic data must be availabe only once.So you have to put this piece of code outside of the given loop.
"LOOP AT itab_stko INTO wa_stko."
wa_itemassign-bom_group_identification = 'BOM_GROUP_ID_1'.
wa_itemassign-sub_object_type = 'ITM'.
wa_itemassign-sub_object_id = wa_items-object_id.
wa_itemassign-super_object_type = 'BOM'.
wa_itemassign-super_object_id = wa_variants-object_id.
wa_itemassign-valid_from_date = wa_stko-datuv.
wa_itemassign-change_no = wa_stpo-aennr.
wa_itemassign-function = 'NEW'.
"No instance of object type BOMGroup has been created. External reference: 4"
This error is coming because u have given "NEW'..Try with 'CREATE'.
Just try this and reply still u have some error.
Biju K Sharma