Hi,
As Jarek mentined , pls check the material existency and then convert the material in to internal format , moreover pls check the mandatory parameters .
CALL FUNCTION 'CSAP_MAT_BOM_CREATE'
EXPORTING
material = material "2000000001
plant = plant "1001
bom_usage = '05'
valid_from = valid_from 'Date
i_stko = ls_stko "Structure of header
* FL_NO_CHANGE_DOC = ' '
* FL_COMMIT_AND_WAIT = ' '
* FL_CAD = ' '
fl_default_values = ' '
IMPORTING
fl_warning = fl_warning
bom_no = bom_no
TABLES
t_stpo = lt_stpo[]
* T_DEP_DATA =
* T_DEP_DESCR =
* T_DEP_ORDER =
* T_DEP_SOURCE =
* T_DEP_DOC =
* T_LTX_LINE =
* T_STPU =
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.
why can't you use the below function module :
* call function to create bill fo materail by using
* the previously declared local internal tables
DATA : lit_bomgroup TYPE STANDARD TABLE OF bapi1080_bgr_c,
wa_bomgroup TYPE bapi1080_bgr_c,
lv_bom_text TYPE string,
lv_plant TYPE ztbom_header-werks,
lit_variants TYPE STANDARD TABLE OF bapi1080_bom_c,
wa_variants TYPE bapi1080_bom_c,
lit_items TYPE STANDARD TABLE OF bapi1080_itm_c,
wa_items TYPE bapi1080_itm_c,
lit_matrel TYPE STANDARD TABLE OF bapi1080_mbm_c,
wa_matrel TYPE bapi1080_mbm_c,
lit_itemas TYPE STANDARD TABLE OF bapi1080_rel_itm_bom_c,
wa_itemas TYPE bapi1080_rel_itm_bom_c.
wa_bomgroup-bom_group_identification = 'BAPI_SMP_COL1'.
wa_bomgroup-object_type = 'BGR'.
wa_bomgroup-object_id = 'SIMPLE1'.
wa_bomgroup-bom_usage = wa_bom_h-stlan.
wa_bomgroup-created_in_plant = wa_bom_h-werks.
wa_bomgroup-ltxt_lang = sy-langu.
wa_bomgroup-technical_type = ' '.
wa_bomgroup-bom_text = lv_bom_text.
APPEND wa_bomgroup TO lit_bomgroup.
*-->Check BOM Existency
*-->Convert Material
wa_bom_h-datuv = sy-datum.
wa_bom_h-stlst = '01'.
*-->Convert UOM
*--Get Alt BOM based on Material and Plantand pass the next Alt BOM which we have to create
*-->Variants
wa_variants-bom_group_identification = 'BAPI_SMP_COL1'.
wa_variants-object_type = 'BOM'.
wa_variants-object_id = 'SIMPLE1'.
wa_variants-alternative_bom = wa_bom_h-stlal.
wa_variants-bom_status = wa_bom_h-stlst.
wa_variants-base_qty = wa_bom_h-bmeng.
wa_variants-base_unit = wa_bom_h-bmein. " base unit
wa_variants-alt_text = wa_bom_h-alternate_text. " alternative text
wa_variants-valid_from_date = wa_bom_h-datuv.
wa_variants-function = 'NEW'.
APPEND wa_variants TO lit_variants.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = wa_bom_h-bmein
IMPORTING
output = wa_bom_h-bmein
EXCEPTIONS
unit_not_found = 1
OTHERS = 2.
*--> Pass Items
SORT lit_items BY object_id valid_from_date.
CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
EXPORTING
all_error = 'X'
TABLES
bomgroup = lit_bomgroup
variants = lit_variants
items = lit_items
materialrelations = lit_matrel
itemassignments = lit_itemas
return = e_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.