BOM function module to find sub components

Hi all ,
I got a requirement . I have to find out the components required for a given product .Like if A is made up of X,Y and Z . If i have A , a final product , then how could i  know its sub components  X,Y and Z .
Is there any Function module .
Regards ,
Raj

Aparna,
One doubt.Does the function module metioned by you will even explode if a Component under the header material is having a sub-assembly  which again is having some components and those componenets also have sub-assembly so on....
I mean in one shot if we give the header material it should explode all the BOMS of the corresponding components.
We have developed a small program kindly have a look at it.Does this whole program can be replaced by that function module alone?
As we need supply area w.r.t a component under header material we are displaying only those fields in the output.
REPORT ZBOMEXPLOSION.
TABLES: MBEW,
        MARA, "Material Master
        MAKT,
        MARC,
        MAST, "BOM Header
        STKO, "BOM Detail
        STPO, "Bom Components
        STAS. "BOM Alternative
*Declarations for ALV
type-pools slis.
DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA:itrepid TYPE sy-repid.
itrepid = sy-repid.
DATA:itevent TYPE slis_t_event.
DATA:itlistheader TYPE slis_t_listheader.
DATA:walistheader LIKE LINE OF itlistheader.
DATA:itlayout TYPE slis_layout_alv.
DATA:top TYPE slis_formname.
DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA :itsort1 TYPE slis_sortinfo_alv.
DATA:itprintparams TYPE slis_print_alv.
DATA:itvariant TYPE disvariant.
data : title type lvc_title.
field-symbols <fs> type LVC_TITLE.
concatenate 'BOM Explosion level by level' ' ' into title separated by
space.
assign title to <fs>.
DATA:PARENT-MATNR LIKE MAST-MATNR,
CHILD-MATNR LIKE STPO-IDNRK,
CHILD-WERKS LIKE MAST-WERKS,
CHILD-STLAL LIKE MAST-STLAL,
W_MAKTX LIKE MAKT-MAKTX,
W_LEVEL TYPE I,
W_DOT(1),
W_LVL(12),
W_LVL1(12),
W_LVL2(2),
WCNT TYPE I.
DATA: BEGIN OF ITAB OCCURS 100,
CNT TYPE I,
LEVEL TYPE I,
LVL1 LIKE W_LVL1,
WERKS LIKE MAST-WERKS,
POSNR LIKE STPO-POSNR,
IDNRK LIKE STPO-IDNRK,
PRVBE LIKE STPO-PRVBE,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 100,
WERKS LIKE MAST-WERKS,
IDNRK LIKE STPO-IDNRK,
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 100,
CNT TYPE I,
SUBCNT TYPE I,
LEVEL TYPE I,
LVL1 LIKE W_LVL1,
WERKS LIKE MAST-WERKS,
POSNR LIKE STPO-POSNR,
IDNRK LIKE STPO-IDNRK,
prvbe like stpo-prvbe,
SBASE TYPE P,
MAKTX LIKE MAKT-MAKTX,
END OF ITAB2.
PARAMETERS: P_WERKS LIKE MAST-WERKS,
            P_MATNR LIKE MAST-MATNR,
            P_STLNR LIKE MAST-STLNR,
            P_STLAN LIKE MAST-STLAN,
            P_STLAL LIKE MAST-STLAL.
perform zmm.
perform alv.
*&      Form  zmmspt
*       text
*  -->  p1        text
*  <--  p2        text
form zmm .
SELECT * FROM MAST WHERE WERKS = P_WERKS
                     AND MATNR = P_MATNR
                     AND STLNR = P_STLNR
                     AND STLAN = P_STLAN
                     AND STLAL = P_STLAL.
