cancel
Showing results for 
Search instead for 
Did you mean: 

How to explode the multilevel BOM with Alternate BOMs in each level.

Former Member
0 Kudos

Hi experts,

                I referred this question in various discussion in scn but i couldn't found any answers.

               My requirement is  i want to explode the material level by level with all  Alternate BOMs in each level.I used this FM 'CS_BOM_EXPL_MAT_V2 to explode the multilevel BOM material but it displays the output for only one alternative BOMs (i.e it taking only one alternate BOMs in each level ) like CS12 transactions.

               How to explode the multilevel BOM with all Alternate BOMs ..? is there any FM is there.?

               I used this code for reference but it displays output for single alternate BOM only in each level  how to achieve multilevel BOM exploding with all Alternate BOMs..?

              
               https://wiki.sdn.sap.com/wiki/display/Snippets/Program+on+Exploding+Bill+Of+Materials

              

               for helpful answers i will reward the points immediately.

thanks ,

PRABHAKARAN.


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

Try reading avaiable alternatives of the bom from table stko/stpo first

after getting all the avaiable alternatives use the FM you mentioned and fetch the data one by one

collect the data and then display. This could be the only way dont think that it will be possible to explode the

all alternatives in one go.

Regards,
Mandar.

Answers (8)

Answers (8)

Former Member

Hi Prabhakaran,

Try with program RCS12001 for Exploding BOM Multilevel.

Thanks & Regards,

Ravi

Former Member
0 Kudos

hi Ravi,

               The RCS12001 Report only give the output for single alternate boms i want the same output format but for Multiple alternate BOMs.

Former Member
0 Kudos

Hi,

Please use the report "rcs15001" pass matnr,werks,datuv,dirkt,mattp and mehrs=> this fields brin multiple level.I have used this if any doubt just ask me.Hope it is useful.

Regards,

Ravi Shankar L

Former Member
0 Kudos

Hi,

Why not try to use workbench?

{code}

  DATA:
       classes_to_process TYPE classes_in_workarea.

  " define classes to be processed by EWB
  CLEAR classes_to_process.

  classes_to_process-mtk_inarea = 'X'.  " Material header
  classes_to_process-tsk_inarea = 'X'.  " Task list
  classes_to_process-seq_inarea = 'X'.  " Sequences
  classes_to_process-opr_inarea = 'X'.  " Operations
  classes_to_process-suo_inarea = ' '.   " Sub-operations
  classes_to_process-prt_inarea = ' '.   " PRT
  classes_to_process-com_inarea = 'X'.  " Components
  classes_to_process-cha_inarea = 'X'.  " Characteristics

  IF NOT  classes_to_process-com_inarea IS INITIAL.
    classes_to_process-obm_inarea = 'X'.
    classes_to_process-bom_inarea = 'X'.
    classes_to_process-itm_inarea = 'X'.
  ELSE.
    classes_to_process-obm_inarea = ' '.
    classes_to_process-bom_inarea = ' '.
    classes_to_process-itm_inarea = ' '.
  ENDIF.

  CALL FUNCTION 'CP_CC_S_LOAD_CHECK'
    EXPORTING
      i_classes_in_workarea = classes_to_process
    EXCEPTIONS
      odp_cannot_be_loaded  = 1
      cla_cannot_be_loaded  = 2
      sui_to_be_loaded      = 3
      itm_to_be_loaded      = 4
      bom_to_be_loaded      = 5
      com_to_be_loaded      = 6
      cha_to_be_loaded      = 7
      opr_to_be_loaded      = 8
      seq_to_be_loaded      = 9
      tsk_to_be_loaded      = 10
      mtk_to_be_loaded      = 11
      no_entries            = 12
      itm_selobj_wrong      = 13
      bom_selobj_wrong      = 14
      opr_selobj_wrong      = 15
      tsk_selobj_wrong      = 16.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'S'
            NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.

  CALL FUNCTION 'CP_CC_S_LOAD_COMPLEX_BY_TSK'
    EXPORTING
      i_class                        = 'P'
