How to fetch assets from tables depending on periods submitted in query ?

Hello,
Module : Fixed Assets
We are trying to fetch the assets for a report depending on the periods['From Period' & 'To Period'] given to SQL query,but we are not getting count of assets as expected.
And so the count isn't matching with 'CIP Details Report' which is a seeded oracle report.Here is the query that we tried,
SELECT   fadd.asset_id, fadd.asset_number,
         fak.segment1 || '.' || fak.segment2 asset_key, fadd.tag_number,
         fadd.description asset_description,
         fadd.attribute_category_code asset_category,
         fb.date_placed_in_service, gp.start_date, gp.end_date
    FROM fa_additions fadd,
         fa_asset_keywords fak,
         fa_books_v fb,
         gl_periods gp,
         fa_deprn_periods fdp,
         fa_asset_history fah,
         fa_transaction_headers fth
   WHERE fadd.asset_key_ccid = fak.code_combination_id
     AND fadd.asset_id = fb.asset_id
     AND fah.asset_id = fadd.asset_id
     AND fth.asset_id = fah.asset_id
     AND fth.transaction_header_id = fah.transaction_header_id_in
     AND fah.asset_type = 'CIP'
     AND fdp.book_type_code = fb.book_type_code
     AND fdp.period_name = gp.period_name
     AND fdp.book_type_code = :p_book_type_code            --'KV US CORP BOOK'
     AND fdp.period_counter =
            (SELECT MAX (fdp.period_counter)
               FROM fa_deprn_periods fdp
              WHERE 1 = 1
                AND fdp.calendar_period_open_date BETWEEN (SELECT start_date
                                                             FROM gl_periods
                                                            WHERE period_name =
                                                                    :p_period_from) = -- 'JUL-12-F13'
                                                      AND (SELECT start_date
                                                             FROM gl_periods
                                                            WHERE period_name =
                                                                    :p_period_to)) -- 'DEC-12-F13'
     AND fth.transaction_date_entered
            BETWEEN (SELECT calendar_period_open_date   
                       FROM fa_deprn_periods                      --gl_periods
                      WHERE period_name = :p_period_from           -- 'JUL-12-F13'
                        AND book_type_code = :p_book_type_code)   --'KV US CORP BOOK'
                AND (SELECT calendar_period_close_date    
                       FROM fa_deprn_periods                      --gl_periods
                      WHERE period_name = :p_period_to              -- 'DEC-12-F13'
                        AND book_type_code = :p_book_type_code)
GROUP BY fadd.asset_id,
         fadd.asset_number,
         fak.segment1 || '.' || fak.segment2,
         fadd.tag_number,
         fadd.description,
         fadd.attribute_category_code,
         fb.date_placed_in_service,
         fb.deprn_method_code,
         fb.life_in_months,
         gp.start_date,
         gp.end_date
ORDER BY 1
The query returns the assets which have the 'transaction date entered' between the periods submitted.
But what about the assets who's 'Beginning Year Balance' is not zero [in the periods submitted in the query], those assets should also get displayed in the report.[and seeded report 'CIP Detail Report' shows assets who's 'Beginning Year Balance' is not zero along with  the assets which have the transaction date entered between the periods submitted]
Any inputs / help / suggestions on this ?
Thanks !

