6 Replies Latest reply: Jun 11, 2012 9:39 AM by Eric Lagasca RSS

How to use CS_BOM_EXPL_MAT_V2 to get correct quantity of component?

Eric Lagasca
Currently Being Moderated

Hi,

 

I am getting an issue with my program. I am using CS_BOM_EXPL_MAT_V2 to get the BOMs of a material. For example I have a material MAT1 that has the ff. BOM explosion.

 

MAT1

- COMP1 with Qty 2

- COMP2 with Qty 1

- COMP3 with Qty 1

 

And then, for component COMP1, it also has sub-components:

 

COMP1

- SUBCOMP1 with Qty 1

- SUBCOMP2 with Qty 1

 

So what I am expecting in my program, using CS_BOM_EXPL_MAT_V2, is to have the report to have a quantity of SUBCOMP1 = 2 and SUBCOMP2 = 2 (because MAT1 uses 2 quantity of COMP1). But what I am getting is SUBCOMP1 = 1 qty and SUBCOMP2 = 1 qty because I think that it is only considering the BOM of COMP1 and the quantity of COMP1 is not taken into account.

 

When running transaction CS12, the output is correct (SUBCOMP1 = 2, SUBCOMP2 = 2) for material MAT1.

 

So, how do I make CS_BOM_EXPL_MAT_V2 work so that it will respect the count of the component, in this case COMP1 with Qty 2, and cascade the value to the sub-components, in this case SUBCOMP1 and SUBCOMP2, and multiply it so it will return the correct quantity, in this case both sub-components should have Qty 2 as in transaction CS12?

 

