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: 

Problem in getting BOM for components

Former Member
0 Kudos

Hi,

Can anyone help me in developing the logic for the following req.

I have a SAP table STPO(For BOM).

My selection screen has upto ten componenets number.

I want to display only those BOM which has all the components entered in the screen

For example:

Table XYZ

Field1 Field2

X 1

X 2

Y 1

Y 2

Y 3

If I have entered 1 and 2 in the selection screen I need to display X and Y

If I have entered 1,2, and 3 in the selection screen I need to display X

Thanks in advance.

Amit Goyal

2 REPLIES 2

Former Member
0 Kudos

Hi,

First hit against the MAST table with the material number. Then hit against STPO with the internal BOM number to get the components. There are also some function modules that will do this to.

data: xmast type mast.

data: istpo type table of stpo with header line.

Select Single * from mast

where matnr = p_matnr.

If sy-subrc = 0.

Write:/ 'This material has a BOM'.

else.

Write:/ 'No BOM found'.

Endif.

write:/ 'Components'.

select * into corresponding fields of table istpo

from stpo

where stlnr = xmast-stlnr.

loop at istpo.

write:/ istpo-idnrk.

endloop.

Regards

Former Member
0 Kudos

you might try it this way (these are ideas only, not tested code. please use at your own risk)

select-options: sidnrk for stpo-idnrk.

data: compcount type i,

begin of warea,

stlty like stpo-stlty,

stlnr like stpo-stlnr,

count type i,

end of warea.

describe table sidnrk lines compcount.

select stlty stlnr count(*) from stpo into warea

where idnrk in sidnrk

group by stlty stlnr

having count = compcount.

this should get you a list of all stlnr's that have all of the components in them. You can then use warea fields to get materials from MAST. this assumes each component is assigned to any BOM only once, etc...

again, this is just a thought, based on not having anything in front of me right now SAP-Wise to test it out.