Hi vijaya,
no simple select statement solution so far.
As BSEG is a huge table you should try to get the full key values into another internal table first.
SAP avoids direct selections from BSEG.
Pleas consider the use of one of the secondary index tables first:
      BSAD : Accounting: Secondary Index for Customers (Cleared Items)
      BSAK : Accounting: Secondary Index for Vendors (Cleared Items)
      BSAS : Accounting: Secondary Index for G/L Accounts (Cleared Item
      BSEC : One-Time Account Data Document Segment
      BSEG : Accounting Document Segment
      BSID : Accounting: Secondary Index for Customers
      BSIK : Accounting: Secondary Index for Vendors
      BSIS : Accounting: Secondary Index for G/L Accounts
you may include
      BKPF : Accounting Document Header
for restrictions about time and document type.
The last step is a FOR ALL ENTRIES selection from BSEG providing the full key values.
Although you may have even more selects, the overall performance will be much better.
Regards,
Clemens

Similar Messages

  • Fixed Assets : How to fetch assets from FA tables depending on periods submitted in query ?

    Hello,
    Module : Fixed Assets
    We are trying to fetch the assets for a report depending on the periods['From Period' & 'To Period'] given to SQL query,but we are not getting count of assets as expected.
    And so the count isn't matching with 'CIP Details Report' which is a seeded oracle report.Here is the query that we tried,
    SELECT   fadd.asset_id, fadd.asset_number,
             fak.segment1 || '.' || fak.segment2 asset_key, fadd.tag_number,
             fadd.description asset_description,
             fadd.attribute_category_code asset_category,
             fb.date_placed_in_service, gp.start_date, gp.end_date
        FROM fa_additions fadd,
             fa_asset_keywords fak,
             fa_books_v fb,
             gl_periods gp,
             fa_deprn_periods fdp,
             fa_asset_history fah,
             fa_transaction_headers fth
       WHERE fadd.asset_key_ccid = fak.code_combination_id
         AND fadd.asset_id = fb.asset_id
         AND fah.asset_id = fadd.asset_id
         AND fth.asset_id = fah.asset_id
         AND fth.transaction_header_id = fah.transaction_header_id_in
         AND fah.asset_type = 'CIP'
         AND fdp.book_type_code = fb.book_type_code
         AND fdp.period_name = gp.period_name
         AND fdp.book_type_code = :p_book_type_code            --'KV US CORP BOOK'
         AND fdp.period_counter =
                (SELECT MAX (fdp.period_counter)
                   FROM fa_deprn_periods fdp
                  WHERE 1 = 1
                    AND fdp.calendar_period_open_date BETWEEN (SELECT start_date
                                                                 FROM gl_periods
                                                                WHERE period_name =
                                                                        :p_period_from) = -- 'JUL-12-F13'
                                                          AND (SELECT start_date
                                                                 FROM gl_periods
                                                                WHERE period_name =
                                                                        :p_period_to)) -- 'DEC-12-F13'
         AND fth.transaction_date_entered
                BETWEEN (SELECT calendar_period_open_date 
                           FROM fa_deprn_periods                      --gl_periods
                          WHERE period_name = :p_period_from           -- 'JUL-12-F13'
                            AND book_type_code = :p_book_type_code)   --'KV US CORP BOOK'
                    AND (SELECT calendar_period_close_date  
                           FROM fa_deprn_periods                      --gl_periods
                          WHERE period_name = :p_period_to              -- 'DEC-12-F13'
                            AND book_type_code = :p_book_type_code)
    GROUP BY fadd.asset_id,
             fadd.asset_number,
             fak.segment1 || '.' || fak.segment2,
             fadd.tag_number,
             fadd.description,
             fadd.attribute_category_code,
             fb.date_placed_in_service,
             fb.deprn_method_code,
             fb.life_in_months,
             gp.start_date,
             gp.end_date
    ORDER BY 1
    The query returns the assets which have the 'transaction date entered' between the periods submitted.
    But what about the assets who's 'Beginning Year Balance' is not zero [in the periods submitted in the query], those assets should also get displayed in the report.[and seeded report 'CIP Detail Report' shows assets who's 'Beginning Year Balance' is not zero along with  the assets which have the transaction date entered between the periods submitted]
    Any inputs / help / suggestions on this ?
    Thanks !

    This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
    Thanks,
    N

  • How to fetch data from PTREQ tables

    I need to display  data in the customised webdynpro application from PTREQ tables.
    Can anyone help me out how to fetch data from these tables.

    use the standard modules like
    PT_ARQ_REQUEST_CHECK
    PT_ARQ_REQUEST_EXECUTE
    PT_ARQ_REQUEST_PREPARE

  • How to fetch data from cluster tables

    hi
    i need to know  how to fetch data from cluster tables please update me if any
    i know that we cannot use joins in cluster table we use view etc
    but i need detailed inforation on methods for fetching data from cluster tables
    regards
    Nishant

    Hi,
        Check the following links
    http://fuller.mit.edu/hr/cluster_tables.html
    The specified item was not found.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33

  • How to fetch records from query.....

    hii experts,
    How to fetch data from following query.... The query is depend on the Project_Id
    SELECT           'Plant Consumption' TYP,                                 -1*ROUND(SUM (MTA.BASE_TRANSACTION_VALUE)) S_VALUE,
    TO_CHAR (MMT.TRANSACTION_DATE, 'Mon-rrrr') MNTYR,
    TO_CHAR (MMT.TRANSACTION_DATE, 'rrrrmm') MNT,
                        TO_CHAR(MMT.TRANSACTION_REFERENCE) TRX_REF,
                        MMT.SOURCE_LINE_ID SRC_LIN,
                        TO_CHAR(MMT.SHIPMENT_NUMBER) SHP
    FROM (SELECT TO_CHAR( OLA.HEADER_ID) HDR1,
                        OLA.LINE_ID LINE1,
                                  OLA.PROJECT_ID ,
                                  TO_CHAR(OLA.SHIPMENT_NUMBER) SHP1
                             FROM OE_ORDER_HEADERS_ALL OHA,
                                  OE_ORDER_LINES_ALL OLA
                             WHERE OHA.HEADER_ID = OLA.HEADER_ID
                             AND OHA.ORG_ID = OLA.ORG_ID
                             AND OLA.PROJECT_ID = :P_PROJECT_ID
                             AND OLA.ORG_ID = :P_ORG_ID
                             AND OLA.FLOW_STATUS_CODE = 'CLOSED'
                             ) A,
                        MTL_MATERIAL_TRANSACTIONS MMT,
    MTL_TRANSACTION_ACCOUNTS MTA,
    GL_CODE_COMBINATIONS GCC
    WHERE MMT.TRANSACTION_ID = MTA.TRANSACTION_ID
    AND GCC.CODE_COMBINATION_ID      = MTA.REFERENCE_ACCOUNT
    AND MMT.TRANSACTION_TYPE_ID = 33
    AND GCC.SEGMENT1 = '11'
    AND GCC.SEGMENT2 = '13'
    AND GCC.SEGMENT3 = '34381'
    AND GCC.SEGMENT4 = '0000'
    AND                GCC.SEGMENT5                     =      '000000'
    AND MMT.SHIPMENT_NUMBER IS NOT NULL
    AND MMT.PROJECT_ID IS NULL
    AND           A.HDR1           = TO_CHAR(MMT.TRANSACTION_REFERENCE)
    AND                A.LINE1           = MMT.SOURCE_LINE_ID
    AND A.PROJECT_ID = :P_PROJECT_ID
    AND                A.SHP1           = TO_CHAR(MMT.SHIPMENT_NUMBER)
    GROUP BY TO_CHAR (MMT.TRANSACTION_DATE, 'rrrrmm'),
         TO_CHAR (MMT.TRANSACTION_DATE, 'Mon-rrrr'),MMT.TRANSACTION_REFERENCE,MMT.SOURCE_LINE_ID,MMT.SHIPMENT_NUMBER;
    -----

    hii
    The project_number is matching column in table mtl_material_transaction mmt and A (FROM CLAUSE query). But data retreive based on
    WHERE MMT.PROJECT_ID IS NULL
    AND A.PROJECT_ID = :P_PROJECT_ID
    PS

  • PDE-PLI031 Unable to fetch record from table tool_modulre

    Dear ALL
    I am creating PL/SQL Libraries in report builder.
    but When I try to save the Library to database, a error
    PDE-PLI031 Unable to fetch record from table tool_modulre.
    Would you please tell me how to solve this problem
    and why it coming
    thankyou very much
    pritam singh

    Hi ,
    Saving a library (.pll) to database would store the object inside specific tables that are to be created.
    If you are using 6i, then you should find toolbild & toolgrnt.sql files which you have to run in the order specified. The above scripts creates the necessary tables and henceforth you won't get those errors while saving.
    Hope this helps.
    Thanks,
    Vinod.

  • How to retrieve data from table(BOM_ITEM)

    Hi All,
    I wrote webservices using axis1.4 to get BOM information from SAP.. funtional module is CAD_DISPLAY_BOM_WITH_SUB_ITEMS
    webservices works fine..I'am able to retrieve data from Export Parameter..But not able to retrieve data from table
    How to retrieve data from table(BOM_ITEM)..?
    Cheers, all help would be greatly appreciated
    Vijay

    Hi,
    1. Create Page Process.
    2. Select Data Manipulation
    3. In category select "Automated Row Fetch"
    4. Specify process name, sequence, select "On Load - Before Header" in point.
    5. Specify owner, table, primary key, and the primary key column(Item name contains primary key).
    6. Create a process.
    7. In each item select "Database Column" in "Source Type".
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • How to fetch data from Mysql with SSL.

    I am using jdk1.5 and mysql 5.0.
    How to fetch data from Mysql with SSL
    I am using url = jdbc:mysql://localhost/database?useSSL=true&requireSSL=true.
    It shows error. how to fetch

    I have created certificate in mysql and checked in mysql.
    mysql>\s
    SSL: Cipher in use is DHE-RSA-AES256-SHA
    but through ssl how to fetch data in java.

  • Time out error while fetching records from table BKPF

    Hi,
    I am fetching records from table BKPF using BUKRS & AWKEY in where clause. Query is as follows:
        SELECT BELNR  XBLNR  AWKEY
        FROM   BKPF
        INTO TABLE L_I_BKPF_TEMP
        PACKAGE SIZE 500
        WHERE BUKRS LIKE L_C_EG
        AND   AWKEY IN L_R_AWKEY .
          APPEND LINES OF L_I_BKPF_TEMP TO I_BKPF .
        ENDSELECT .
    Program is giving time out error. There are 25628 records in range L_R_AWKEY , i m fetching 500 records at a time using  PACKAGE SIZE. But the execution of prog stops on this query.
    Please suggest something to overcome this problem.

    Hi
    Rui is right,
    if you need to get the data by  operation parameters u have to use the fields AWTYP and AWKEY.
    In this selection u can omit the company code.
    SELECT BELNR XBLNR AWKEY FROM BKPF
           INTO TABLE L_I_BKPF_TEMP
                 PACKAGE SIZE 500
                      WHERE   AWTYP = <......> "<------------
                             AND AWKEY IN L_R_AWKEY .
           APPEND LINES OF L_I_BKPF_TEMP TO I_BKPF .
    ENDSELECT .
    Max

  • What is a cube? how we store data in that? how we fetch data from cube?

    Hi,
    What is a cube? how we store data in that? how we fetch data from cube?
    Regards.
    venkat

    >
    venkey B wrote:
    > Hi,
    >
    >
    > What is a cube? how we store data in that? how we fetch data from cube?
    >
    >
    > Regards.
    >
    > venkat
    Hi Venkat,
    I guess you mean an infocube from the SAP BI product. I propose to look at the forum for Business Intelligence to find your answers.
    E.g. SAP POS DM writes the sales data in infocubes.....

  • VB Runtime error timeouts. Could not fetch terms from table: TPW6

    VB Runtime error timeouts are occurring repeatedly for multiple users on the terminal server.
    Event Type:         Warning
    Event Source:     VBRuntime
    Event Category:  None
    Event ID:              1
    Description: The VB Application identified by the event source logged this Application XL Reporter: Thread ID: 13508 ,Logged: Could not fetch terms from table: TPW6
    It looks like bad table reference in XL reports? This is causing significant lag as they wait to time-out. Is there a way to identify source(s) and correct  it/them? Unfortunately the error does not say what report. Is there any way of identifying exactly what the SAP equivalent is to the tables it is having issues finding?
    thanks

    This error may not cause big problems.  We have to live with it for a long time.  It only show XLR with highlight icon on the task bar.  It shouldn't have much bigger impacts.
    Thanks,
    Gordon

  • Fetch value from Table with respect to APP_USER.

    Hi,
    i want to fetch value from Table with respect to APP_USER.
    i am using
    SELECT ID,NAME,FILE_OBJ_ID,MIME_TYPE,DOC_SIZE,BLOB_CONTENT,DESCRIPTION,UPLOAD_DATE,'Download' FROM DUMY_FILE where CREATED_BY =:APP_USER;
    Show me error
    failed to parse SQL query:
    ORA-00911: invalid characterThanks
    Edited by: 805629 on Jan 13, 2011 2:09 AM

    Hello,
    I too have the same problem.
    I am using this query:
    select manager from leave_mgmt where support_engg=:APP_USER
    and source type is SQL Query(return single value)
    but nothing is coming up in the text field. Its empty.
    Please advice. Thanks in advance.

  • How to fetch data from single database table using 2 internal tables.

    Hi friends,
    i am a new user of ABAP and also SDN.
    i need a help. 
    i want to fetch data from one database table based on primary keys of 2 internal tables.  how to put in where clause.
    Thanks in advance.

    hii
    refer to following code ..i hope it will help you
    SELECT matnr                         " Material Number
        FROM mara
        INTO TABLE i_mara
       WHERE matnr IN s_matnr.
      IF i_mara[] IS NOT INITIAL.
        SELECT matnr                       " Material Number
               werks                       " Plants
               prctr                       " Profit Center
          FROM marc
          INTO TABLE i_marc
           FOR ALL ENTRIES IN i_mara
         WHERE matnr = i_mara-matnr
           AND werks IN s_werks.
      ENDIF.                               " IF i_mara[] IS NOT INITIAL
      i_output = i_marc.
      IF i_marc[] IS NOT INITIAL.
        SELECT matnr                       " Material Number
               werks                       " Plants
               lgort                       " Storage Location
          FROM mard
          INTO TABLE i_mard
           FOR ALL ENTRIES IN i_marc
         WHERE matnr EQ i_marc-matnr
           AND werks EQ i_marc-werks
           AND lgort IN s_lgort.
      ENDIF.                               " IF i_mara[] IS NOT INITIAL
    regards
    twinkal

  • How to fetch data from database in javafx 2.2 table which is editable.

    Dears!
    I want to fetch data from database in javafx 2.2 tableformat with jdbc , which is also editable and i can add more records in this table also.
    Can anybody help me

    I can vaguely recall some sort of JavaFX database connectivity feature, I'm not sure if it's valid anymore.The link is based on JavaFX Composer which only applied to NetBeans 6.9 and JavaFX 1.x (both of which are now dead techs).
    There is a good chance you will have to write your own. There are several blogs describing other peoples' work. You could probably use them as a reference.Here is Narayan's basic [url http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] tutorial for displaying data from a database in a TableView, you'll need to look elsewhere for the editing portion.
    The [url http://docs.oracle.com/javafx/2/ui_controls/table-view.htm]JavaFX TableView tutorial gives info about how to handle edits in a TableView, but you will need to tie the updates back to the database yourself.
    It is possible that [url http://www.javafxdata.org/]DataFX may provide some facilities to help support you.

  • How to fetch rows from PL/SQL table(Collections)

    Hi,
    I retrived rows from the table and stored in to table type.
    Now I want fetch these rows and display on the screen. Pls guide me.
    following code is my code:
    DECLARE
    type t1 is table of emp%rowtype index by binary_integer;
    var1 t1;
    v_counter number:=0;
    BEGIN
    select * bulk collect into var1 from emp;
    for vr in var1.first..var1.last
    loop
    dbms_output.put_line(var1(1)); --Got an Error Here. Acually I don't Know how to  fetch.
    update dept set deptno=var1.deptno --Here also Error occured.
    end loop;
    END;

    Fetching rows to display them is a task for the client tool. You need to define a ref cursor therefore.
    If you just want to play around, here we go
    SQL> DECLARE
      2    type t1 is table of emp%rowtype index by binary_integer;
      3    var1 t1;
      4    v_counter number:=0;
      5  BEGIN
      6    select * bulk collect into var1 from emp;
      7    for vr in 1..var1.count loop
      8      dbms_output.put_line(var1(vr).ename);
      9      update dept set deptno=var1.deptno Here also Error occured.
    10    end loop;
    11  END;
    12  /
    SCOTT
    ADAMS
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • ICloud is not working and still mobile me conflicting with icloud on lion

    I am really starting to lose faith in Apple ever since I got this icloud problem on my macbook pro.. Everytime when I do something with icloud, it kept asking my old mobile me account and saying 'mobile me' services are no longer available.. how can

  • System keeps crashing on my macbook pro

    I am using a MacBook Pro OS 10.10.2, when I try to transfer a book to my kobo, the system crashes? I have the 4.0 version of Digital Editions, help!!

  • Customizing templates in HTMLDB

    I am trying to customize a template, but I would like to select some items in the #BODY#, not all (default). How can I do that? Thanks a lot!

  • Adobe InContext Editing on Intranet Sites

    Hello, I am a devleoper and working on our organizations site and many people need access to edit certain areas of the page with no experience at all. I love the idea of InContext but not sure how i can get it to work for this. As any organization, w

  • How to make a Projector file scrollable

    Is there a way or a setting that makes a published Projector file scrollable? I have a projector file with some content off-screen (not on the stage). I want the user to be able to scroll up and bring in the off-stage content (and of course scroll to