*     i_profile                      = '1'
      i_classes_in_workarea          = classes_to_process
      i_cpsc_mtk_sel                 = mtk_sel
      i_cpsc_tsk_sel                 = tsk_sel
      i_cpsc_opr_sel                 = opr_sel
      i_date_from                    = sy-datlo
      i_date_to                      = sy-datlo
      i_message_handler              = 'X'
    EXCEPTIONS
      workarea_not_found             = 1
      class_wrong_type               = 2
      workarea_wrong_type            = 3
      class_in_workarea_inconsistent = 4
      workarea_not_specified         = 5
      tsk_not_found                  = 6
      no_selection_criteria          = 7
      invalid_selection_period       = 8
      key_date_required_for_ecm      = 9.

  IF NOT sy-subrc IS INITIAL.
    MESSAGE i001(cpwb).
    EXIT.
  ENDIF.

  " Load material list
  CALL FUNCTION 'CZ_CL_S_MTK_PROVIDE'
    EXPORTING
      i_date_from      = sy-datlo
      i_date_to        = sy-datlo
      i_plnty          = 'N'
    TABLES
      e_mtk_class_data = mtk_data
    EXCEPTIONS
      wrong_key        = 1
      OTHERS           = 2.

*      " Load operations
  CALL FUNCTION 'CP_CL_S_OPR_PROVIDE'
    EXPORTING
      i_date_from      = sy-datlo
      i_date_to        = sy-datlo
      i_plnty          = 'N'
    TABLES
      e_opr_class_data = opr_data
    EXCEPTIONS
      wrong_key        = 1
      OTHERS           = 2.

  " Load component assigments
  CALL FUNCTION 'CM_CL_S_COM_PROVIDE_BY_OPR'
    EXPORTING
      i_date_from      = sy-datlo
      i_date_to        = sy-datlo
      i_plnty          = 'N'
    TABLES
      e_com_class_data = com_data
    EXCEPTIONS
      wrong_key        = 1
      OTHERS           = 2.

  " Load BOM headers
  CALL FUNCTION 'CS_CL_S_BOM_PROVIDE'
    EXPORTING
      i_date_from      = sy-datlo
      i_date_to        = sy-datlo
    TABLES
      e_bom_class_data = bom_data
    EXCEPTIONS
      wrong_key        = 1
      OTHERS           = 2.

  " Load BOM items
  CALL FUNCTION 'CS_CL_S_ITM_PROVIDE'
    EXPORTING
      i_date_from      = sy-datlo
      i_date_to        = sy-datlo
    TABLES
      e_itm_class_data = itm_data
    EXCEPTIONS
      wrong_key        = 1
      OTHERS           = 2.

{code}

premlahar
Participant
0 Kudos

You can check in product structure browser : CC04 : All alternate BOM's for a material

shubo
Discoverer
0 Kudos

Hi

You can try and use the following function module for your purpose:

'CK_F_CSTG_STRUCTURE_EXPLOSION'.

Sample code:

CALL FUNCTION 'CK_F_CSTG_STRUCTURE_EXPLOSION'

    EXPORTING

      klvar                 = pi_keko-klvar

      kalnr                 = pi_keko-kalnr

      kadky                 = pi_keko-kadky

      tvers                 = pi_keko-tvers

      werk                  = pi_keko-werks

      sicht                 = c_sicht

      s_losgr               = c_charx

      s_bezugsmenge         = pi_v_menge

      s_bezugsmengeneinheit = pi_v_meins

      s_aufloesungstiefe    = v_level

      s_read_only_db        = c_charx

      s_only_mat_pos        = ' '

    TABLES

      strukturtabelle       = pi_tab

      t_keko_imp            = lt_keko

    EXCEPTIONS

      invalid_bzobj         = 1

      keko_not_found        = 2

      meta_model_error      = 3

      ckhs_not_found        = 4

      OTHERS                = 5.

  IF sy-subrc <> 0.

    MESSAGE i000 WITH 'Material could not be exploded'.

    LEAVE LIST-PROCESSING.

  ENDIF.

You don't need to call this in a loop. It will explode the materials along with Costing Structure for how many levels you specify.

Cheers

Shubhankar

gurunathkumar_dadamu
Active Contributor
0 Kudos

Hi Prabhakaran,

Try the below code will work. For the similar requirement i have done custom report.

*Global DATA diclerations

INCLUDE zptp_access_bom_top.

