Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Any FM to get all levels of components of a BOM ?

Former Member
0 Kudos

Hi Gurus,

I am not an ABAPER. But I am looking for a FM which can be used to extract Multilevel BOM (All levels of BOM).

I know following FM gets component level only:-

'CSAP_MAT_BOM_ITEM_SELECT'

I researched on net and found some useful information but am unable to put things together.

For eg. please refer the linnk :-

http://www.sapfans.com/forums/viewtopic.php?f=13&t=52016

I am trying to explode material BOM. Just found on net that there are different FM's to explode diff categories of BOMs.

Can anyone please help.

Thanks

Edited by: Ray_Ray on Jul 8, 2010 10:19 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

check this:

Regards,

Kiran

11 REPLIES 11

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi,

In the standard transactions the functions csap_mat_bom_read , cs_where_used_mat are used.

The first one can be used for bom explosion from parent to child.Pass the material and plant to the function module , it will give the first level, then pass the materials obtained once again to the same function module for next level, repeat this process till no data is returned.

You can write a recursive logic to do this.

The second one gives you the upper level for a child part in the same manner.

0 Kudos

Hi All,

Thanks for response. What I have understood so far is as follows:-

Use either of the mentioned FM and loop it till you get 0 for that material and it will happen till all the materials are covered.

Now what I am unable to understand is the field which would help me to identify the subsequest assemblies of the BOM. I am giving an example just so that I am able to make everyone understand what I am looking for.

We are maintaining Multilevel bom. The user needs a report in BI which gives information about Material and the UOM of one of the item which is in assembly. eg. ABC is the material for that we have a BOM which inturn has 4 items and one of the items has two more BOMS :-

ABC

]

-


] ] ] ]

ABC1 ABC2 ABC3 ABC4

]

-


] ] ]

ABC2.1 ABC2.2 ABC2.3

Now Users need UOM of ABC2.2 for ABC.

How can I link it. Which field can be used?

Please help.

Regards

0 Kudos

The table STPO returned by the function module has a field COMP_UNIT ( unit of measure ) against every material.

0 Kudos

Hi Ray,

Check this rough source code,

This gives you the logic how to explode multilevel BOM, make the necessary changes.

Please not that there is no logic written for the alternative BOM ( a material may contain more than one BOM ).

you can identify the alternative bom from the availabe fields of the fm output table.


REPORT zinverse_bom_explosion.

TABLES:mara,marc.

TYPES:BEGIN OF ty_1,
      pmatnr   TYPE csap_mbom-matnr,
      matnr    TYPE csap_mbom-matnr,
      comp_qty    TYPE p DECIMALS 0,
      unit TYPE kmpme,
      END OF ty_1,

      BEGIN OF ty_2,
      pmatnr   TYPE csap_mbom-matnr,
      matnr    TYPE csap_mbom-matnr,
      unit TYPE kmpme,
      comp_qty    TYPE p DECIMALS 0,
      END OF ty_2.

DATA:it_list    TYPE TABLE OF stpo_api02,
     it_gather  TYPE TABLE OF ty_1,
     it_gather2 TYPE TABLE OF ty_1,
     it_store   TYPE TABLE OF ty_2.
DATA:g_cnt    TYPE sy-tfill,
     wa_gather TYPE  ty_1,
      wa_gather2 TYPE ty_1,
     wa_stpov  TYPE stpo_api02,
     g_index  TYPE sy-tabix,
     g_partno TYPE marc-matnr,
     wa_store  TYPE ty_2,
     g_usage TYPE csap_mbom-stlan,
     g_datuv TYPE csap_mbom-datuv,
     g_datub TYPE csap_mbom-datub.

PARAMETERS:p_matnr TYPE csap_mbom-matnr.
PARAMETERS:p_werks TYPE csap_mbom-werks.

START-OF-SELECTION.

  g_usage = 'P'.
  g_datuv = g_datub = sy-datum.
  wa_gather-matnr = g_partno = p_matnr.
  APPEND wa_gather TO it_gather.
  PERFORM get_parts.

FORM get_parts .
  CLEAR g_cnt.
  DESCRIBE TABLE it_gather LINES g_cnt.
  IF g_cnt = 0.
    EXIT.
  ENDIF.
  LOOP AT it_gather INTO wa_gather.
    CALL FUNCTION 'CSAP_MAT_BOM_READ'
      EXPORTING
        material   = wa_gather-matnr
        plant      = p_werks
        bom_usage  = g_usage
        valid_from = g_datuv
        valid_to   = g_datub
      TABLES
        t_stpo     = it_list[]
      EXCEPTIONS
        error      = 1
        OTHERS     = 2.
    CLEAR g_cnt.
    DESCRIBE TABLE it_list[] LINES g_cnt.
    IF g_cnt = 0.
      wa_store-matnr = g_partno.
      MOVE wa_gather-matnr TO wa_store-pmatnr.
      wa_store-comp_qty = wa_gather-comp_qty.
      APPEND wa_store TO it_store.
      CLEAR wa_store.
      CLEAR wa_gather.
    ELSE.
      g_index = 0.
      MOVE wa_stpov-component TO wa_gather2-matnr.
      wa_gather2-comp_qty = wa_stpov-comp_qty.
      APPEND wa_gather2 TO it_gather2.
      CLEAR wa_gather2.
    ENDIF.
    REFRESH it_list[].
  ENDLOOP.
  it_gather[] = it_gather2[].
  REFRESH it_gather2[].
  PERFORM get_parts.
ENDFORM.                    "get_parts

0 Kudos

Hi,

Can we use FM 'CABM_READ_BOM_ITEM' for the same purpose?

Regards

Former Member
0 Kudos

check this:

Regards,

Kiran

0 Kudos

There is no standard Fm which will explode the BOM to the last level. You can use the FM CS_BOM_EXPL_MAT_V2 in a loop to explode the subassemblies in every loop pass.

0 Kudos

actually, FM CS_BOM_EXPL_MAT_V2 DOES do a multi-level explosion. specify "X" in the MEHRS parameter, and you geta full, multi-level explosion with a single call

0 Kudos

Hi David,

Can you please tell me which field can be used to identify all levels of a BOm?

Regards

Former Member
0 Kudos

you can use CS_BOM_EXPLOSION

Sridharnekkanti
Active Participant
0 Kudos

check this FM CS_BOM_EXPL_KND_V1