Logic to fetch BOM

Hi,
The reqmt in a report to fetch the PO , header material, component and calculate the theoritical value Zthe_value (fetching the value form RSEB-ENMNG).
Fetching PO -EBELN and EBELP currently-
select single * from resb
      where ebeln = t_result2-ebeln and
            ebelp = t_result2-ebelp.
      if sy-subrc = 0.
        t_result2-enmng   = resb-bdmng.
        t_result2-meins   = resb-meins.
endif.
But now we want to change the logic to fetch the theoritical value as mentioned below.
By taking into consederation EBELN and EBELP how to add below logic.
Search in MAST table for given header material (MAST-MATNR) against Plant (MAST-WERKS) to take stlnr field no.(BOM no)
In STPO table with the same BOM no.(STPO-STLNR) check for component (STPO-IDNRK)
If BOM is not there for the component which is there in the Purchasing Order then leave field theoritical value as blank and if BOM is there then calculate theoritical value.
Pls provide code snippet.
Thanks

Hi,
You can use the following FM's do get the Material BOM details.
1 ) CS_BOM_EXPL_MAT_V2
2) CS_BOM_EXPLOSION
For Example
  LOOP AT i_afpo INTO wa_afpo.
    CLEAR : lv_tar_qty.
   lv_tar_qty = ( wa_afpo-wemng * wa_afpo-umrez ) / wa_afpo-umren.
    lv_tar_qty = ( wa_afpo-psmng * wa_afpo-umrez ) / wa_afpo-umren.
    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
      EXPORTING
        aufsw                 = ' '
        capid                 = 'PI01'
        datuv                 = wa_afpo-sdatv
        ehndl                 = '1'
        emeng                 = lv_tar_qty
        mbwls                 = ' '
        mtnrv                 = wa_afpo-matnr
        mehrs                 = 'X'
        mmory                 = '1'
        stlal                 = wa_afpo-stlal
        werks                 = wa_afpo-dwerk
        aumgb                 = 'X'
      TABLES
        stb                   = lt_stb
        matcat                = lt_mat
      EXCEPTIONS
        material_not_found    = 4
        no_plant_data         = 8
        no_bom_found          = 12
        no_suitable_bom_found = 16
        alt_not_found         = 24
        missing_authorization = 28
        conversion_error      = 36.
    DELETE lt_stb WHERE stufe NE 1.
    LOOP AT lt_stb INTO lw_stb.
      MOVE-CORRESPONDING lw_stb TO w_stb.
      MOVE : wa_afpo-matnr TO w_stb-plnbez,
             wa_afpo-aufnr TO w_stb-aufnr,
             wa_afpo-rsnum TO w_stb-rsnum.
      APPEND w_stb TO i_stb.
      CLEAR : w_stb.
    ENDLOOP.
    FREE : lt_stb, lt_mat.
  ENDLOOP.

Similar Messages

  • Abap logic not fetching multiple rows from master data table

    Hi
    I just noticed that my logic is fetching only 1 row from master data table.
    ProdHier table
    PRODHIERACHY            Level
    1000                                  1
    1000011000                      2
    10000110003333              3
    10000110004444              3
    '10000110005555              3*
    logic only fetches one row of level 3, I would like to fetch all level 3 rows.
    DATA: ITAB type table of /BI0/PPROD_HIER,
          wa like line of ITAB.
    Select * from /BI0/PPROD_HIER INTO wa where /BIC/ZPRODHTAS = 3.
    IF wa-PROD_HIER(10) = SOURCE_FIELDS-PRODH2.
         RESULT = wa-PROD_HIER.
         ELSEIF wa-PROD_HIER(5) = SOURCE_FIELDS-PRODH1.
         RESULT = wa-PROD_HIER.
    ENDIF.
    ENDSELECT.
    thanks

    Hi,,
    I have implemented the logic in end routine and it still reads only the first row.
    I am loading only PRODH1 and PROD2 but now I want to get all values of PRODH3 from the master data table.
    The first 5 values are PRODH1 and first 10 values belongs to PRODH2.
    Whenever PRODH2 = 1000011000 in source I should get the following values
    10000110001110
    10000110001120
    10000110001130
    I have multiple rows of 1000011000 so my result should be
      1000011000               10000110001110
      1000011000               10000110001120
      1000011000               10000110001130
    DATA: ITAB type table of /BI0/PPROD_HIER,
    wa like line of ITAB.
    data rp type _ty_s_TG_1.
    Select  * from /BI0/PPROD_HIER INTO table itab where /BIC/ZPRODHTAS = 3.
    LOOP AT RESULT_PACKAGE INTO rp.
    read table itab into wa with key PROD_HIER(5) = rp-PRODH1.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
         ELSE.
    read table itab into wa with key PROD_HIER(10) = rp-PRODH2.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    Edited by: Bhat Vaidya on Sep 10, 2010 11:27 AM
    Edited by: Bhat Vaidya on Sep 10, 2010 11:37 AM

  • Logical database fetching datas

    Hi,
                  I  am using RFBPET00  standard program,in that fieldname name1 values are not coming.
    For that if bseg-koart = 'K' i need to fetch values from LFA1 and I have to insert values in the detail list.
    I need to move values to gs_alv_output_detail-name1.
    I have used the following code.
    get lfa1.
    check lfa1-lifnr = dkonto.     
    *******This is the place where all gs_alv_output_detail are appended.
    if bseg-koart = 'K'.
    move : lfa1-name1 to gs_alv_output_detail-name.
    endif.
    Start Of Insertion by C5053612
      APPEND gs_alv_output_detail TO gt_alv_output_detail.
      clear gs_alv_output_detail.
    while I executing the program I am getting the values
    for name1 where 'K' is there.
    How to fetch datas from logical database and map it there.
    Regards,
    Bathri

    Hi Harsh,
    Thanks for your reply.
           I tried this.
                  move : lfa1-name1(30)  to gs_alv_output_detail-name.
    But still I am getting ########### for name.
    I have one doubt.
    get lfa1.
    check lfa1-lifnr = dkonto.        
    After this whether I need to pass any values for name.
    Regards,
    Bathri.

  • What is Exact logic to get BOM ITEM

    Hi all,
    BOm Item retrival logic is giving item ,But checked in CS03 there is no BOM ITEM present for that material and plant combination.
    Tried with FM 'CSAP_MAT_BOM_ITEM_SELECT 'and BAPI ' CSAP_MAT_BOM_READ'  to get Material BOM ITEM...Its working perfect and not giving any Item.....its correct output.
    But I dont want to use BAPI and FM.
    Please let me know anyone...what is Exact logic to get ITEM.
    My logic involves MAST -> STKO -> STAS -> STPO.
    Edited by: amit soni on Aug 26, 2011 11:15 AM

    Not pretty sure what you need.  My guess is that you want to know the link between the table related to BOM master and for some reason don't want to use the FM or BAPI.
    MAST  ->  Matnr (mat), werks (plant), stlan (bom usage), stlal (alt.bom #), you will get the stlnr (internal bom number).  Note that if you have multiple BOM, you will get the same alt bom#.
    STKO -> Use stlty (BOM Category = M Material), stlnr (BOM#), stlal (alt BOM#), you get the BOM header.
    STAS -> stlty (BOM Category = M Material), stlnr (BOM#), stlal (Alt BOM#), you get the STLKN ( item node)
    STPO -> stlty (BOM Category = M Material), stlnr (BOM#), stlkn (item node), you get the right item from the BOM header specified.
    Hope this is what you want.

  • Logic to fetch multiple records from BKPF, SRGBTBREL and SOOD

    Hi All
    Need help in developing a login for a report.
    We are trying to display records of a/c documents which have an associated note with them. This involves 4 categories.
    1)     My Document, I attached the note.
    2)     My Document, someone else attached the note.
    3)     No note attached.
    4)     All.
    The logic desired is as below:
    1)     BKPF-BUKRS + BKPF-BELNR + BKPF-GJAHR = SRGBTBREL-INSTID_A. (SRGBTBREL can have multiple records for this combination if multiple notes attached)
    2)     a) SOOD-OBJTY = SRGBTBREL-INSTID_B+17(3).
    b) SOOD-OBJYR = SRGBTBREL-INSTID_B+20(2).
    c) SOOD-OBJNO = SRGBTBREL-INSTID_B+22(12).
    Unique combination.
    I have fetched the details from the three database tables but finding it challenging to put it across in one output internal table. It doesnu2019t cover the scenario where multiple notes are attached to the document (One can be from the same person who created the document and another ones can be from different person or both from the different people).
    Thanks in advance,
    Harsh

    Code Snippet Part 2.
    * Approved Document.
        IF rb_app = 'X'.
          CLEAR wa_sood.
    *      READ TABLE gt_sood INTO wa_sood WITH KEY objtp = lv_objtp
    *                                               objyr = lv_objyr
    *                                               objno = lv_objno.
          LOOP AT gt_sood INTO wa_sood WHERE objtp = lv_objtp
                                         and objyr = lv_objyr
                                         and objno = lv_objno.
    *      IF sy-subrc = 0.
            IF wa_bkpf-usnam <> wa_sood-cronam.
    * Company Code.
              wa_output-bukrs = wa_bkpf-bukrs.
    * A/c Document No.
              wa_output-belnr = wa_bkpf-belnr.
    * Fiscal Year.
              wa_output-gjahr = wa_bkpf-gjahr.
    * Document Type.
              wa_output-blart = wa_bkpf-blart.
    * Document Date.
              wa_output-budat = wa_bkpf-budat.
    * Day On Which Accounting Document Was Entered.
              wa_output-cpudt = wa_bkpf-cpudt.
    * User name.
              wa_output-usnam = wa_bkpf-usnam.
    * Reverse Document Number.
              wa_output-stblg = wa_bkpf-stblg.
    * Transaction Code.
              wa_output-tcode = wa_bkpf-tcode.
    * Short description of contents.
              wa_output-objdes = wa_sood-objdes.
    * Creator Name.
              wa_output-cronam = wa_sood-cronam.
    * Date created.
              wa_output-crdat = wa_sood-crdat.
    * Time created.
              wa_output-crtim = wa_sood-crtim.
    * Status.
              WRITE icon_green_light TO wa_output-light.
              APPEND wa_output TO gt_output.
    *          CLEAR: wa_output,
    *                 wa_sood.
    *        ENDIF.
          ENDIF.
                   ENDLOOP.
        ENDIF.
    * All Documents.
        IF rb_all = 'X'.
    * Company Code.
          wa_output-bukrs = wa_bkpf-bukrs.
    * A/c Document No.
          wa_output-belnr = wa_bkpf-belnr.
    * Fiscal Year.
          wa_output-gjahr = wa_bkpf-gjahr.
    * Document Type.
          wa_output-blart = wa_bkpf-blart.
    * Document Date.
          wa_output-budat = wa_bkpf-budat.
    * Day On Which Accounting Document Was Entered.
          wa_output-cpudt = wa_bkpf-cpudt.
    * User name.
          wa_output-usnam = wa_bkpf-usnam.
    * Reverse Document Number.
          wa_output-stblg = wa_bkpf-stblg.
    * Transaction Code.
          wa_output-tcode = wa_bkpf-tcode.
          CLEAR wa_sood.
    *      READ TABLE gt_sood INTO wa_sood WITH KEY objtp = lv_objtp
    *                                               objyr = lv_objyr
    *                                               objno = lv_objno.
          LOOP AT gt_sood INTO wa_sood WHERE objtp = lv_objtp
                                         and objyr = lv_objyr
                                         and objno = lv_objno.
    *      ELSE.
            IF wa_bkpf-usnam <> wa_sood-cronam.
    * Status.
              WRITE icon_green_light TO wa_output-light.
    * Short description of contents.
              wa_output-objdes = wa_sood-objdes.
    * Creator Name.
              wa_output-cronam = wa_sood-cronam.
    * Date created.
              wa_output-crdat = wa_sood-crdat.
    * Time created.
              wa_output-crtim = wa_sood-crtim.
            ELSE.
    * Status.
              WRITE icon_yellow_light TO wa_output-light.
    * Short description of contents.
              wa_output-objdes = wa_sood-objdes.
    * Creator Name.
              wa_output-cronam = wa_sood-cronam.
    * Date created.
              wa_output-crdat = wa_sood-crdat.
    * Time created.
              wa_output-crtim = wa_sood-crtim.
            ENDIF.
    *      ENDIF.
          ENDLOOP.
          IF sy-subrc <> 0.
            WRITE icon_red_light TO wa_output-light.
          ENDIF.
          APPEND wa_output TO gt_output.
    *      CLEAR: wa_output,
    *             wa_sood.
        ENDIF.
      ENDLOOP.

  • PO Based Voucher - Logic to fetch Material Documents

    Hi all,
    I m n abaper.
    I am Printing Documents from RSEG(Invoice Receipt) in a PO Based Voucher printout.
    In RSEG we have a Reference Document No field - LFBNR which captures Material Documents (MKPF) or Service Entries. I have no problem when this field is not blank as i can get all the relevant Material Docs.
    When this Field RSEG - LFBNR is not Updated(in case of Freight cost) then how do i get the Material Documents pertaining to a particular RSEG-BELNR.
    To solve this i am going PO based , ie, i am fetching all Material Documnets for a RSEG-EBELN and RSEG-EBELP from MSEG . But I currently have no logic to filter this List of Material Documents to those only pertaining to a particular RSEG-BELNR.
    Please help....
    Thanks..

    Hi Prabhu,
    Thanks a lot for all your inputs.
    This is not a G/L or Mat based Invoice.
    This invoice in for Freight Cost.
    In MIRO/MIR7 when we POST/PARK an invoice for "Goods/service Items" the RSEG-LFBNR field is updated with the Material Doc/ Service entry no. But in case of "Planned Delivery Cost"' this RSEG-LFBNR field is blank. Problem i am facing can be explained with an example.
    I have a PO with 1000 Qty.
    I do partial Goods Receipts of 150, 200, 300. In total I did GR for 650 Qty.
    Now i go to MIRO/MIR7 enter the PO then i get all the 3 GR's . I select all 3 GR's and post.
    In invoice this is updated as one line item with 650 Qty and total freight cost.
    In my program i am getting all these Material Docs by passing the PO No and PO item.
    But problem comes when i again do GR for the rest of the Qty ( 1000 - 650 = 350 ). This GR is also coming in the output. For this logic in my program fails.
    Since in invoice(RSEG) there comes only 1 item for a PO No and PO Item i do not know the breakup of 650 Qty and my output is wrong.  
    - Azizur

  • Logic for fetching Quantity Delivered and Invoiced

    I am creating a Sales Order report in which I need to Fetch the delivered Quantity and Invoiced Quantity fields.
    I am currently going to VBFA table and pass SO and line item number and fetch all data. Then I perform addition/ subtraction to remove cancelled quantities.  this is making the logic complicated.
    Is there any standard Function module/ or table or BAPI which can fetch the Delivered and Invoiced quantities directly?
    Regards,
    Onkar Borkar

    Hi Experts,
    There is a  requirement where in it is required to track changes in the field 'Batch' in the deliveries. This change log report should have the option of checking the log for multiple deliveires at a time. It can be similar to the delivery change log report that we have but shoul run for multiple deliveries at a time.
    Please let me know if such a reporet is available in standard SAP or in LIS repporting.
    Thanks/ Regards,
    Onkar

  • Logic to fetch delivered and invoiced Qty using sales order and line no

    Hi Experts,
    I am creating a Sales Order report in which I need to Fetch the delivered Quantity and Invoiced Quantity fields.
    I am currently going to VBFA table and pass SO and line item number and fetch all data. Then I perform addition/ subtraction to remove cancelled quantities. this is making the logic complicated.
    Is there any standard Function module/ or table or BAPI which can fetch the Delivered and Invoiced quantities directly?
    Regards,
    Onkar B

    Hi,
    First pass the sales order number into "VBFA" table into the field "VBELV".
    Execute or Press F8.
    Get the document number of the delivery from "VBELN".
    Pass the same delivery document numebr into "LIPS" table into the field "VBELN".
    Execute.
    Get the value of the delivery quantity from the field "LFIMG" in this table.
    Next got the table "VBFA".
    Pass the delivery document number into the field "VBELV".
    Execute or Press F8.
    Get the document number of the billing document from "VBELN".
    Pass the same billing document numebr into "VBRP" table into the field "VBELN".
    Execute.
    Get the value of the invoiced quantity from the field "FKIMG" in this table.
    Like this we have to get the delivery and invoice quantities.
    Regards,
    Krishna.

  • Want to chnage the logic for ck40n bom valuation mixed costing ?

    Dear Gurus,
    In ck40n transaction,material bom valuation is depnding on mixed ratio.
    My requirement is to change the logic,Iam debugging the ck40n transaction for costing,but iam unable to getting the right position to change the logic for mixed costing (average).
    Thanks in advance,
    CR

    In solution 1, I had a procurement alternative and mixing ration in plant 200 and a special procurement type for costing in plant 210.
    Before calculating the mixed costing in plant 200 I had to eliminate the spec.proc.type for costing in plant 210 otherwise, the calculation got into a loop.
    Without the spc.proc.type in plant 210, I got a correct mixed costing in plant 200.
    Then I enter the spec.proc. type for costing again in plant 210 and calculate the cost price. This copies the mixed costing from plant 200. So far, OK.
    But as soon as I save this cost estimate in plant 210, the reports in CK11N or CK13N get incorrect for the first calculation made for plant 0210 while costing in plant 0200 is overwritten by this result. Now the report gets into a loop and you can drill down endlessly.

  • Want to change logic for  ck40n bom valuation for mixed costing ?

    Dear Gurus,
    In ck40n transaction,material bom valuation is depnding on mixed ratio.
    My requirement is to change the logic,Iam debugging the ck40n transaction for costing,but iam unable to getting the right position to change the logic for mixed costing (average).
    Thanks in advance,
    CR

    In solution 1, I had a procurement alternative and mixing ration in plant 200 and a special procurement type for costing in plant 210.
    Before calculating the mixed costing in plant 200 I had to eliminate the spec.proc.type for costing in plant 210 otherwise, the calculation got into a loop.
    Without the spc.proc.type in plant 210, I got a correct mixed costing in plant 200.
    Then I enter the spec.proc. type for costing again in plant 210 and calculate the cost price. This copies the mixed costing from plant 200. So far, OK.
    But as soon as I save this cost estimate in plant 210, the reports in CK11N or CK13N get incorrect for the first calculation made for plant 0210 while costing in plant 0200 is overwritten by this result. Now the report gets into a loop and you can drill down endlessly.

  • Logic to fetch the file name from Application Server

    Hi Friends
    I have a requirement that : By giving the Directory name (eg:/tmp),I have to get the all file names stored under that Directory name.
    Can anyone please provide me the logic / function modules related to this requirement.
    Points are assured for useful answers.
    Regards,
    Sree

    Hi,
    use these:
    function module "EPS_GET_DIRECTORY_LISTING"
    FM RZL_DIR_READ instead. its easy and effective to use.
    Or
    FILE_GET_NAME_USING_PATH,
    EPS_GET_DIRECTORY_LISTING
    /SAPDMC/LSM_F4_FRONTEND_FILE
    OPEN DATASET <Path / filename> FOR INPUT IN TEXT MODE...
    if sy-subrc eq 8, then the file does not exist on the application server.
    Reward Points if found helpfull..
    Cheers,
    Chandra Sekhar.

  • Need ABAP program logic to fetch datas from four tables

    Hi Friends,
    I have to develop a print program for purchase requisition.
    when a program is executed it has to accept the PR number,and it has to display the purchase requisition informations,also it has to display the address of the plant in the header.
    I have to fetch datas from EBAN,T001W,ADR2,ADR3 and ADR6.so i need all your help in writing the best select query for this program to work efficiently.
    Thanks in advance.

    Please don't just unload your specification here and expect others to do your work.
    Thread locked.
    Thomas
    P.S. "Total questions: 231 (191 unresolved)" is a lousy track record, please close your open questions properly, leaving a final comment only when it adds value.

  • Integrated Web Logic Server (Fetching data)

    hi everyone
    I m xplring the Jdeveloper 11g .As i have no expertises in this tool so i m using tutorial of TUHRA2 Application
    but i have a problem when i run the application on integratedWebLogicServer it deploy on the web but it not fatch data as message display saying "Fetching data "
    and the it take centries
    pls help me
    my email address is
    [email protected]
    regards
    Hasan

    Give details about your error message.

  • How to write ABAP Logic in SAP Query to fetch records from many Tables

    Hi Expert,
    I have one requirement, want to display all BOM (Equipment BOM, Function Location BOM and Meterial BOM) from a particular plant.
    List of tables as below:
    EQST: Equipment to BOM Link
    TPST: Link Between Functional Location and BOM
    MAST: Material to BOM Link
    STPO:BOM item
    Requirement: When user enters Plant then SAP Query should execute and fetch all BOMs (as mentioned above) from STPO Table.
    I have done so far is as follows:
    I create User Group, Infoset and SAP Query.
    While creating INFOSET, i used 4 tables (EQST,TPST,MAST & STPO) and link between then is as follows:
    STPO-STLNR ---> EQST-STLNR : Left Outer Join
    STPO-STLNR ---> TPST-STLNR : Left Outer Join
    STPO-STLNR ---> MAST-STLNR : Left Outer Join
    Now its showing all BOM from all plants though I enter one Plant value.
    Please advise me to write SAP Query and Logic to fetch all BOM from selected Plant Value.
    Thanks,
    Jay.
    Edited by: jaykrishna007 on Jul 29, 2011 11:41 AM

    Hi FCannavo,
    Thanks for your quick reply.
    See, now I changed my Infoset design.
    I added one Plant Table (T001W) and then
    T001W-WERKS--->EQST-WERKS
    T001W-WERKS--->MAST-WERKS
    T001W-WERKS--->TPST-WERKS
    and then
    EQST-STLNR--->STPO-STLNR
    MAST-STLNR--->STPO-STLNR
    TPST-STLNR--->STPO-STLNR
    on selection screen, user will enter Plant Value.
    Now its showing some records, but i dont think so i would be correct output or not, please guide me whether it is correct or not?
    Thanks,
    Jay.

  • BOM Item Details fetching  issue

    Hello Friends,
    Actually I am fetching BOM item details data, with the use of STAS  & STPO tables but to my surprise I am not getting all counter values in STPO tables i.e. first I am passing BOM NO, Alternate & Item ID To STAS table to get counter details and then passing these counter values in STPO table to get item data like qty , variable size item data etc.  But I am unable to find all counters which are available in STAS are present in STPO table e.g. in STAS table there are 113 counters but in case of STPO table only 37 counter values are found.
    Kindly provide your valuable inputs for above mentioned issue.
    Thanks in advance.
    Regards,
    Tejas

    Hi Vivek,
    Thanks for your reply.
    Request if you can elaborate your answer.
    Right now I am taking counter values from STAS and then passing them to STPO but many of counter values are not available even I checked deletion indicator it is not marked with X still those are not available in STPO.
    Regards,
    Tejas