*Include to hold selection screen details

INCLUDE zptp_access_bom_sel.

* Include to hold all perform details

INCLUDE zptp_access_bom_start.

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

*&  Include           ZPTP_ACCESS_BOM_TOP

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

TYPE-POOLS:slis.

*- table declaratios.

TABLES: mara,

        marc,

        mast,

        mvke.

TYPES : BEGIN OF ty_itemd,

      guid TYPE /rpm/tv_guid,

      external_id TYPE c LENGTH 48,

      portfolio_guid TYPE /rpm/tv_guid,

      parent_guid TYPE /rpm/tv_guid,

      END OF ty_itemd.

TYPES:  BEGIN OF ty_mara_check,

         matnr             TYPE mara-matnr,

         wrkst(24)             TYPE c,

         mtart             TYPE mara-mtart,

         mstae             TYPE mara-mstae,

        END OF   ty_mara_check.

*-structures.

TYPES :  BEGIN OF ty_mara,

         matnr             TYPE mara-matnr,

         wrkst             TYPE mara-wrkst,

         mtart             TYPE mara-mtart,

         mstae             TYPE mara-mstae,

         END OF   ty_mara.

TYPES: BEGIN OF ty_marc,

        matnr              TYPE marc-matnr,

        prctr              TYPE marc-prctr,

        werks               TYPE  marc-werks,

        END OF   ty_marc.

TYPES:  BEGIN OF ty_mvke,

        matnr              TYPE mvke-matnr,

        mvgr4              TYPE mvke-mvgr4,

        mvgr1              TYPE mvke-mvgr1,

        END   OF ty_mvke.

TYPES : BEGIN OF ty_bapi_material_check,

   material              TYPE bapi1080_mbm_c-material,

   plant                 TYPE bapi1080_mbm_c-plant,

   bomusage              TYPE bapi1080_bgr_c-bom_usage,

   END   OF ty_bapi_material_check.

TYPES : BEGIN OF ty_final,

        matnr             TYPE mara-matnr,

       matnr_item         TYPE mara-matnr,

        END OF   ty_final.

*- Strucure for error details

TYPES:

  BEGIN OF ty_details,

         matnr             TYPE  mast-matnr,

         msg(250)          TYPE c,

         type(3)           TYPE c,

  END OF ty_details.

TYPES: BEGIN OF ty_/rpm/bucket_d,

        parent_guid        TYPE /rpm/bucket_d-parent_guid,

        END OF   ty_/rpm/bucket_d.

TYPES : BEGIN OF ty_/rpm/bucket_d1,

           external_id     TYPE mara-wrkst,

          END OF   ty_/rpm/bucket_d1.

TYPES: BEGIN OF ty_mara_item,

       matnr_item           TYPE mara-matnr,

       wrkst_item           TYPE mara-wrkst,

       END OF ty_mara_item.

TYPES : BEGIN OF ty_hier,

external_id    TYPE c LENGTH 48,

desc           TYPE char50,

END OF ty_hier.

DATA: it_itemd  TYPE TABLE OF ty_itemd,

      it_bucketd  TYPE TABLE OF ty_itemd,

      it_item                TYPE STANDARD TABLE OF stpo_api01,

      it_item1               TYPE STANDARD TABLE OF stpo_api03,

      it_return              TYPE TABLE OF bapiret2,

      wa_return              TYPE bapiret2,

      it_mara                TYPE STANDARD TABLE OF ty_mara,

      it_mara_check                TYPE STANDARD TABLE OF ty_mara_check,

      it_mara_del            TYPE TABLE OF ty_mara,

*      it_marc                TYPE STANDARD TABLE OF ty_marc,

      it_/rpm/bucket_d       TYPE STANDARD TABLE OF ty_/rpm/bucket_d,

      it_/rpm/bucket_d1      TYPE STANDARD TABLE OF ty_/rpm/bucket_d1,

      it_mara_item           TYPE STANDARD TABLE OF ty_mara_item,

      it_final               TYPE STANDARD TABLE OF ty_final,

      it_fieldcat            TYPE     slis_t_fieldcat_alv,

      it_events              TYPE     slis_t_event,

      it_stb  TYPE TABLE OF stpox,

      it_matcat          TYPE TABLE OF          cscmat,

      it_log             TYPE STANDARD TABLE OF ty_details.

