Skip to Content
author's profile photo Former Member
Former Member

BOM - Function Module

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2004 at 02:28 PM

    Try with fm "CSAP_MAT_BOM_READ".

    Gianluca

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2004 at 09:56 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2004 at 10:08 AM

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

    Madhavan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2004 at 07:41 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 17, 2004 at 11:26 PM

    Material field (Component) is in STB-IDNRK.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 18, 2004 at 12:04 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 23, 2004 at 08:29 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.