SELECT SINGLE * FROM MARA WHERE MATNR = MAST-MATNR.
IF SY-SUBRC NE 0.
CONTINUE.
ENDIF.
IF MARA-LVORM <> 'X'.
PARENT-MATNR = MAST-MATNR.
CHILD-MATNR = MAST-MATNR.
CHILD-WERKS = MAST-WERKS.
CHILD-STLAL = MAST-STLAL.
CLEAR ITAB.
CLEAR ITAB-LEVEL.
MOVE MAST-WERKS TO ITAB-WERKS.
MOVE MAST-MATNR TO ITAB-IDNRK.
WCNT = WCNT + 1.
MOVE WCNT TO ITAB-CNT.
APPEND ITAB.
W_LEVEL = 1.
PERFORM GETCHILD.
ENDIF.
ENDSELECT.
SORT ITAB BY LEVEL DESCENDING.
LOOP AT ITAB.
PERFORM GET_BOM.
MOVE ITAB-WERKS TO ITAB1-WERKS.
MOVE ITAB-IDNRK TO ITAB1-IDNRK.
APPEND ITAB1.
CLEAR ITAB2.
MOVE-CORRESPONDING ITAB TO ITAB2.
APPEND ITAB2.
ENDLOOP.
SORT ITAB2 BY CNT.
LOOP AT ITAB2.
CLEAR: MAKT-MAKTX.
SELECT SINGLE * FROM MAKT WHERE MATNR = ITAB2-IDNRK AND
SPRAS = 'E'.
SELECT SINGLE * FROM MBEW WHERE MATNR = ITAB2-IDNRK AND
BWKEY = ITAB2-WERKS.
ITAB2-MAKTX = MAKT-MAKTX.
MODIFY ITAB2.
ENDLOOP.
endform.                    " zmm
*&      Form  GETCHILD
*       text
*  -->  p1        text
*  <--  p2        text
form GETCHILD .
SELECT * FROM STPO WHERE STLNR = MAST-STLNR
ORDER BY POSNR.
SELECT SINGLE * FROM STKO WHERE STLNR = STPO-STLNR
AND STLAL = MAST-STLAL.
SELECT SINGLE * FROM STAS WHERE STLNR = STPO-STLNR AND
STLKN = STPO-STLKN AND
STLAL = MAST-STLAL.
IF SY-SUBRC EQ 0.
CLEAR: W_DOT, W_LVL, W_LVL1.
PERFORM MOV_DATA.
CHILD-MATNR = STPO-IDNRK.
W_LEVEL = W_LEVEL + 1.
PERFORM SUBCHILD.
W_LEVEL = W_LEVEL - 1.
ENDIF.
ENDSELECT.
endform.                    " GETCHILD
*&      Form  SUBCHILD
*       text
*  -->  p1        text
*  <--  p2        text
form SUBCHILD .
SELECT SINGLE * FROM MAST WHERE MATNR = CHILD-MATNR
AND WERKS = CHILD-WERKS.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
SELECT * FROM STPO WHERE STLNR = MAST-STLNR
ORDER BY POSNR.
SELECT SINGLE * FROM STKO WHERE STLNR = STPO-STLNR AND
STLAL = MAST-STLAL.
SELECT SINGLE * FROM STAS WHERE STLNR = STPO-STLNR AND
STLKN = STPO-STLKN AND
STLAL = STKO-STLAL.
IF SY-SUBRC EQ 0.
W_DOT = '.'.
PERFORM MOV_DATA.
CHILD-MATNR = STPO-IDNRK.
W_LEVEL = W_LEVEL + 1.
PERFORM SUBCHILD.
W_LEVEL = W_LEVEL - 1.
SHIFT W_LVL.
ENDIF.
ENDSELECT.
endform.                    " SUBCHILD
*&      Form  MOV_DATA
*       text
*  -->  p1        text
*  <--  p2        text
form MOV_DATA .
W_LVL2 = W_LEVEL.
CONCATENATE W_DOT W_LVL INTO W_LVL.
CONCATENATE W_LVL W_LVL2 INTO W_LVL1.
MOVE W_LVL1 TO ITAB-LVL1.
MOVE W_LEVEL TO ITAB-LEVEL.
MOVE MAST-WERKS TO ITAB-WERKS.
MOVE STPO-POSNR TO ITAB-POSNR.
MOVE STPO-IDNRK TO ITAB-IDNRK.
MOVE STPO-PRVBE TO ITAB-PRVBE.
WCNT = WCNT + 1.
ITAB-CNT = WCNT.
APPEND ITAB.
endform.                    " MOV_DATA
*&      Form  GET_BOM
*       text
*  -->  p1        text
*  <--  p2        text
form GET_BOM .
SELECT SINGLE * FROM MAST WHERE MATNR EQ ITAB-IDNRK AND
WERKS = ITAB-WERKS.
IF SY-SUBRC EQ 0.
SELECT * FROM STPO WHERE STLTY = 'M' AND
STLNR = MAST-STLNR AND
DATUV LE SY-DATUM.
SELECT SINGLE * FROM STKO WHERE STLTY = 'M' AND
STLNR = STPO-STLNR AND
STLAL = MAST-STLAL.
SELECT SINGLE * FROM STAS WHERE STLNR = STPO-STLNR AND
STLKN = STPO-STLKN AND
STLAL = STKO-STLAL.
ENDSELECT.
ENDIF.
endform.                    " GET_BOM
*&      Form  alv
*       text
*  -->  p1        text
*  <--  p2        text
form alv .
IF itab2[] IS INITIAL.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
STOP.
ENDIF.
DEFINE m_fieldcat.
    itfieldcat-fieldname = &1.
    itfieldcat-col_pos = &2.
    itfieldcat-seltext_l = &3.
    itfieldcat-do_sum = &4.
    itfieldcat-outputlen = &5.
    append itfieldcat to itfieldcat.
    clear itfieldcat.
  END-OF-DEFINITION.
  m_fieldcat 'LVL1' '' 'Level' '' 04.
  m_fieldcat 'POSNR' '' 'Item' '' 06.
  m_fieldcat 'IDNRK' '' 'Component' '' 18.
  m_fieldcat 'MAKTX' '' 'Description'  '' 40.
  m_fieldcat 'PRVBE' '' 'Supply Area' '' 12.
  itlayout-zebra = 'X'.
  itlayout-colwidth_optimize = 'X'.
  itlayout-no_subtotals = ' '.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