DATA:it_marc TYPE STANDARD TABLE OF ty_marc,

     it_mvke TYPE STANDARD TABLE OF ty_mvke,

     x_data TYPE zspn_s_output.

DATA:it_hier TYPE STANDARD TABLE OF ty_hier,

      wa_hier TYPE ty_hier.

DATA         :  x_mara                 TYPE ty_mara,

                x_marc                  TYPE ty_marc,

                x_mvke                  TYPE ty_mvke,

                x_header                TYPE stko_api01,

                x_item                 TYPE stpo_api01,

                x_item1                TYPE stpo_api01,

                x_bapi_materail_check  TYPE ty_bapi_material_check,

                x_stko                TYPE stko_api02,

                x_final               TYPE ty_final,

                x_final1              TYPE ty_final,

                x_sucess              TYPE ty_details,

                x_error               TYPE ty_details,

                x_exist               TYPE ty_details,

                x_fieldcat            LIKE LINE OF it_fieldcat,

                x_stb                  TYPE stpox,

                x_matcat              TYPE cscmat,

                x_topmat              TYPE  cstmat,

                x_dstst               TYPE  csdata-xfeld,

                x_event               TYPE slis_alv_event.

DATA: lv_material            TYPE csap_mbom-matnr,

      lv_plant               TYPE csap_mbom-werks,

      lv_bom_usage           TYPE csap_mbom-stlan,

      lv_date                TYPE csap_mbom-datuv,

      lv_bom_no              TYPE stko_api02-bom_no,

      lv_idnrk               TYPE stpo-idnrk,

      lv_item_no             TYPE stpo_api01-item_no,

      lv_error(200)          TYPE c,

      lv_sucess(200)         TYPE c,

      lv_text(200)           TYPE c,

      lv_text1(200)          TYPE c,

      lv_external_id TYPE mara-wrkst,

      lv_com_item TYPE mara-wrkst,

      lv_exist(200)          TYPE c.

CONSTANTS:c_base_quan(1)     TYPE c VALUE '1',

          c_base_unit(2)     TYPE c VALUE 'EA',

          c_lan(2)           TYPE c VALUE 'EN',

          c_e(1)             TYPE c VALUE 'E',

          c_x(1)             TYPE c VALUE 'X',

          c_y(1)             TYPE c VALUE 'Y',

          c_z(1)             TYPE c VALUE 'Z',

          c_z003(4)          TYPE c VALUE 'Z003',

          c_sucess(1)        TYPE c VALUE 'S'.

DATA: lv_project_id TYPE zproject_id,

      lv_sector     TYPE zproject_id,

      lv_product    TYPE zproject_id,

      lv_prog_grp   TYPE zproject_id,

      lv_program    TYPE zproject_id,

      lv_proj_set   TYPE zproject_id,

      lv_proj_id    TYPE zproject_id.

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

*&  Include           ZPTP_ACCESS_BOM_SEL

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

*- selection-screen.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_matnr FOR mara-matnr,                                          "material no

                s_prctr for   marc-prctr OBLIGATORY,                               "profit center

                s_mvgr4 for   mvke-mvgr4 OBLIGATORY,                               "portfolio year

                s_mvgr1 for   mvke-mvgr1 OBLIGATORY,                               "SIH Level

                s_mtart for   mara-mtart OBLIGATORY,                               "material type

                s_werks FOR   marc-werks OBLIGATORY,                               "plant

                s_mstae FOR   mara-mstae OBLIGATORY,                               "cross plant materail status

                s_stlan FOR   mast-stlan OBLIGATORY.                               "BOM usage

SELECTION-SCREEN END OF BLOCK b1.

*SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.

*PARAMETERS:   p_prctr TYPE marc-prctr OBLIGATORY,                               "profit center

*              p_mvgr4 TYPE mvke-mvgr4 OBLIGATORY,                               "portfolio year

*              p_mvgr1 TYPE mvke-mvgr1 OBLIGATORY,                               "SIH Level

*              p_mtart TYPE mara-mtart OBLIGATORY,                               "material type

*              p_werks TYPE marc-werks OBLIGATORY,                               "plant

