2008 May 01 4:54 PM
hi gurus,
i am using the function module
CS_BOM_EXPL_MAT_V2
after using this module
i get an internal table which is filled with various materials with different levels,
levels range from 1 to 25 in in which 1 has hieghest value and 25 least,
the levels are not inorder.
ex:
whenever a lower level appears ie.
after level one if level two comes then the matnr at level 1 is parent and all level 2's become immediate children,
so i should be creating an internal table, which contains pairs of 1 parent and one of its immediate child, so that all teh children immeditatly are covered.
Once this all level 1's are covered, we should start with level 2's.
level 2 becomes parent and immediate level 3's become child, again all teh 2's and 3's make a pair, so that all the threes are covered.
am i clear, if not please let me know,
i donot understand, whetehr to take top-down or bottom up approach.
presently i am thinking this way,
loop at the internal table , whenever a level 1 appears, right away make a pair of curent matnr and matnr with level 1.
i might be getting 4 or 5 pairs.
then reduce all the levels by 1.
so all the level2's become level 1s and level 1s to 0.
again loop around the itab looking for level 0s, once we get a level 0, we store that in a variable v_matnr,
from that point till we get next level 0, we collect all the level 1's.
so all these ( 0's, 1's) make pairs of BOMs.
inthis way after every loop we reduce the levels by 1, till we run out of levels to 0 or negetive.
i know this is worst way of programing, but any ideas friends, any better way of doing this.
rgds.
2008 May 01 6:27 PM
Hi,
thanks for the replies,
Paul,
if i sort returned table with stufe column, how will i get to know , who is whos child.
do u mean sorting by any other column.
i appreciate your help.
Mr. A.
i am trying to understand your logic,
what does wegxx store, it says , path with 4 chars, how does this field help us.
i appreciate your help.
thanks again.
Hi,
thanks for the replies,
Paul,
if i sort returned table with stufe column, how will i get to know , who is whos child.
do u mean sorting by any other column.
i appreciate your help.
Mr. A.
i am trying to understand your logic,
what does wegxx store, it says , path with 4 chars, how does this field help us.
i appreciate your help.
thanks again.
2008 May 01 5:11 PM
friend
u r planning to display the material of level 1 first and material of level 2 and then level 3 am i right??
if you do like this how will you make out which material is the parent of material in level 1 or 2.
thats not the right way to dispaly the material
if u have to dipaly level 1 and then its immediate children and then its immediate children so on
ex original parent 13568
level material
.1 12346 immediate child of 13568
..2 36748 immediate child of 12346
...3 89709 immediate child of 36748
.1 67878 immediate child of 13568
this is the right way to display the material.
u r trying to display
level material
1 12346
1 67878
2 36748
3 89709
think which the best way.....
2008 May 01 5:26 PM
no waht i am trying to fill is
if:
1 has children a,b
b has children x,y,z.
z has children p,q,r.
then
(1, a )
(1, b )
(b, x)
(b, y)
(b, z)
( z, p)
(z, q )
(z, r )
it is something like a tree with pair relations going from root node till leaves.
2008 May 01 5:46 PM
couldn't you simply sort the retuned table (STPOX) by the fields you want ordered?
I would think this would include BOM, LEVEL, etc
2008 May 01 6:04 PM
if u want to print only in that way....
then u can try the as follows....
1. get the highest number in the column stuff of structure stb.
2. construct do loop for highest number times.
3. Construct inner do loop
read the table with stuf with '1' and wegxx with '1'
keep increase the value for wegxx column(dont increase the value of stuf column.
if sy-subrc NE 0.
exit (inner loop)
endif.
now increase the stuf value by one
endloop.
hope this will meet ur requirement..
bye
Edited by: Mr A on May 1, 2008 7:09 PM
2008 May 01 6:27 PM
Hi,
thanks for the replies,
Paul,
if i sort returned table with stufe column, how will i get to know , who is whos child.
do u mean sorting by any other column.
i appreciate your help.
Mr. A.
i am trying to understand your logic,
what does wegxx store, it says , path with 4 chars, how does this field help us.
i appreciate your help.
thanks again.
2008 May 01 7:39 PM
2008 May 01 8:27 PM
the funtion module
csXXX_12...
return the BOM material in one table right???
and this table contains diff fields like stuf and wegxx, idnrk etc.....
let me write the logic for you....
1. find highest number in the table in column stuf. say that number is 3.
data: gv_level type stb-stuf,
gv_next type stb-wegxx.
do 3 times.
do .
read tabel it_stb into wa_stb with key stuf = gv_level
wegxx = gv_next.
if sy-subrc = 0.
..... do ur operations...(like moving etc...)
gv_next = gv_next + 1.
else.
exit.
endif.
enddo.
gv_level = gv_level + 1.
enddo.
i hope with this u will get what u want.
i dont have system to test the program but it should work
bye
Edited by: Mr A on May 1, 2008 9:27 PM
2008 May 01 9:20 PM
Hi Mr.A,
your logic is excellent.
but i have a question,
below is the CS12 output for one material.
first column is level and second level is item
1.....0010
2.....0010
3.....0010
4.....0010
3.....0020
4.....0010
2.....0020
3.....0010
4.....0010
3.....0020
3.....0030
2.....0030
3.....0010
4.....0010
3.....0020
3.....0030
3.....0040
3.....0050
3.....0060
4.....0010
2.....0040
2.....0050
2.....0060
3.....0010
2.....0070
3.....0010
1.....0020
2.....0010
2.....0020
1.....0030
2.....0010
2.....0020
1.....0040
1.....0050
2.....0010
1.....0060
1.....0070
1.....0080
1.....0090
as u said we use a read stmt, it will work fine for all teh level 1's,
it will also work for level 2's as long as it it under the first level 1.
if u notice in the above data, there are multiple occurences of same level 2 and item value 0010,
read stmt will only cathch the first occurence,
do i have to make some changes or am i wrong,
thanks a lot for your effort.
2008 May 01 9:46 PM
1.....0010
wht is the 1 and what is the 0010.?
i dont understand.
in stuf & wegxx fields how come the values is 0010, it should be 1 or 2 or 3 ....
i am talking abt first 2 field of the return table stb in the function module
2008 May 01 10:33 PM
i am sorry, Mr A,
the one i gave above was the display of CS12 tcode, bcos i learnt from this forum that, CS_BOM_EXPL_MAT_V2 was equivalent to that,
but below is the data for a material from first 2 columns, of the stb table
1.....1
2.....1
3.....1
4.....1
3.....2
4.....2
2.....2
3.....3
4..... 3
3.....4
3.....5
2.....3
3.....6
4.....4
3.....7
3.....8
3.....9
3.....10
3.....11
4.....5
2.....4
2.....5
2.....6
3.....12
2 .....7
3.....13
1.....2
2..... 8
2.....9
1.....3
2.....10
2.....11
1.....4
1.....5
2.....12
1.....6
1.....7
1.....8
1.....9
i put the dots , so that, we can see the gap.
the second column ie. wegxx is showing the number of occurences,
but how do we find the parent child relation pair.
bcos when we run the logic what we get is
1....1
1....2
1....3
2....1
2....2
2....3
.
.
.
.
.
.
how will i find those pair.
2008 May 01 10:39 PM
dear
thats what i am saying from the begining, if you display this way how you will have the parent child relationship.
refer to my first reply....
please explain me ur problem clearly so that i can analys and give u correct answer
if you need to send any screen shorts send them to meetganeshamratyahoodotcodotin(replace at with @ and dot with .)
bye
2008 May 01 10:57 PM
actually, my work was that,
my program will be given a set of material numbers,
this program should bring out data as in CS03, that is immediate components of the given materials,
i need to again pass these output material components into CS03 to get their immediate components,
the program has to keep passing as long thaere are no more components for the given materials.
for this purpose we can directly use CS12 tcode,
but
we need a file which has explicit two columns, one for material and one for component.
for the given materials we will put theimmediate components, but again if that component has sub components,
we need to put this component in material column and its sub component innext column.
am i clear.
2008 May 01 11:08 PM
see
What you are doing with CS03.? I dont understand that....
CS03 will display the first level material right.
but with FM module u r getting all level at a time...
still i dont understand ur requirement clearly.....
tell me what u want to acomplish with ur program, dont give any tcodes for reference.
bye
2008 May 01 11:24 PM
yes, exactly, i need to get the first level components of the given material.
place them in two columns,
one is parent column and one is child coumn.
MAT1 COMPONENT1
MAT1 COMPONENT2
MAT1 COMPONENT3
.
.
.
then again, this components have subcomponents,
so for each of those sub components we need first level components.
COMPONENT1 SUBCOMPONENT1
COMPONENT1 SUBCOMPONENT2
left column is parent and right is child.
in this way we keep pasing the components as materials till we get the raw material.
in this process, we make the list what we are passing and what we are getting.
as two seperate columns.
2008 May 02 2:33 PM
2008 May 02 2:50 PM
Hi Sanjana,
You can solve your issue with recursive type of call as shown below:
Loop at int_tab1.
Concatenate matnr to string separated by space.
move tab1-matnr to component.
while sy-subrc = 0.
perform get_next_component using component.
endwhile.
endloop.
form get_next_component.
loop at int_tab1 where matnr = component.
Concatenate matnr to string separated by space.
move tab1-matnr to component. ( Here your matnr suppose to be sub-component)
perform get_next_component using component.
endform.
You can modify this logic to display in a multi-dimensional way.
Srinivasa Rao Varrey
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |