multilevel bom explosion with all alternative

11
Generated by Jive on 2014-07-15+02:00 1 Multilevel BOM Explosion With all alternative BOMs like CS03 Hi friends,  This program demonstrate Multilevel BOM Explosion With all alternative BOMs like CS03 T-code.  In CS12 we can explode the Multilevel BOM for only one alternate BOMs .There is no standard program for Multilevel BOM Explosion With all alternative BOMs in each level by level.This customized program will give you the output but it will take long time to execute for the material having more number of alternative BOMs.  REPORT ZPP_BOM11. TYPES : begin of ty_tab,  matnr TYPE mara-matnr,  werks TYPE mast-werks,  stlaN TYPE mast-stlaN,  stlnr TYPE mast-stlnr,  stlal TYPE mast-stlal,  end of ty_tab. data: it_tab TYPE STANDARD TABLE OF ty_tab,  wa_tab TYPE ty_tab. TYPES : begin of ty_STB.  INCLUDE STRUCTURE STPOX.  TYPES: END OF TY_STB.  DATA : IT_STB TYPE STANDARD TABLE OF TY_STB,  WA_STB TYPE TY_STB,  fs_stb TYPE TY_STB. TYPES : begin of ty_STB1,

Upload: sapgak

Post on 12-Oct-2015

15 views

Category:

Documents


1 download

DESCRIPTION

BOM