*              p_mstae TYPE mara-mstae OBLIGATORY,                               "cross plant materail status

*              p_stlan TYPE mast-stlan OBLIGATORY.                               "BOM usage

*

*

*

*SELECTION-SCREEN END OF BLOCK b2.

PERFORM get_data.

PERFORM alv_display.

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

*&  Include           ZPTP_ACCESS_BOM_START

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

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

*&      Form  GET_DATA

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

*       text

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

*  --  p1        text

*  --  p2        text

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

FORM get_data .

*- select the profit center

  DATA : lv_com_item TYPE mara-wrkst.

  SELECT

        matnr

        prctr

        werks

         FROM marc

         INTO TABLE it_marc

         WHERE matnr IN s_matnr

         AND   prctr IN s_prctr

         AND   werks IN s_werks.

*- select the  portfolio year  and bom level.

  IF it_marc IS NOT INITIAL.

    SELECT

          matnr

          mvgr4

          mvgr1

           FROM mvke

           INTO TABLE it_mvke

           FOR ALL ENTRIES IN it_marc

           WHERE matnr = it_marc-matnr

           AND   mvgr4 IN s_mvgr4

           AND   mvgr1 IN s_mvgr1.

    SORT it_mvke BY mvgr1 ASCENDING.

*- select material & commitment item(project id) from mara into it_mara.

    IF it_mvke IS NOT INITIAL.

      IF s_mtart-low = 'ZMEM' OR s_mtart-high = 'ZSUP'.

        SELECT

           matnr

           wrkst

           mtart

           mstae

              FROM mara

              INTO TABLE it_mara

              FOR ALL ENTRIES IN it_mvke

              WHERE ( matnr = it_mvke-matnr AND matnr IN s_matnr )

              AND   mtart IN s_mtart

              AND   mstae IN s_mstae.

*- if sucess.

        IF sy-subrc = 0.

          DELETE it_mara WHERE mtart <> 'ZMEM'

                           AND mtart <> 'ZSUP'.

*- sort it_mara by matnr wrkst.

          LOOP AT  it_mvke INTO  x_mvke.

            READ TABLE it_mara INTO x_mara WITH KEY matnr = x_mvke-matnr.

            IF sy-subrc = 0.

              READ TABLE it_marc INTO  x_marc WITH KEY matnr = x_mara-matnr.

              IF sy-subrc = 0.

                PERFORM bapi_check_bom.

                IF sy-subrc = 0.

                  PERFORM bapi_creation.

                ELSE.

*                  PERFORM bapi_change_bom.

                ENDIF.

              ENDIF.

            ENDIF.

            CLEAR: lv_bom_no,

                   lv_text,

                   lv_text1,

                   lv_material,

                   lv_plant,

                   lv_bom_usage,

                   lv_date,

                   lv_error,

                   lv_sucess,

                   sy-msgno,

                   sy-msgid,

                   sy-msgty,

                   x_mara,

                   x_mvke,

                   x_marc.

            REFRESH : it_item,

                      it_stb,

                      it_matcat.

          ENDLOOP.

        ENDIF.

      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    "get_data

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

*&      Form  BAPI_CHECK_BOM

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

*       text

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

*  -->  p1        text

*  --  p2        text

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

FORM           bapi_check_bom .

  IF sy-subrc = 0.

    IF x_mara-matnr IS NOT INITIAL.

      MOVE :  x_mara-matnr TO x_bapi_materail_check-material ,

              x_marc-werks TO x_bapi_materail_check-plant,

              c_y          TO x_bapi_materail_check-bomusage .

      CALL FUNCTION 'BAPI_MAT_BOM_EXISTENCE_CHECK'

        EXPORTING

          material = x_bapi_materail_check-material

          plant    = x_bapi_materail_check-plant

          bomusage = x_bapi_materail_check-bomusage

        TABLES

          return   = it_return.

      .