*     I_INTERFACE_CHECK              = ' '
*     I_BYPASSING_BUFFER             =
*     I_BUFFER_ACTIVE                = ' '
     I_CALLBACK_PROGRAM             = sy-repid
*     I_CALLBACK_PF_STATUS_SET       = ' '
*     I_CALLBACK_USER_COMMAND        = ' '
*     I_STRUCTURE_NAME               =
     IS_LAYOUT                      = itlayout
     IT_FIELDCAT                    = itfieldcat[]
*     IT_EXCLUDING                   =
*     IT_SPECIAL_GROUPS              =
     IT_SORT                        = itsort[]
*     IT_FILTER                      =
*     IS_SEL_HIDE                    =
*     I_DEFAULT                      = 'X'
*     I_SAVE                         = ' '
*     IS_VARIANT                     =
*     IT_EVENTS                      =
*     IT_EVENT_EXIT                  =
*     IS_PRINT                       =
*     IS_REPREP_ID                   =
*     I_SCREEN_START_COLUMN          = 0
*     I_SCREEN_START_LINE            = 0
*     I_SCREEN_END_COLUMN            = 0
*     I_SCREEN_END_LINE              = 0
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER        =
*     ES_EXIT_CAUSED_BY_USER         =
    TABLES
      t_outtab                       = itab2
*   EXCEPTIONS
*     PROGRAM_ERROR                  = 1
*     OTHERS                         = 2
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
EXPORT ITAB2 TO MEMORY ID 'KK_ITAB2'.
endform.                    " alv
K.Kiran.

