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

select BOM for given MATNR...

Former Member
0 Likes
2,366

Hi All,

I have a problem with selecting the BOMs for avaible MATNR's.

My current report is displaying the Material Master data...with Material Numbers.

The existing part of the code is some thing like this:

talbes: mara.

data: begin of i_mdata occurs 0,

mtno like mara-matnr,

-


-


end of i_mdata.

now i have to select the BOM's(STPO-IDNRK) for these material numbers.

could anybody plz tell me how to do the selection..

thnkx

5 REPLIES 5
Read only

Former Member
0 Likes
1,321

Hi,

Welcome to SDN.

Try function : CSAP_MAT_BOM_READ

Use i/p Parameters for this function module : MAterial , Plant and BOM Usage.

This will return BON in Table T_STPO.

Lanka

Message was edited by: Lanka Murthy

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,321

Here is one approach.




report zrich_0003.

data: i_mara type table of mara with header line.
data: i_mast type table of mast with header line.
data: i_stpo type table of stpo with header line.


select-options: s_matnr for i_mara-matnr.


start-of-selection.

  select * from mara into table i_mara
          where matnr in s_matnr.

  check not  i_mara[] is initial.
  select * from mast into table i_mast
           for all entries in i_mara
                 where matnr = i_mara-matnr.

  check not  i_mast[] is initial.
  select * from stpo into table i_stpo
          for all entries in i_mast
                 where stlnr = i_mast-stlnr.



  loop at i_mast.


    write:/ i_mast-matnr, i_mast-werks.

    loop at i_stpo where stlnr = i_mast-stlnr.
      write:/ i_stpo-idnrk.
    endloop.

  endloop.

Welcome to SDN. Please remember to award points for helpful answers ans mark you post as solved when solved completely . Thanks.

Regards,

Rich Heilman

Read only

0 Likes
1,321

Hi Rich,

thnks for the reply..

but i cant take the select-options for the matnr.

as i told u, i hve to use the internal table which is already with Material Master details....here, the Itab is: i_mdata.

i have to write the select statement for retrieving the BOMs based on the <b>i_mdata-mtno</b> <b>compulsorily.</b>

plz check this....and let me know how to select those..

thnx

Read only

0 Likes
1,321

This was meant to be an example, not a 100% solution for you. But it remains the same......



data: i_mast type table of mast with header line.
data: i_stpo type table of stpo with header line.


start-of-selection.


  check not  <b>i_mdata</b>[] is initial.
  select * from mast into table i_mast
           <b>for all entries in i_mdata</b>
                 where matnr = <b>i_mdata-matnr</b>.

  check not  i_mast[] is initial.
  select * from stpo into table i_stpo
          for all entries in i_mast
                 where stlnr = i_mast-stlnr.



  loop at i_mast.


    write:/ i_mast-matnr, i_mast-werks.

    loop at i_stpo where stlnr = i_mast-stlnr.
      write:/ i_stpo-idnrk.
    endloop.

  endloop.



Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,321

You have already gone halfway to your goal... You just need to go to the table MAST using MATNR to get the id needed to get to STPO... that is the basic layout of it...