Application Development and Automation 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: 
Read only

Finding BOM header material from component item

Former Member
0 Likes
9,521

If I am given a material component of a BOM, how can I then get the BOM header material. For instance Part 123 is the BOM header material and it contains one component which is part ABC. If I know part ABC, how do I then pull in Part 123 into my program?

Thanks in advance for your help.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
3,858

That's right, the component can be used in more than one BOM, so you have to take that into account. But any way, you would need to get the internal BOM number from STPO where you find your ABC material in field IDNRK. Then use this internal BOM number and select against, the MAST table. This MAST table will give you the parent material and plant. So you may need to use STKO as well to get some of other field values to use to narrow your search against MAST.

Regards,

Rich Heilman

If I am given a material component of a BOM, how can I then get the BOM header material. For instance Part 123 is the BOM header material and it contains one component which is part ABC. If I know part ABC, how do I then pull in Part 123 into my program?

Thanks in advance for your help.

5 REPLIES 5
Read only

Former Member
0 Likes
3,858

Hi ,

I have a conern regarding your requiremnet , as a material can be used in a number of BOM , so the material ABC can be in more than one BOM , so what exactly is your requirement to get all the materisl which have the material ABC as a component in the bom ,

Regards

Arun

Read only

RichHeilman
Developer Advocate
Developer Advocate
3,859

That's right, the component can be used in more than one BOM, so you have to take that into account. But any way, you would need to get the internal BOM number from STPO where you find your ABC material in field IDNRK. Then use this internal BOM number and select against, the MAST table. This MAST table will give you the parent material and plant. So you may need to use STKO as well to get some of other field values to use to narrow your search against MAST.

Regards,

Rich Heilman

Read only

0 Likes
3,858

Or you could use this function.

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                      = lv_matnr
            postp                      = ' '
            stlan                      = ' '
            werks                      = lv_werks
            stltp                      = ' '
       importing
            topmat                     = selpool  "Not Currently Used
       tables
            wultb                      = itab  "Contains the where-used records
            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.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
3,858

Give the material component in the field IDNRK ( component) in the table STPO

BOM category ( STLTY) = M and then you will get BOM ( STLNR )

Give this STLNR to table MAST and find header material in matnr.

select single stlnr from stpo into stpo-stlnr where idnrk = p_component

and stlty = 'M' .

if sy-subrc = 0

select single matnr from mast into mast-matnr where stlnr = stpo-stlnr.

endif.

mast-matnr is the bom header material.

If there are multiple BOM's for the given component, then you will have to specify more conditions in the where clause.

Read only

Former Member
0 Likes
3,858

Thanks so much to all of you for your help!