*      CLEAR: x_bapi_materail_check.

      IF NOT it_return IS INITIAL.

        CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

          EXPORTING

            capid                 = c_Z003

            mktls                 = c_x

            mehrs                 = c_x

            mtnrv                 = x_bapi_materail_check-material

            stlan                 = c_z

            DATUV                 = sy-datum

            stpst                 = 0

            svwvo                 = c_x

            werks                 = '1000'

            vrsvo                 = c_x

          IMPORTING

            topmat                = x_topmat

            dstst                 = x_dstst

          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.

          PERFORM error_handling.

        ENDIF.

        ELSE.

          CONCATENATE text-007 lv_material INTO lv_exist SEPARATED BY space.

*- moving the error details into wa_error.

          MOVE :lv_exist    TO x_exist-msg,    "message

                lv_material TO x_exist-matnr,  "material

                c_e     TO x_exist-type.   "message type

          APPEND x_exist TO it_log.

          CLEAR:x_exist.

        ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    " BAPI_CHECK_BOM

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

*&      Form  BAPI_CREATION

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

*       text

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

*  --  p1        text

*  --  p2        text

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

FORM bapi_creation .

  IF x_mara-matnr IS NOT INITIAL.

    lv_com_item = x_mara-wrkst.

*- passthe materials to wa_header :To bom creation.

    MOVE:  x_mara-matnr    TO  lv_material,

           x_marc-werks     TO  lv_plant,

           s_stlan-low     TO  lv_bom_usage,

           c_base_quan     TO  x_header-base_quan,

           c_base_unit     TO  x_header-base_unit.

*- converting data format.

    CONCATENATE  sy-datum+4(2) '/' sy-datum+6(2) '/' sy-datum+0(4) INTO lv_date.

*    CLEAR x_mara.

    DELETE it_stb WHERE mtart <> 'ZDWI'

                  AND   mtart <> 'ZDXI'.

    LOOP AT it_stb INTO x_stb.

      IF sy-subrc = 0.

*- passing the item details.

*        lv_item_no = lv_item_no + 10.

*        x_item-item_no = lv_item_no.

        CLEAR: lv_idnrk.

*- converting the materil no (at item level).

        CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

          EXPORTING

            input  = x_stb-idnrk

          IMPORTING

            output = lv_idnrk.

*- item datails.

        x_item-rec_allowd = 'X'.

        x_item-item_categ = 'Z'.

        x_item-component  = lv_idnrk.              "Bom.Component

        x_item-comp_qty   = c_base_quan.           "Comp.Quantity

        x_item-comp_unit  = c_base_unit.           "Comp.unit

        APPEND x_item TO it_item.

        CLEAR :x_item,

               x_stb.

      ENDIF.

    ENDLOOP.

  ENDIF.

*- converting the maerail no.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

    EXPORTING

      input  = lv_material

    IMPORTING

      output = lv_material.

*- Calling the fm for bom creation.

  IF lv_material IS NOT INITIAL AND it_item IS NOT INITIAL.

    CALL FUNCTION 'CSAP_MAT_BOM_CREATE'

      EXPORTING

        material   = lv_material           "material

        plant      = lv_plant              "plant

        bom_usage  = lv_bom_usage          "bom usage

        valid_from = lv_date               "valid date

        i_stko     = x_header             " header

      IMPORTING

        bom_no     = lv_bom_no             " bom no

      TABLES

        t_stpo     = it_item               " item

      EXCEPTIONS

        error      = 1

        OTHERS     = 2.

  ENDIF.

  IF lv_bom_no IS NOT INITIAL.

    CONCATENATE text-005 lv_text1 lv_bom_no INTO lv_sucess SEPARATED BY space.

*- moving the sucess records into wa_sucess.

    MOVE : lv_sucess   TO x_sucess-msg,     "message

           lv_material  TO x_sucess-matnr,   "material

           sy-msgty    TO x_sucess-type.    "message type

    APPEND x_sucess   TO it_log.

    CLEAR x_sucess.

*- calling the fm to database commit

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  ELSE.

*- bom is not created.

    IF sy-msgty NE 'W'.

*- seleting the error text

      SELECT SINGLE text FROM t100 INTO lv_text WHERE sprsl = c_lan

                                                 AND  arbgb = sy-msgid

                                                 AND  msgnr = sy-msgno.

      REPLACE ALL OCCURRENCES OF '&' IN lv_text WITH space.

      IF sy-msgno NE '305'.

        CONCATENATE lv_text lv_material INTO lv_error SEPARATED BY space.

      ELSE.

        lv_error = lv_text.

      ENDIF.

    ELSE.

      CONCATENATE text-006 lv_material INTO lv_error SEPARATED BY space.

    ENDIF.