If this is not possible with FM CS_BOM_EXPL_MAT_V2, please suggest other ways to achieve this.

  • Re: How to use CS_BOM_EXPL_MAT_V2 to get correct quantity of component?
    Laurent Fournier
    Currently Being Moderated

    Hello,

     

    I think that you must set multilevel indicator. Take a look at the following code and see if this can help you.

     

    FORM EXPLODE_BOM  USINGU_DATE
                           U_MATNR
                           U_MENGE
                           U_WERKS
                           U_MULTI
                CHANGING   C_SUCCESS.

     

      CLEAR : C_SUCCESS.

     

      CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

    EXPORTING
    *FTREL                   = ' '
    *ALEKZ                   = ' '
    *ALTVO                   = ' '
    *AUFSW                   = ' '
      AUMGB                   = 'X'
    *AUMNG                   = 0
      AUSKZ                   = ' '
    *AMIND                   = ' '
    *BAGRP                   = ' '
    *BEIKZ                   = ' '
    *BESSL                   = ' '
    *BGIXO                   = ' '
    *BREMS                   = ' '
      CAPID                   = 'PP01'
    *CHLST                   = ' '
    *COSPR                   = ' '
    *CUOBJ                   = 000000000000000
    *CUOVS                   = 0
    *CUOLS                   = ' '
      DATUV                   = U_DATE
    *DELNL                   = ' '
    *DRLDT                   = ' '
    *EHNDL                   = ' '
    *EMENG                   = 0
    *ERSKZ                   = ' '
    *ERSSL                   = ' '
    *FBSTP                   = ' '
    *KNFBA                   = ' '
    *KSBVO                   = ' '
    *MBWLS                   = ' '
    *MKTLS                   = 'X'
    *MDMPS                   = ' '
      MEHRS                   = U_MULTI
    *MKMAT                   = ' '
    *MMAPS                   = ' '
    *SALWW                   = ' '
    *SPLWW                   = ' '
    *MMORY                   = ' '
      MTNRV                   = U_MATNR
    *NLINK                   = ' '
    *POSTP                   = ' '
    *RNDKZ                   = ' '
    *RVREL                   = ' '
    *SANFR                   = ' '
    *SANIN                   = ' '
    *SANKA                   = ' '
    *SANKO                   = ' '
    *SANVS                   = ' '
    *SCHGT                   = ' '
    *STKKZ                   = ' '
    *STLAL                   = '1'
    *STLAN                   = '1'
      STPST                   = 0
    *SVWVO                   = 'X'
      WERKS                   = U_WERKS
    *NORVL                   = ' '
    *MDNOT                   = ' '
    *PANOT                   = ' '
    *QVERW                   = ' '
    *VERID                   = ' '
    *VRSVO                   = 'X'

    *  IMPORTING

    *TOPMAT                  =
    *DSTST                   =
    TABLES
      STB                     = BOM_EXPL
    *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

     

     

    Regards.

  • Re: How to use CS_BOM_EXPL_MAT_V2 to get correct quantity of component?
    Eric Lagasca
    Currently Being Moderated

    Here is how my code currently looks like: 

     

    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

      EXPORTING

        aumgb                 = 'X'

        capid                 = 'PP01'

        datuv                 = v_datuv

        endhl                 = '1'

        mehrs                 = 'X'

        mmory                 = '1'

        mtnrv                 = v_matnr

        stlal                 = v_stlal

        stpst                 = 0

        svwvo                 = 'X'

        werks                 = v_werks

        vrvso                 = 'X'

      IMPORTING

        topmat                = gs_top

      TABLES

        stb                   = gt_stb

        matcat                = gt_matca

      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.

    • Re: How to use CS_BOM_EXPL_MAT_V2 to get correct quantity of component?
      Laurent Fournier
      Currently Being Moderated

      Hi again,

       

      Can you please try to remove fields endhl & mmory from the call and try it out ?

       

      I can't see any other difference except the stlal field compairing to my piece of coding.

       

      I remember that my piece of coding worked as required.

       

      Regards.

    • Re: How to use CS_BOM_EXPL_MAT_V2 to get correct quantity of component?
      sultana seher
      Currently Being Moderated

      Hi,

       

      Try calling the FM as below   

       

      call function 'CS_BOM_EXPL_MAT_V2'
           exporting
             ftrel                 = ' '
             alekz                 = ' '
             altvo                 = ' '
             aufsw                 = ' '
             aumgb                 = ' '
             aumng                 = ' '
             auskz                 = ' '
             amind                 = ' '
             bagrp                 = ' '
             beikz                 = ' '
             bessl                 = ' '
             bgixo                 = ' '
             brems                 = ' '
             capid                 = 'PP01'
             chlst                 = ' '
             cospr                 = ' '
             cuobj                 = 000000000000000
             cuovs                 = ' '
             cuols                 = ' '
             datuv                 = sy-datum
             delnl                 = ' '
             drldt                 = ' '
             ehndl                 = '1'
             emeng                 = 0
             erskz                 = ' '
             erssl                 = ' '
             fbstp                 = ' '
             knfba                 = ' '
             ksbvo                 = ' '
             mbwls                 = ' '
             mktls                 = ' '
             mdmps                 = ' '
             mehrs                 = 'X'
             mkmat                 = ' '
             mmaps                 = ' '
             salww                 = ' '
             splww                 = ' '
             mmory                 = ' '
             mtnrv                 = l_matnr
             nlink                 = ' '
             postp                 = ' '
             rndkz                 = ' '
             rvrel                 = ' '
             sanfr                 = ' '
             sanin                 = ' '
             sanka                 = ' '
             sanko                 = ' '
             sanvs                 = ' '
             schgt                 = ' '
             stkkz                 = ' '
             stlal                 = '01'
             stlan                 = '1'
             stpst                 = '0'
             svwvo                 = ' '
             werks                 = l_werks
             norvl                 = ' '
             mdnot                 = ' '
             panot                 = ' '
             qverw                 = ' '
             verid                 = ' '
             vrsvo                 = 'X'
           importing
             topmat                = wa_matcat
             dstst                 = g_field
           tables
             stb                   = i_stb
             matcat                = i_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.

Actions