cancel
Showing results for 
Search instead for 
Did you mean: 

BOM - Function Module

Former Member
0 Kudos

Hi,

Any function module available to find grand parent (Top most material) for a given child (Material)?

Example.

-A

--B

---C

-


D

I will input Material "D" and I should get Material "A".

Advance thanks.

Regards,

V Balaji.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Did you check transaction CS15? This transaction will give you the where-used list for a given material and there are several selections to choose from and levels to choose from. Will this not suffice your requirement? If not, check this program and see if you can find a piece of logic or function module that you can use.

Former Member
0 Kudos

Hi Balaji,

Did you try the function module "CS_BOM_EXPL_PSP_V1", hope this solve your problem, here we have to create two internal tables with the structures "CSCMAT" and "STPOX".

After executing the FM you will find two tables, the one which you need is stb-idnrk(this is the Material no), here you will get all the levels for your Top level material no.

Hope this will solve your problem, still you didn't solve contact me.OK

Shivaram

Former Member
0 Kudos

Material field (Component) is in STB-IDNRK.

Former Member
0 Kudos

hi,

i have to get a ouput like the one u get for bom explosion cs12,,my input contains material and change number,,i used the fucntion 'CS_BOM_EXPL_MAT_V2',,i am getting the levels but how can i get the corresponding material components,,the structure it uses is stpox whixh doesn't have matnr field,,,

the output is like

1 first component

-2 sub component

--3 sub component for 2

-2 sub component and so on

reg

sorabh

Former Member
0 Kudos

I HAVE THE SAME REQUIREMENT AS CS12 I M USING 'CS_BOM_EXPL_MAT_V2' FM FOR THE MATERIAL BOM BUT I M NOT GETTING THE COMPONENETS LIST ONLY HEADER DATA IS COMING. AS DSTST PARAMETER IS DISPLAYING 'X' MEANS STRUCTURE IS DESTROY BY THE FILLTER. PLEASE GUIDE ME ABT THE SAME AS IT IS URGENT.

REGARDS

NILESH SHETE

VXLozano
Active Contributor
0 Kudos

Please, a message in full caps is hard to read, and normally means that you are shouting us... try to edit it and put in normal text and/or don't (ab)use caps again

Former Member
0 Kudos

Your problem might have got resolved by now but did you try out function module CS_BOM_EXPL_MAT_V2

Madhavan

Former Member
0 Kudos

There is no standard Function Module available in SAP for it. You'll have to develop your own function module.

You may refer following code. You won't be able to use this as it is. You need to change it. This function module assumes that any top most product name always contains 11 chars.

FUNCTION Z_PICK_TOP_PRODUCT.

*"----


""Local interface:

*" IMPORTING

*" VALUE(P_IDNRK) LIKE STPO-IDNRK

*" TABLES

*" ASSY_TAB STRUCTURE ZASSYTAB

*" EXCEPTIONS

*" NO_PRODUCT_FOUND

*"----


TABLES : MAST ,

STPO,

STKO.

DATA : M_ASSYFLAG(1) .

**PICK FIRST LEVEL **

PERFORM PICK_NEXT_LEVEL_ASSY USING P_IDNRK.

PERFORM PICK_PRODUCT TABLES ASSY_TAB.

DESCRIBE TABLE COMP_TABT LINES M_CNT.

IF M_CNT = 0 .

PERFORM PICK_ORGUNIT TABLES ASSY_TAB.

LOOP AT ASSY_TAB.

WRITE : / ASSY_TAB.

ENDLOOP.

EXIT.

ENDIF.

**END PICK FIRST LEVEL **

**PICK OTHER HIGHER LEVELS **

DO 30 TIMES.

CLEAR M_CNT.

DESCRIBE TABLE COMP_TABT LINES M_CNT.

IF M_CNT = 0 . EXIT.ENDIF.

COMP_TAB[] = COMP_TABT[] .

REFRESH COMP_TABT.CLEAR COMP_TABT.

LOOP AT COMP_TAB.

PERFORM PICK_NEXT_LEVEL_ASSY USING COMP_TAB-IDNRK.

PERFORM PICK_PRODUCT TABLES ASSY_TAB.

ENDLOOP.

REFRESH COMP_TAB.CLEAR COMP_TAB.

ENDDO.

PERFORM PICK_ORGUNIT TABLES ASSY_TAB.

LOOP AT ASSY_TAB.

WRITE : / ASSY_TAB.

ENDLOOP.

ENDFUNCTION.

FORM PICK_NEXT_LEVEL_ASSY USING FMATNR LIKE MAST-MATNR.

CALL FUNCTION 'CS_WHERE_USED_MAT'

EXPORTING

DATUB = '00000000'

DATUV = '00000000'

MATNR = FMATNR

  • POSTP = ' '

  • RETCODE_ONLY = ' '

STLAN = '2'

  • WERKS = ' '

  • IMPORTING

  • TOPMAT =

TABLES

WULTB = POV_TAB

EQUICAT = EQU_TAB

KNDCAT = KND_TAB

MATCAT = MAT_TAB

STDCAT = STD_TAB

TPLCAT = TPL_TAB

EXCEPTIONS

CALL_INVALID = 1

MATERIAL_NOT_FOUND = 2

NO_WHERE_USED_REC_FOUND = 3

NO_WHERE_USED_REC_SELECTED = 4

NO_WHERE_USED_REC_VALID = 5

OTHERS = 6.

IF SY-SUBRC <> 0 . CLEAR POV_TAB. REFRESH POV_TAB . ENDIF.

ENDFORM.

FORM PICK_PRODUCT TABLES ASSY_TAB LIKE G_ASSY_TAB[].

LOOP AT POV_TAB.

M_STRLEN = STRLEN( POV_TAB-MATNR ) .

IF M_STRLEN = 11 . " IF PRODUCT THEN MOVE PRODUCT NO TO ASSY_TAB

MOVE POV_TAB-MATNR TO ASSY_TAB-MATNR.

COLLECT ASSY_TAB. "APPEND ONLY UNIQUE RECORDS

ELSE.

*break-point.

MOVE POV_TAB-MATNR TO COMP_TABT-IDNRK .COLLECT COMP_TABT.

ENDIF.

ENDLOOP.

ENDFORM.

FORM PICK_ORGUNIT TABLES ASSY_TAB LIKE G_ASSY_TAB[].

LOOP AT ASSY_TAB.

SELECT SINGLE * FROM MAST WHERE MATNR = ASSY_TAB-MATNR

AND STLAN = '2'.

SELECT SINGLE * FROM STKO WHERE STLNR = MAST-STLNR

AND STLAL = MAST-STLAL

AND STLTY = 'M'.

IF SY-SUBRC = 0.

ASSY_TAB-ORGUNIT = STKO-ZOBJID.

MODIFY ASSY_TAB.

ENDIF.

ENDLOOP.

ENDFORM.

Former Member
0 Kudos

Try with fm "CSAP_MAT_BOM_READ".

Gianluca