*- moving the error details into wa_error.

    MOVE :lv_error    TO x_error-msg,    "message

          lv_material TO x_error-matnr,  "material

          sy-msgty    TO x_error-type.   "message type

    APPEND x_error TO it_log.

    CLEAR:x_error.

  ENDIF.

ENDFORM.                    " BAPI_CREATION

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

*&      Form  ALV_DISPLAY

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

*       text

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

*  --  p1        text

*  --  p2        text

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

FORM alv_display .

*- fieldcatlog

  PERFORM fieldlcat.

*- events

  PERFORM events.

  SORT it_log BY type DESCENDING.

* display the errors by using simple alv list

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

      i_callback_program = sy-repid

      it_fieldcat        = it_fieldcat

      it_events          = it_events

    TABLES

      t_outtab           = it_log.

ENDFORM.                    " ALV_DISPLAY

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

*&      Form  FIELDLCAT

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

*       text

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

*  --  p1        text

*  --  p2        text

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

FORM fieldlcat .

  CLEAR x_fieldcat.                       "material no

  x_fieldcat-col_pos   = '1'.

  x_fieldcat-fieldname = 'MATNR'.

  x_fieldcat-tabname   = 'IT_RECORDS'.

  x_fieldcat-outputlen =  18.

  x_fieldcat-seltext_m =  text-002.

  APPEND x_fieldcat TO it_fieldcat.

  CLEAR x_fieldcat.

  x_fieldcat-col_pos   = '2'.            " meaasge type

  x_fieldcat-fieldname = 'TYPE'.

  x_fieldcat-tabname   = 'IT_RECORDS'.

  x_fieldcat-outputlen = 5.

  x_fieldcat-seltext_m = text-003.

  APPEND x_fieldcat TO it_fieldcat.

  CLEAR x_fieldcat.

  x_fieldcat-col_pos   = '3'.            " mesage text

  x_fieldcat-fieldname = 'MSG'.

  x_fieldcat-tabname   = 'IT_RECORDS'.

  x_fieldcat-outputlen = 90.

  x_fieldcat-seltext_m = text-004.

  APPEND x_fieldcat TO it_fieldcat.

  CLEAR x_fieldcat.

ENDFORM.                    " FIELDLCAT

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

*&      Form  EVENTS

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

*       text

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

*  --  p1        text

*  --  p2        text

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

FORM events .

*- events for top_of-page.

  x_event-name = slis_ev_top_of_list.

  x_event-form = 'TOP_OF_PAGE'.

  APPEND x_event TO it_events.

  CLEAR x_event.

ENDFORM.                    " EVENTS

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

**&      Form  TOP_OF_PAGE

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

**       text

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

**  --  p1        text

**  --  p2        text

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

FORM top_of_page .

*- displaying the top_of_page.

  WRITE: /5 text-010,sy-datum,sy-uzeit.

  ULINE.

ENDFORM.                    " TOP_OF_PAGE

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

*&      Form  ERROR_HANDLING

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM error_handling .

  CASE sy-subrc.

    WHEN 1.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg =  text-011.

      x_error-type = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 2.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg  = text-012.

      x_error-type = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 3.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-013.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 4.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-014.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 5.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-015.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 6.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-016.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 7.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-017.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 8.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-018.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

when 9.

      x_error-matnr = x_bapi_materail_check-material.

      x_error-msg   = text-019.

      x_error-type  = c_e.

      APPEND x_error to it_log.

      CLEAR x_error.

endcase.

Regards,

Guru

    ENDFORM.                    " ERROR_HANDLING

Former Member
0 Kudos

Hi gurunath,

     Could please explain the logic as i am unable to understand the correct logic and i worked on that code but i didn't got any results.

Regards,

prabhakaran.k

former_member205060
Active Participant
0 Kudos

Did you want to achieve this in your customize report ???

Former Member
0 Kudos

hi Rahul,

     yea , i want to achieve this in customized report.

anand_shukla
Active Participant
0 Kudos

Hi, Prabhakaran,

You can put * in the filed of alt BOM.