Similar Messages

  • Function Module to find out the release value in contract

    Dear All,
    I have to upload the contract with new accoutn assignment without changing the existing contract. For that i have to download all the existing contract data with value.
    In that case i have some issues regarding the value.
    For example : In the system old contract is created with value 1000 and the released value as 500.
    In that case i have to uload the new contract with all the details of existing contract with value of 500 (1000-500=500).
    How can i get the value (500) and from which table.Is there any functional module to find out the release value in contract.
    Thanks and regads,
    PM
    Edited by: PM on Jan 21, 2010 8:40 AM
    Edited by: PM on Jan 22, 2010 9:48 AM

    Hi
    You need to link the table VBFA and VBAK.
    For a contract you can check all the subsequent document (which you can filter whether you want to see Order / delivery / Billing) in VBFA and then from there pick the subsequent document no. and then from VBAK you can pick the Net value of these subsequent documents, and so you will have both the values (value of Contract and value in subsequent document) and you can determine the balance value.
    Regards
    Amitesh Anand

  • Function Module to find out detail of open period of Finance (FI)

    Hi  All,
    I have a query that I want to know the existing function module to find out
    FI period detail thatis detail of opened period in FI.
    Regards,
    Rishi

    Hi Rishi
    Go to transaction SE37 and you can see the list of FM.
    Thanks
    Ashok
    Assign points for useful answer

  • Function module to find the Credit limit of a Customer based on Credit Area

    hi Experts,
                       Is there any function module to find the Credit limit of a Customer based on Credit Area.
    Regards,
    Dheepak

    hi
    try this:
      select single * from KNKK INTO zzKNKK
          where KUNNR = xkunnr and KKBER = xkkber.
    credit limit: zzKNKK-KLIMK...
    regards,darek

  • Function Module to find date by passign the Planning Calendar

    Hi All,
    Can you tell me is there any function Module to find date by passign the Planning Calendar?
    The requirement is i have a planning calender assigned to the Material in the MRP2 view.
    Example: Material XXXXXX is assigned a Planning Calendar Z01.
    Z01 is defined such that Delivery is on Monday only. This calendar says that the material is received from the Vendor only on Mondays.
    So whenever i punch a Sales Order for Material XXXXXX, a PR is automatically geenrated when saving the sales order and the calculation of Delivery dates is also happening at this level.
    Basing on this PR a PO is raised to a Vendor for procuring the Material XXXXXX, now my problem is for example the PO is raised today (30.04.2008), but the Materail XXXXXX is available only on next monday in my plant (05.05.2008) basing on my Planning Calendar assigned in the Materail Master, so i have to inform this dealy to my customer at the time of punching the sales order.
    So is there any function Module to find date by passign the Planning Calendar?
    Thanks for your valuable inputs.
    Regards,
    Sudarshan

    Hi Jorge,
    Thanks for your reply.
    I am unable to open the Function module which you have mentioned below.
    I am working on 4.6 c version of SAP.
    Any ways i have found one function module which is useful to my requirement as stated below:
    DATE_GET_PERIOD
    Thanks and Regards,
    Sudarshan

  • Table Name or Function Module to find out all the Screens & Subscreens for

    Hello Experts,
          Table Name or Function Module to find out all the Screens & Subscreens for all T-Codes
    Helpful Answer will b rewarded
    Arif Shaik

    Hi Balaji,
       But TSTC only Gives the Program Name , T-Code and Screen but not all the Subscreen details
    Any other which U know

  • Function Module to find the Difference between two times.

    Hi All,
    Wud you plz let me know the Function Module to find the Difference between two times.
    Input Time1( Hours:Minutes) Time2 ( Hours:Minutes)
    Need Output in Hours:Minutes only . ( No seconds Needed )
    Ex :
    Input :
           06:00 to 18:00 Output : 12:00
    and  20:00 to 06:00 Output: 10:00 with +ve sign only. No -ve sign.
    Thanks,
    N.L.Narayana

    check this .
    data : p_timel like sy-uzeit,
           p_timeh like sy-uzeit,
           diff like sy-uzeit,
           di(8) type c .
           p_timel = '200000'.
           p_timeh = '060000'.
           diff = p_timeh - p_timel.
           concatenate diff+0(2) ':' diff+2(2) into di.
           write:/ di.
    also check for this.
           p_timel = '060000'.
           p_timeh = '180000'.
    see if this can be implemented in ur code .
    or else  u can try with  Fm L_TO_TIME_DIFF passing startdate enddate starttime endtime with UOM as MIN
    hope this helps regards,
    vijay

  • Function Module to find the Diff bt Two Times : O/p : Hours:Minutes only

    Hi All,
    Wud you plz let me know the Function Module to find the Difference between two times.
    Input Time1( Hours:Minutes:Seconds) Time2 ( Hours:Minutes:Seconds)
    Need Output in Hours:Minutes only .  ( No seconds Needed )
    Thanks,
    N.L.Narayana

    Hi
    Please use FM
    <b>SD_DATETIME_DIFFERENCE</b>

  • Function module to find both sold and ship to party

    Is there any function module to find both sold-to-party and ship-to-party based on the sales Area.
    That is if i give sales org , distribution channel , division as input . I must get Sold-to-party and Ship-to-party as output.
    Regards,
    S.Velsankar

    Hi,
    You can find sold to and ship to party customer from KNVP Table as below:-
    SELECT      KUNNR
    FROM KNVP
    INTO w_sold_to_party
    WHERE VKORG = YOUR SALES ORG
    AND     VTWEG = dist channel
    AND    SPART = division
    AND    PARVW = 'SP'.                        "Sold to party depneds of how its configured in your system
    Check TPAR table for description Sold to part and pass the PARVW value.
    Similarly for ship to party
    SELECT      KUNNR
    FROM KNVP
    INTO w_sold_to_party
    WHERE VKORG = YOUR SALES ORG
    AND     VTWEG = dist channel
    AND    SPART = division
    AND    PARVW = 'SH'.                        "Sold to party depneds of how its configured in your system
    Regards,
    Subhashini

  • Function module to find time difference

    Can any body help me to find the function module to find the time diff: between two times, time is in 24hrs

    Hi again,
    1. Difference is always returned in SECONDS.
    2. use this code (just copy paste in new program)
    REPORT abc.
    data : t1 type sy-uzeit.
    data : t2 type sy-uzeit.
    DATA : DIFF TYPE I.
    t1 = '090000'.
    t2 = '100000'.
    DIFF = T2 - T1.
    WRITE :/ DIFF.
    regards,
    amit m.

  • Function module to get Structure components

    Hi friends,
    is there a function module to get structure components,if we give a structure name.
    regards
    kaushik

    Sample program using the function module.
    report zrich_0003.
    types: begin of type_item,
           f1(3),
           f2(3),
           f3(3),
           f4(3),
           end of type_item.
    types: begin of type_data,
           data(800),
           end of type_data.
    data:  lineitems type table of type_item with header line,
           t_output type table of type_data with header line,
           fieldlist type table of rstrucinfo with header line,
           fieldsym  type table of rfieldlist with header line.
    data:  syrepid type sy-repid.
    data:  fieldname like fieldlist-compname,
           data_line type type_data.
    field-symbols : <fs1> type any,
                    <fs2> type any.
    lineitems-f1 = 'a1'.
    lineitems-f2 = 'a2'.
    lineitems-f3 = 'a3'.
    lineitems-f4 = 'a4'.
    append lineitems.
    lineitems-f1 = 'b1'.
    lineitems-f2 = 'b2'.
    lineitems-f3 = 'b3'.
    lineitems-f4 = 'b4'.
    append lineitems.
    lineitems-f1 = 'c1'.
    lineitems-f2 = 'c2'.
    lineitems-f3 = 'c3'.
    lineitems-f4 = 'c4'.
    append lineitems.
    lineitems-f1 = 'd1'.
    lineitems-f2 = 'd2'.
    lineitems-f3 = 'd3'.
    lineitems-f4 = 'd4'.
    append lineitems.
    syrepid = sy-repid.
    * Gets all of the global data types.
    call function 'GET_GLOBAL_SYMBOLS'
         exporting
              program   = syrepid
         tables
              fieldlist = fieldsym.
    * gets all of the components of a structure
    call function 'GET_COMPONENT_LIST'
         exporting
              program    = syrepid
              fieldname  = 'lineitems'
         tables
              components = fieldlist.
    format color 3.
    loop at lineitems assigning <fs2> .
      loop at fieldlist.
        fieldname = fieldlist-compname .
        assign component  fieldname  of structure <fs2> to <fs1>.
        concatenate data_line <fs1> into data_line .
      endloop.
      append data_line to t_output.
      clear data_line.
    endloop.
    loop at t_output.
      write:/ t_output.
    endloop.
    Regards,
    Rich Heilman

  • Function Module to find Fully Invoice PO

    Hi all,
           Is there any function module to find Fully Invoice PO?
           Or
          Tell me the tables from where can i get the details of Fully Invoiced PO?

    Hi,
       My requirement is like this.
    I have a company code on selection screen.
    I have to take PO's based on company code.
    Then I need to check whether that PO is fully invoiced or not.
    Initial i was checking EKKO table. But I found that is not the correct table to find out.

  • QM : is there any function module to find inspection lot characterstics

    Hi All,
            is there any function module to find all characterstics for an inspection lot.
    i need exact data which qe51n transaction is fetching .
    thanks in adv ,
    Varma

    Hi uvs,
    1. we can use the fm BAPI_INSPOPER_GETCHAR.
    regards,
    amit m.

  • Function module to find category Guid

    Hi all,
    I need a Function Module to find the 'Category Guid' using 'Category Id' and 'Logical System Name', from table 'COMM_CATEGORY', to update category Guid in the database table ZSRM_BBP_DET_ACC. Please Help.
    Regards,
    Abhinay.

    Hello,
    In SRM7.0 release, you have BBP_CATEGORY_GET_GUID function module.
    Regards.
    Laurent.

  • Function module to find out DATA BASE size, free space, used size

    Is there any function module to find out DATA BASE , free space, used size
    FM that gives all the details of the Date base
    what data base, what is the size, free space, used space etc...
    instead of writing case by case for each data base. based on  CASE SY-DBSYS.

    Hi,
    Check this FM:
    DB02_ORA_SELECT_DBA_SEGMENT
    alternatively u can check the tcode: DB02
    thanks|
    Mahesh