Maybe you are looking for

  • Software necessary to communicate with Ipod not properly installed

    Hi, I updated my Itunes software and have been having problems ever since. Every time I connect my Ipod I get the message: "Software necessary to communicate with Ipod not properly installed. Reinstall Itunes..." After I click Ok it goes to Itunes bu

  • RDS - Remove Unknown Publisher warning?

    I found an article that shows how to remove the Unknown Publisher warning.  See Here. The suggested GPO setting is below.  But so far, I cannot get an instance to not show the publisher warning.  Any suggestions?  Computer Configuration/Administrativ

  • How do I change the main external editor from PS CC to PS 6?

    I put a trial version of PS CC on my computer and Lightroom 4 has changed the main external editor to the CC trial version. I don't want this to happen and I don't want PS6 to be an "Additional External Editor." I want the main editor to be PS6 at al

  • Repartitioning a Windows NTFS drive via Firewire

    I pulled an 80GB IDE HD from an old Wintel box and want to use it with my Mac Mini via an external Firewire enclosure. The drive has two partitions a C: drive and a D: drive. When I connect the drive, it will mount the C: drive partition but not the

  • Error initializing BAM in jboss

    i've been trying to install livecycle on a linux machine to some avail, i've been following the documentation that adobe provides, but i'm getting some errors. i'm stuck in BAM initialization. i've followed what the document provided and used the ado