Register Login

How to Handle Alternate BoM Creation Using Inbound Idoc?

Updated May 18, 2018

Hello Experts,

I have a requirement to create alternate BoM using Inbound IDoc 'Bommat03'. By default it creates Alternate BoM as '01'. Now if I try to create an Alternate BoM, say 'G1' for an already existing BoM using the IDoc, I get the error message as 'BoM already exists for the material'.

But I can manually create the Alternate BoM as 'G1' using Transaction CS01. If anyone has ever faced this kind of scenario or have any idea how to handle Alternate BoM creation using Inbound Idoc then please let me know asap.

Thanks for your help in advance.


Comments

  • 20 Nov 2015 3:44 pm rekha Helpful Answer

    Use below code for Alternate BOM with sub item .

    Part 1.

    DATA: bom_header LIKE cad_bicsk,
    bom_item type table of cad_bom_item WITH HEADER LINE,
    bom_sub_item type table of cssubitem WITH HEADER LINE,
    dms_class_data type table of cls_charac WITH HEADER LINE,
    sap_field_data type table of rfcdmsdata WITH HEADER LINE,
    e_return LIKE cad_return-value,
    e_message LIKE message-msgtx,
    e_message_len LIKE cad_return-message_len.
    DATA v_ITEM TYPE I.
    TYPES : BEGIN OF ty_data,
    level TYPE i,
    matnr TYPE cad_bicsk-matnr,
    werks TYPE werks_d,
    usage TYPE stlan,
    qty TYPE cad_bom_item-menge,
    fqty type fmeng, " Quantity is Fixed
    sub_upmng type upmng,
    text type cad_bicsk-ztext,
    END OF ty_data.

    DATA : it_data TYPE TABLE OF ty_data ,
    wa_data TYPE ty_data.

    *
    **---selection screen
    PARAMETERS:p_file TYPE ibipparms-path OBLIGATORY.
    *
    **---f4 help for the file from PC
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *
    PERFORM get_f4help.
    *
    *--start-of-selection .
    START-OF-SELECTION.
    *
    PERFORM upload_file_itab.

    CLEAR: bom_header, bom_item, bom_sub_item.
    REFRESH: bom_item, bom_sub_item.

    data : v_lineitem type SPOSN value '0000',
    v_slineitem type SPOSN value '0'.

    LOOP AT it_data INTO wa_data.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = wa_data-matnr
    IMPORTING
    output = wa_data-matnr.

    IF wa_data-level = 0.

    * fill BOM header
    clear bom_header.
    bom_header-matnr = wa_data-matnr. "'000000000200000016'.
    * bom_header-stlal = '1'. " Alternative Bom
    bom_header-werks = wa_data-werks. "'1000'.
    bom_header-stlan = wa_data-usage."'3'.
    bom_header-bmeng = wa_data-qty.
    bom_header-cadkz = 'X'.
    bom_header-stktx = wa_data-text.
    * bom_header-ztext = wa_data-text.
    bom_header-datuv = '01.10.2010'.

    ELSEIF wa_data-level = 1.
    * fill item
    v_lineitem = v_lineitem + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_lineitem
    IMPORTING
    output = v_lineitem.

    * bom_item-upskz = 'X'. " If We hav the Sub items Enable it.
    bom_item-idnrk = wa_data-matnr. "'000000000200000017'.
    bom_item-posnr = v_lineitem.
    bom_item-postp = 'L'.
    bom_item-menge = wa_data-qty. "'1'.
    bom_item-fmeng = wa_data-fqty.
    APPEND bom_item.
    CLEAR: bom_item.

    *** fill sub item
    CLEAR V_ITEM .
    v_slineitem = v_slineitem + 1.
    ELSEIF wa_data-level = 2.

    * V_ITEM = V_ITEM + 1.
    * bom_sub_item-posid = v_slineitem.
    * bom_sub_item-ebort = 'test'.
    * bom_sub_item-upmng = wa_data-sub_upmng.
    * bom_sub_item-uposz = V_ITEM.
    * bom_sub_item-uptxt = 'test'.
    * append bom_sub_item.
    * clear bom_sub_item.

    ENDIF.
    if wa_data-level = 0.

    else.
    at END OF LEVEL.
    * Call function
    CALL FUNCTION 'CAD_CREATE_BOM_WITH_SUB_ITEMS'
    EXPORTING
    i_bom_header = bom_header
    i_auto_posnr = ''
    IMPORTING
    e_return = e_return
    e_message = e_message
    e_message_len = e_message_len
    e_bom_header = bom_header
    TABLES
    bom_item = bom_item
    bom_sub_item = bom_sub_item
    dms_class_data = dms_class_data
    sap_field_data = sap_field_data
    EXCEPTIONS
    OTHERS = 1.
    refresh bom_item.
    write : e_message.
    ENDAT.

    ENDIF.
    CLEAR wa_data.
    endloop.
    **&---------------------------------------------------------------------*
    **& Form GET_F4HELP
    **&---------------------------------------------------------------------*
    FORM get_f4help .

    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.

    ENDFORM. " GET_F4HELP
    **&---------------------------------------------------------------------*
    **& Form UPLOAD_FILE_ITAB
    **&---------------------------------------------------------------------*
    FORM upload_file_itab .

    DATA:v_file TYPE string.
    MOVE p_file TO v_file.

    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = it_data
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    OTHERS = 17
    .
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    ENDFORM. " UPLOAD_FILE_ITAB

    When you people uploading the filat file use the Header Material as Level 0(zero) and All Components as level 1 (one).

    I hope this code may use.


×