Maybe you are looking for

  • I have just downloaded itunes. I cannot install QT as an older version is in place. Cannot remove the older version using CP. Any ideas?

    I have just downloaded itunes. I cannot install QT as an older version is in place. Cannot remove the older version using CP. Any ideas?

  • Reg Mapping KANBAN - safety stock

    Hi This is Regarding KANBAN Business scenario: Container will have safety stock maintained, Procurement will trigger only when stock in container goes below safety stock. not when container is empty. We dont want system to calculate KANBAN quantity P

  • How can I get my keyboard to show up when searching?

    When im on youtube i go into the search engine for a song. My keyboard doesnt show up when i hit search. I go to google and my keyboard shows. I search google.com ,and i try and log in.The keyboard doesnt show. Ive tried restarting my ipod , but its

  • String.trim() problem.

    Hi I have an ascii file that I parse, the first like is " hello there " When I do a trim() on the String. It returns: " hello there " If I do: Character.isSpaceChar(str.charAt(0)) It returns true. If I go into into the file using a text editor and de

  • VERY SLOW charging

    hello, my z10 is very slow charge since last week. I try to reset to factory (in BBLink), Security Wipe, and battery pull, but it's not work . It take 10 mins per 1%, HELP ME PLEASE PS. current OS 10.2.1.2102