TRANSCRIPT

  • Generated by Jive on 2014-07-15+02:001

    Multilevel BOM Explosion With all alternativeBOMs like CS03

    Hi friends,

    This program demonstrate Multilevel BOM Explosion With all alternative BOMs like CS03 T-code. In CS12 we can explode the Multilevel BOM for only one alternate BOMs .There is no standard program forMultilevel BOM Explosion With all alternative BOMs in each level by level.This customized program will giveyou the output but it will take long time to execute for the material having more number of alternative BOMs.

    REPORT ZPP_BOM11.

    TYPES : begin of ty_tab,

    matnr TYPE mara-matnr,

    werks TYPE mast-werks,

    stlaN TYPE mast-stlaN,

    stlnr TYPE mast-stlnr,

    stlal TYPE mast-stlal,

    end of ty_tab.

    data: it_tab TYPE STANDARD TABLE OF ty_tab,

    wa_tab TYPE ty_tab.

    TYPES : begin of ty_STB.

    INCLUDE STRUCTURE STPOX.

    TYPES: END OF TY_STB.

    DATA : IT_STB TYPE STANDARD TABLE OF TY_STB,

    WA_STB TYPE TY_STB,

    fs_stb TYPE TY_STB.

    TYPES : begin of ty_STB1,

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:002

    matnr TYPE mara-matnr,

    ojtxb TYPE ojtxp, mtart TYPE mtart,

    mnglg TYPE cs_e_mnglg,

    meins TYPE meins,

    idnrk TYPE matnr,

    ojtxp TYPE ojtxp, END OF TY_STB1.

    DATA : IT_STB1 TYPE STANDARD TABLE OF TY_STB1,

    WA_STB1 TYPE TY_STB1,

    fs_stb1 TYPE ty_stb1.

    types: begin of ty_final,

    matnr TYPE mara-matnr,

    ojtxb TYPE ojtxp, mtart TYPE mtart,

    mnglg TYPE cs_e_mnglg,

    meins TYPE meins,

    idnrk TYPE matnr,

    ojtxp TYPE ojtxp, end of ty_final.

    data : it_final TYPE STANDARD TABLE OF ty_final,

    wa_final TYPE ty_final.

    TYPE-POOLS: slis.

    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    gd_repid LIKE sy-repid.

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:003

    * *Screen elements................................

    selection-screen begin of block b1 with frame title text-001.

    parameters:

    p_matnr type mast-matnr default '' obligatory," Material Number

    p_werks type mast-werks default 'wtch' obligatory, " Plant

    p_stlan type mast-stlan default '1' obligatory, " Alternative BOM

    p_capid type rc29l-capid default 'BEST' obligatory. " Application

    selection-screen end of block b1.

    START-OF-SELECTION.

    perform bom_header.

    perform Bom_child.

    PERFORM Build_catalog.

    perform display_output.

    *&---------------------------------------------------------------------*

    *& Form BOM_HEADER

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    *

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:004

    stlAn = p_stlAn.

    clear wa_tab.

    loop at it_tab INTO wa_tab.

    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

    EXPORTING

    CAPID = 'PP01'

    DATUV = SY-DATUM

    MKTLS = 'X'

    MTNRV = wa_tab-matnr

    STLAL = wa_tab-stlal

    STLAN = wa_tab-stlan

    STPST = 0

    SVWVO = 'X'

    WERKS = WA_TAB-WERKS

    TABLES

    STB = IT_STB

    * MATCAT = IT_matcat

    EXCEPTIONS

    ALT_NOT_FOUND = 1

    CALL_INVALID = 2

    MATERIAL_NOT_FOUND = 3

    MISSING_AUTHORIZATION = 4

    NO_BOM_FOUND = 5

    NO_PLANT_DATA = 6

    NO_SUITABLE_BOM_FOUND = 7

    CONVERSION_ERROR = 8

    OTHERS = 9

    .

    IF SY-SUBRC 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:005

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    clear: wa_stb1 , wa_stb.

    loop at it_stb INTO wa_stb.

    wa_stb1-matnr = wa_tab-matnr.

    wa_stb1-ojtxb = WA_STB-OJTXB. wa_stb1-mtart = wa_stb-mtart.

    wa_stb1-mnglg = wa_stb-mnglg.

    wa_stb1-meins = wa_stb-meins.

    wa_stb1-idnrk = wa_stb-idnrk.

    wa_stb1-ojtxp = wa_stb-ojtxp. APPEND wa_stb1 to it_stb1.

    ENDLOOP.

    ENDLOOP.

    ENDFORM. " BOM_HEADER

    *&---------------------------------------------------------------------*

    *& Form BOM_CHILD

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    *

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:006

    if IT_STB1 is not initial.

    loop at IT_STB1 into fs_stb1.

    if sy-subrc = 0.

    wa_final-matnr = fs_stb1-matnr.

    wa_final-ojtxb = FS_STB1-OJTXB. wa_final-mtart = fs_stb1-mtart.

    wa_final-mnglg = fs_stb1-mnglg.

    wa_final-meins = fs_stb1-meins.

    wa_final-idnrk = fs_stb1-idnrk.

    wa_final-ojtxp = fs_stb1-ojtxp. append wa_final to it_final.

    ENDIF.

    endloop.

    ENDIF.

    clear wa_final.

    loop at it_final INTO wa_final.

    PERFORM RECURSIVE_BOM .

    endloop.

    ENDFORM. " BOM_CHILD

    FORM RECURSIVE_BOM .

    CLEAR : it_tab, IT_STB , IT_STB1.

    clear : fs_stb,fs_stb1,wa_tab.

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:007

    select matnr werks stlaN stLnr stlal from mast

    INto CORRESPONDING FIELDS OF TABLE it_tab

    where matnr = WA_FINAL-IDNRK and

    werks = p_werks and

    stlAn = p_stlAn.

    loop at it_tab INTO wa_tab.

    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

    EXPORTING

    CAPID = 'PP01'

    DATUV = SY-DATUM

    MKTLS = 'X'

    MTNRV = wa_tab-matnr

    STLAL = wa_tab-stlal

    STLAN = wa_tab-stlan

    STPST = 0

    SVWVO = 'X'

    WERKS = WA_TAB-WERKS

    TABLES

    STB = IT_STB

    EXCEPTIONS

    ALT_NOT_FOUND = 1

    CALL_INVALID = 2

    MATERIAL_NOT_FOUND = 3

    MISSING_AUTHORIZATION = 4

    NO_BOM_FOUND = 5

    NO_PLANT_DATA = 6

    NO_SUITABLE_BOM_FOUND = 7

    CONVERSION_ERROR = 8

    OTHERS = 9

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:008

    .

    IF SY-SUBRC 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    clear: wa_stb1, wa_stb.

    loop at it_stb INTO wa_stb.

    wa_stb1-matnr = wa_tab-matnr.

    wa_stb1-ojtxb = WA_STB-OJTXB. wa_stb1-mtart = wa_stb-mtart.

    wa_stb1-mnglg = wa_stb-mnglg.

    wa_stb1-meins = wa_stb-meins.

    wa_stb1-idnrk = wa_stb-idnrk.

    wa_stb1-ojtxp = wa_stb-ojtxp. APPEND wa_stb1 to it_stb1.

    ENDLOOP.

    loop at IT_STB1 into fs_stb1.

    if sy-subrc = 0.

    wa_final-matnr = fs_stb1-matnr.

    wa_final-ojtxb = FS_STB1-OJTXB. wa_final-mtart = fs_stb1-mtart.

    wa_final-mnglg = fs_stb1-mnglg.

    wa_final-meins = fs_stb1-meins.

    wa_final-idnrk = fs_stb1-idnrk.

    wa_final-ojtxp = fs_stb1-ojtxp. append wa_final to it_final.

    ENDIF.

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:009

    endloop.

    ENDLOOP.

    ENDFORM. " RECURSIVE_BOM

    *&---------------------------------------------------------------------*

    *& Form BUILD_CATALOG

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    *

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:0010

    fieldcatalog-fieldname = 'OJTXP'.

    fieldcatalog-seltext_m = 'Child Desc'.

    fieldcatalog-col_pos = 3.

    fieldcatalog-outputlen = 40.

    APPEND fieldcatalog TO fieldcatalog.

    CLEAR fieldcatalog.

    fieldcatalog-fieldname = 'MTART'.

    fieldcatalog-seltext_m = 'Material Type'.

    fieldcatalog-col_pos = 4.

    APPEND fieldcatalog TO fieldcatalog.

    CLEAR fieldcatalog.

    fieldcatalog-fieldname = 'MNGLG'.

    fieldcatalog-seltext_m = 'Quantity Required'.

    fieldcatalog-col_pos = 5.

    APPEND fieldcatalog TO fieldcatalog.

    CLEAR fieldcatalog.

    fieldcatalog-fieldname = 'MEINS'.

    fieldcatalog-seltext_m = 'Unit Of Measure'.

    fieldcatalog-col_pos = 6.

    APPEND fieldcatalog TO fieldcatalog.

    CLEAR fieldcatalog.

    ENDFORM. " BUILD_CATALOG

    *&---------------------------------------------------------------------*

    *& Form DISPLAY_OUTPUT

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

  • Multilevel BOM Explosion With all alternative BOMs like CS03

    Generated by Jive on 2014-07-15+02:0011

    *