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: 

FM For Finding if Material BOM exits for BOM component.

Former Member
0 Kudos

Hi,

Is there any FM or BAPI to find out if there is any material BOM exists for the BOM component.

How is Indicator assembly get assighned..?

Any inputs would be appreciated.

Thanks,

Mark

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You'll be surprised how cheaply this has been programmed: a selection on MAST with MATNR and WERKS is all SAP does (routine POMAT_STLKZ_ERMITTELN in SAPLCSDI).

(Little hint on how to find these things: work with where-used analyses - either on the data element (e.g. "in function module interfaces" or "in programs"), or, if this doesn't work, on the table/structure field (in this case, RC29P-STLKZ). Then set lots of breakpoints and execute the program, until you're sure you've found the right spot.)

BTW, if you want to do this in a cleaner way, there's no perfect solution, either. There's the BAPI_MAT_BOM_EXISTENCE_CHECK (since 4.6C), but you have to check with a specific BOM usage. Also, by looking at it, it's rather complex, so if you do this in mass-processing, it may have a performance impact.

Or you can program your own MAST/STKO/STPO/... look-up, and at least include fields like deletion flags and the likes.

6 REPLIES 6

Former Member
0 Kudos

You'll be surprised how cheaply this has been programmed: a selection on MAST with MATNR and WERKS is all SAP does (routine POMAT_STLKZ_ERMITTELN in SAPLCSDI).

(Little hint on how to find these things: work with where-used analyses - either on the data element (e.g. "in function module interfaces" or "in programs"), or, if this doesn't work, on the table/structure field (in this case, RC29P-STLKZ). Then set lots of breakpoints and execute the program, until you're sure you've found the right spot.)

BTW, if you want to do this in a cleaner way, there's no perfect solution, either. There's the BAPI_MAT_BOM_EXISTENCE_CHECK (since 4.6C), but you have to check with a specific BOM usage. Also, by looking at it, it's rather complex, so if you do this in mass-processing, it may have a performance impact.

Or you can program your own MAST/STKO/STPO/... look-up, and at least include fields like deletion flags and the likes.

0 Kudos

To programmatically find where a component is used. You will need to use the CS_WHERE_USED_MAT function module. Hitting against MAST with MATNR and WERKS will only tell you if that material has a BOM, not where that material is used in other BOMs. The Assembly flag, I think, gets filled when the component has a BOM itself. I could be wrong though.

Regards,

Rich Heilman

0 Kudos

Sample program.



report zrich_0001 .

* Internal Tables
data: i_stpov like stpov occurs 0 with header line.

parameters: p_matnr type marc-matnr,
            p_werks type marc-werks.

start-of-selection.

perform where_used tables i_stpov
                   using p_matnr
                         p_werks.

loop at i_stpov.
  write:/ i_stpov-matnr, i_stpov-werks.
endloop.


************************************************************************
*  FORM WHERE_USED.
************************************************************************
form where_used tables itab
                using  matnr
                       werks.

  data: selpool like mc29s.
  data: eqpcat  like cscequi occurs 0.
  data: kndcat  like cscknd  occurs 0.
  data: matcat  like cscmat  occurs 0.
  data: prjcat  like cscprj  occurs 0.
  data: stdcat  like cscstd  occurs 0.
  data: tplcat  like csctpl  occurs 0.

  clear itab. refresh itab.
  call function 'CS_WHERE_USED_MAT'
       exporting
            datub                      = sy-datum
            datuv                      = sy-datum
            matnr                      = matnr
            postp                      = ' '
            stlan                      = ' '
            werks                      = werks
            stltp                      = ' '
       importing
            topmat                     = selpool  "Not Currently Used
       tables
            wultb                      = itab
            equicat                    = eqpcat  "Not Currently Used
            kndcat                     = kndcat  "Not Currently Used
            matcat                     = matcat  "Not Currently Used
            stdcat                     = stdcat  "Not Currently Used
            tplcat                     = tplcat  "Not Currently Used
            prjcat                     = prjcat  "Not Currently Used
       exceptions
            material_not_found         = 02
            no_where_used_rec_found    = 03
            no_where_used_rec_selected = 04
            no_where_used_rec_valid    = 05.

endform.

Regards,

Rich Heilman

Former Member
0 Kudos

Rich gave you the function module that can be used to find where a particular material is used in BOMs. CS15 transaction will give you the same thing.

Now the indicator 'Assembly' is set when there is a BOM(read sub-assembly) associated with that component of the current BOM. So if I am looking at the finished goods BOM of say a car, then I will see several components that make the car. But each of those components such as say the engine or the seats or the steering wheel is a semifinished product and needs to be manufactured by itself before you assemble it into a car. So they have their own BOMs. In those cases, you will see this indicator set on the main BOM. This can go into multiple levels like that. You can use CS12, if you want to see the exploded BOM(all levels of the BOM are expanded to the lowest level).

Former Member
0 Kudos

Thanks for your code.

it is working for my requirement.

0 Kudos

HI all

im having the following problem...

we are currently upgrading and we are doing our usual testing ... So we made a copy of PRD system to do our testing...

when re-exploding the po (subcontracting) bom, we get an error message that there is no component

but the BOM exists with correct availibility period.

any idea of what the prone can be?