Hi all,
I have created the product(material) with mandatory fields using of the below function modules.
COM_PRODUCT_MAT_MAINT_MULT_API, COM_PRODUCT_SAVE_API and BAPI_TRANSACTION_COMMIT.
Hereby i'm attaching my code snippet refer this.
DATA: it_product TYPE comt_product_mat_maintain_apit,
is_product TYPE comt_product_mat_maintain_api,
et_product TYPE comt_product_mat_maintain_apit,
et_bapireturn TYPE bapiret2_tab,
es_bapireturn TYPE bapiret2,
it_categories TYPE comt_prod_cat_rel_maintain_tab,
is_categories TYPE comt_prod_cat_rel_maintain,
it_shorttext TYPE comt_pr_shtext_maintain_tab,
is_shorttext TYPE comt_pr_shtext_maintain,
it_measure TYPE /1cn/working_set_i_d_crm_t,
is_measure TYPE /1cn/working_set_i_d_crm.
is_product-header-pr_number = '00001'. “ product header details
is_product-header-com_product-product_id = 'BA07'.
is_product-header-com_product-product_type = '01'.
is_product-header-com_product-logsys = 'CLNT930CI7'.
is_categories-data-category_id = 'MAT_EPA'.
is_categories-data-category_guid = 'DD9A8877C9746BF18A90001321F2A23C'.
is_categories-data-logsys = 'CLNT930CI7'.
APPEND is_categories TO it_categories. “ category details itab
is_measure-meins = 'PC'.
APPEND is_measure TO it_measure.
is_shorttext-data-short_text = 'Sample Product'.
is_shorttext-data-langu = 'EN'.
is_shorttext-data_x-short_text = 'X'.
is_shorttext-data-logsys = 'CLNT930CI7'.
is_shorttext-update_type = 'I'.
APPEND is_shorttext TO it_shorttext. “ description itab
is_product-header-categories = it_categories.
is_product-header-short_texts = it_shorttext.
is_product-conditions-cnd_crm_working_set = it_measure.
APPEND is_product TO it_product. “ full product details
CALL FUNCTION 'COM_PRODUCT_MAT_MAINT_MULT_API'
EXPORTING
it_product = it_product
* IV_CHECK_ONLY =
* IV_SUPPRESS_INACTIVE =
* IV_ACTIVATE_INACTIVE_PRODUCTS =
* IV_APPLICATION = ' '
iv_supress_rollback = 'X'
IMPORTING
et_product = et_product
et_bapireturn = et_bapireturn
EXCEPTIONS
internal_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 et_bapireturn INTO ls_bapireturn WITH KEY type = 'E'.
IF sy-subrc <> 0.
READ TABLE et_bapireturn INTO ls_bapireturn WITH KEY type = 'A'.
IF sy-subrc <> 0.
CALL FUNCTION 'COM_PRODUCT_SAVE_API'
EXPORTING
iv_update_task = 'X'
EXCEPTIONS
internal_error = 1
save_not_allowed = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
call FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDIF.
ENDIF.
Its working fine now.
Thank you for all ur suggestions.
Regards,
Swadini Sujanaranjan