ME_PROCESS_PO_CUST BADI Query

Hi,
I am trying to implement ME_PROCESS_PO_CUST BADI.
My requirement is to diable the NETPR field in ME21N and ME22N Tcodes when the PO is created with ref to an RFQ or Contract.
To achieve this I am implementing the FIELDSELECTION_ITEM method to edit the properties of NETPR field.
  TYPE-POOLS: mmmfd.
  DATA : po_item TYPE mepoitem.
  FIELD-SYMBOLS: <fs> LIKE LINE OF ch_fieldselection.
  po_item = im_item->get_data( ).
  IF po_item IS NOT INITIAL.
    IF po_item-konnr IS NOT INITIAL.
      READ TABLE ch_fieldselection ASSIGNING <fs> WITH TABLE KEY metafield = mmmfd_out_netpr.
      IF sy-subrc IS INITIAL.
        <fs>-fieldstatus = '*'. " Display
      ENDIF.
    ELSEIF po_item-anfnr IS NOT INITIAL.
      READ TABLE ch_fieldselection ASSIGNING <fs> WITH TABLE KEY metafield = mmmfd_out_netpr.
      IF sy-subrc IS INITIAL.
        <fs>-fieldstatus = '*'. " Display
      ENDIF.
    ENDIF.
  ENDIF.
The implementation is active. But still it is not entering this methos. I tried to put a breakpoint also but it didn't stop there.
What can be the possible reason for this? Please suggest...
Edited by: Anup Deshmukh on Aug 3, 2011 12:47 PM

Hi Anup,
find the BADI implementation in SE19, edit, deactivate, activate (Menu Implemention deactivate/activate) or use buttons.
You may reduce the code
    IF po_item-konnr IS NOT INITIAL OR
      ( po_item-konnr IS INITIAL and po_item-anfnr IS NOT INITIAL ).
      READ TABLE ch_fieldselection ASSIGNING <fs> WITH TABLE KEY metafield = mmmfd_out_netpr.
      IF sy-subrc IS INITIAL.
        <fs>-fieldstatus = '*'. " Display
      ENDIF.
    ENDIF.
Regards
Clemens
Edited by: Clemens Li on Aug 3, 2011 2:15 PM

Similar Messages

  • Regarding Error message in ME_PROCESS_PO_CUST badi for validation.

    hi Friends,
    I am Using ME_PROCESS_PO_CUST badi for validation in Purchase order (ME21N),
    For that I implemented PROCESS_ITEM method which fires during each row now i  add another validation in same implementation for plant  should be same through out the all line item. Now following code is woking fine but when for second line item user changese plant then it shows error message as per logic which is fine but even after changing plant to correct one the error message is still coming why is it so?
    following is my current validation code
    method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM.
      DATA:ls_poitem TYPE mepoitem,
           ls_poitem_set TYPE mepoitem.
      DATA:ls_poheader TYPE MEPOHEADER.
      DATA:lm_poheader TYPE ref to IF_PURCHASE_ORDER_MM.
      DATA:w_mara TYPE mara.
      DATA:IT_ZMMTBL039 TYPE STANDARD TABLE OF ZMMTBL039 ,
           WA_ZMMTBL039 TYPE ZMMTBL039 .
      DATA:ls_poitem1 TYPE mepoitem.
      DATA:V_KUNNR1 TYPE KNA1-KUNNR.
      DATA:V_KUNNR2 TYPE KNA1-KUNNR.
      DATA:W_WERKS(4),
           w_werks_tmp(4),
           w_flag(1).
      ls_poitem = im_item->get_data( ).
      lm_poheader = im_item->GET_HEADER( ).
      ls_poheader = lm_poheader->GET_DATA( ).
      IF ls_poitem-werks IS NOT INITIAL.
        w_werks = ls_poitem-werks.
        import w_flag to w_flag from MEMORY ID 'FLAG'.
        if w_flag is initial.
          w_flag = 'X'.
          EXPORT w_werks_tmp FROM w_werks TO MEMORY ID 'MEMO1'.
          export w_flag from w_flag to MEMORY ID 'FLAG'.
          clear: w_flag.
        endif.
      ENDIF.
      IMPORT w_werks_tmp TO w_werks FROM MEMORY ID 'MEMO1'.
    break swaroopb.
      IF ls_poitem-werks NE w_werks.
          MESSAGE E010(zparts) with 'Different plants are not allowed in single PO.'.
      ENDIF.
      CLEAR: WA_ZMMTBL039,w_mara.
      REFRESH:IT_ZMMTBL039[] .
      SELECT *
        INTO TABLE IT_ZMMTBL039
        FROM ZMMTBL039
       WHERE bsart EQ ls_poheader-bsart.
      IF sy-subrc EQ 0.
        CLEAR: WA_ZMMTBL039,w_mara.
        SELECT SINGLE *
          INTO w_mara
          FROM mara
         WHERE matnr EQ ls_poitem-MATNR.
        IF SY-SUBRC EQ 0.
          READ TABLE IT_ZMMTBL039 INTO WA_ZMMTBL039 WITH KEY  bsart = ls_poheader-bsart
                                                              mtart = w_mara-mtart
                                                              spart = w_mara-spart.
          IF SY-SUBRC NE 0.
            MESSAGE E009(zparts) WITH ls_poitem-MATNR w_mara-spart ls_poheader-bsart .
          ENDIF.
        ENDIF.
      ENDIF.
    end method

    Hello Swarup
    Since you want to compare all items together (having the same plant) I would suggest to implement this logic either in method CHECK or POST of the interface.
    However, if you want to make your checks within the PROCESS_ITEM method then you should change your logic.
    It does not make sense to work with the ABAP memory within a BAdI implementing class because the class itself is your "memory".
    I would use the following logic to implement your validation:
      lo_poheader = im_item->get_header( ).  " retrieve header instance
      lt_items = lo_poheader->get_items( ).   " retrieve all items
      ls_detail_x = im_item->get_detail( ).  " details of currently processed item
      LOOP AT lt_items INTO ls_item.
        ls_detail = ls_item-item->get_detail( ).
        IF ( ls_detail-werks NE ls_detail_x-werks ).  " validation failed
        " do something...
       ENDIF.
      ENDLOOP.
    However, I would prefer to do this kind of validation in CHECK or POST method.
    Regards,
      Uwe

  • Bad query performance - how to analyze it?

    Hi all,
    since 8 weeks we locate a bad query performance (round about 30% worse than before) in our BW system. At the moment we use a BIA on revision 49 with 4 blades (16GB).
    I have already read note 1318214 and analyzed that the most time is spend on the virtual provider(over 80%!).
    I´ve seen that a lot of time is spend on the "Datamanager":
    For example: It takes 0,76s to select 3.5million items in the relative provider and 78s!!! to select 0 items in the virtual provider.
    information from RSDDSTATTREXSERV:
    RFC Server    BIA client  BIA Kernel    ABAP RFC
    497          464              450               619
    So it seems to be a problem an the BW site, what can we do to improve the performance or analyse the query performance better.
    Best Regards,
    Jens

    Hi Jens,
    A few checks you may consider doing.
    BIA Availability :  Check the BI connection with BIA.
    Check if you need to rebuild BIA indices again. SAP recommends to do this often, to repair the degenerate indices or delete the indice which are not referenced any more.(eg data in the cube was compressed/deleted and the indices are no more needed.)
    Check the if BIA  reorganization is required - This is done to see the indices are evenly distribueded areoss the BIA Landscape.
    Try to find from BI Admin if major administration work was done within these 8 weeks.eg: Copy cube, dimension restructureing, copying data to some copy cube, archiving etc.
    You can use the BIA monitor to peform checks/monitor alerts from BIA servers
    [ BIA monitor|http://help.sap.com/saphelp_nw70/helpdata/en/43/7719d270d81a6ee10000000a11466f/content.htm]
    This link would tell you on the overall status of the BIA and any actions if required.
    Also it has sublinks to other important transaction of BIA monitoring and maintainnance.
    To go to BIA monitor : RSA!---> BIA monitor icon.
    Is your virtual provider reading data from R/3 or BW.
    Generally virtual providers are used to read data from other systems , so it woulfd not have an indices in BIA, I believe if this is the case. except for some applications like BCS wher eyou may be reading data from BW itself.
    Hope this helps
    Bext regards,
    Sunmit.

  • Question about bad query

    Hi all ,
    I have small question related to bad query .
    what is the affecting happens to database if there is lot of bad query , i know the performance issue is there what's other things .like archive log generated database time , IO , TMP tablespace , please give me information about it's .
    thanks & regards.

    user11969912 wrote:
    I have small question related to bad query . What do you consider a bad query? A bad query can be the result of poorly written and illogical SQL. It can be due to not using bind variables. It can be due to a on-optimal execution plan generated by the CBO. It can be due to poorly designed code that uses what seems to be a "good query", badly and in the wrong way (using bulk collection when a native SQL alone suffices, or hitting the very same data multiple times, etc).
    what is the affecting happens to database if there is lot of bad query Each of these have a different impact on the database. A "bad query" can cause a snapshot-too-old error. A deadlock error. A shared pool memory allocation error. Can cause no error and simple increase I/O. Or increase CPU. Etc.
    It is a lot more complex than what you seem to think, given your question.

  • Me_process_po_cust badi for generating internal number range in me21n tcode

    Hi all,
    I have requirement while creating purchase order my client want to generate internal number range based on company code,document type and plant.here, we are making one custom table to hold compny code,plant,doc.type and Number range number.I am using me_process_po_cust badi for the same.I got the po header and item data from this badi.my problem is how i can pass this number range number in me21n to respective fields.
    Regards,
    Sleela Patil

    Hi,
    Thank u both of you..I tried that exit.following is the code I have written for that exit.
    TABLES: T001K,NRIV,EKKO,ZVS_MM_RANGE.
    DATA: WA_TAB TYPE ZVS_MM_RANGE,
          WERKS LIKE T001W-WERKS.
    GET PARAMETER ID 'WRK' FIELD WERKS.
    SELECT SINGLE * FROM T001K
                    WHERE BUKRS EQ NEKKO-BUKRS.
    IF SY-SUBRC EQ 0.
      SELECT SINGLE * FROM ZVS_MM_RANGE
                      INTO WA_TAB
                      WHERE BUKRS EQ NEKKO-BUKRS
                      AND WERKS EQ WERKS    "T001K-BWKEY
                      AND BSART EQ NEKKO-BSART.
      IF SY-SUBRC EQ 0.
        MOVE: NEKKO-EBELN TO NUMBER,
              WA_TAB-NRRANGENR TO RANGE.
      ELSE.
        MESSAGE 'Please maintain Number range in table zvs_mm_range' TYPE 'E'.
      ENDIF.
    ENDIF.
    Here, I am getting data as I needed but problem is client having multiple plant for single company code.I am not able to capture plant in this exit.as, it is in item level.so,later on tried to do it using me_process_po_cust badi.
    Now my problem is that how to pass this number range number in me23n tansaction.
    Regards,
    Sheela Patil

  • Bad query plan for self-referencing CTE view query and variable in WHERE clause. Is there way out or this is SQL Server defect?

    Please help. Thank you for your time and expertise.
    Prerequisites: sql query needs to be a view. Real view is more than recursion. It computes location path,  is used in JOINs and returns this path.
    Problem: no matter what I tried, sql server does not produce 'index seek' when using variable but does with literal.
    See full reproduction code below.
    I expect that query SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID will seek UNIQUE index but it does not.
    I tried these:
    1. Changing UX and/or PK to be CLUSTERED.
    2. query OPTION(RECOMPILE)
    3. FORCESEEK on view
    4. SQL Server 2012/2014
    5. Wrap it into function and CROSS APPLY. On large outer number of rows this just dies, no solution
    but to no avail. This smells like a bug in SQL Server. I am seeking your confirmation.
    I am thinking it is a bug as variable value is high-cardinality, 1, and query is against unique key. This must produce single seek, depending if clustered or nonclustred index is unique
    Thanks
    Vladimir
    use tempdb
    BEGIN TRAN
    -- setup definition
    CREATE TABLE dbo.LocationHierarchy(
    lcID int NOT NULL ,
    lcHID hierarchyid NOT NULL,
    lcCode nvarchar(25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    lcHIDParent AS lcHID.GetAncestor(1) PERSISTED,
    CONSTRAINT PK_LocationHierarchy_lcID PRIMARY KEY NONCLUSTERED (lcID ASC),
    CONSTRAINT UX_LocationHierarchy_pltID_lcHID UNIQUE CLUSTERED (lcHID ASC)
    -- add some data
    INSERT INTO dbo.LocationHierarchy
    VALUES
    (1, '/', 'A')
    ,(2, '/1/', 'B')
    ,(3, '/1/1/', 'C')
    ,(4, '/1/1/1/', 'D')
    --DROP VIEW dbo.vwLocationCodes
    GO
    CREATE VIEW dbo.vwLocationCodes
    AS
    WITH ru AS
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.lcHID
    ,CAST('/' + lh.lcCode + '/' as varchar(8000)) as LocationPath
    -- to support recursion
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    UNION ALL
    SELECT
    ru.lcID
    ,ru.lcCode
    ,ru.lcHID
    ,CAST('/' + lh.lcCode + ru.LocationPath as varchar(8000)) as LocationPath
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    JOIN ru ON ru.lcHIDParent = lh.lcHID
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.LocationPath
    ,lh.lcHID
    FROM ru lh
    WHERE lh.lcHIDParent IS NULL
    GO
    -- get data via view
    SELECT
    CONCAT(SPACE(l.lcHID.GetLevel() * 4), lcCode) as LocationIndented
    FROM dbo.vwLocationCodes l
    ORDER BY lcHID
    GO
    SET SHOWPLAN_XML ON
    GO
    DECLARE @lcID int = 2
    -- I believe this produces bad plan and is defect in SQL Server optimizer.
    -- variable value cardinality is 1 and SQL Server should know that. Optiomal plan is to do index seek with key lookup.
    -- This does not happen.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID -- bad plan
    -- this is a plan I expect.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = 2 -- good plan
    -- I reviewed these but I need a view here, can't be SP
    -- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/17/non-recursive-common-table-expressions-performance-sucks-1-cte-self-join-cte-sub-query-inline-expansion.aspx
    -- http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22d2d580-0ff8-4a9b-b0d0-e6a8345062df/issue-with-select-using-a-recursive-cte-and-parameterizing-the-query?forum=transactsql
    GO
    SET SHOWPLAN_XML OFF
    GO
    ROLLBACK
    Vladimir Moldovanenko

    Here is more... note that I am creating table Items and these can be in Locations.
    I am trying LEFT JOIN and OUTER APLLY to 'bend' query into NESTED LOOP and SEEK. There has to be nested loop, 2 rows against 4. But SQL Server fails to generate optimal plan with SEEK. Even RECOMPILE does not help
    use tempdb
    BEGIN TRAN
    -- setup definition
    CREATE TABLE dbo.LocationHierarchy(
    lcID int NOT NULL ,
    lcHID hierarchyid NOT NULL,
    lcCode nvarchar(25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    lcHIDParent AS lcHID.GetAncestor(1) PERSISTED,
    CONSTRAINT PK_LocationHierarchy_lcID PRIMARY KEY NONCLUSTERED (lcID ASC),
    CONSTRAINT UX_LocationHierarchy_pltID_lcHID UNIQUE CLUSTERED (lcHID ASC)
    -- add some data
    INSERT INTO dbo.LocationHierarchy
    VALUES
    (1, '/', 'A')
    ,(2, '/1/', 'B')
    ,(3, '/1/1/', 'C')
    ,(4, '/1/1/1/', 'D')
    --DROP VIEW dbo.vwLocationCodes
    GO
    --DECLARE @Count int = 10;
    --WITH L0 AS (SELECT N FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) N (N))-- 10 rows
    --,L1 AS (SELECT n1.N FROM L0 n1 CROSS JOIN L0 n2) -- 100 rows
    --,L2 AS (SELECT n1.N FROM L1 n1 CROSS JOIN L1 n2) -- 10,000 rows
    --,L3 AS (SELECT n1.N FROM L2 n1 CROSS JOIN L2 n2) -- 100,000,000 rows
    --,x AS
    -- SELECT TOP (ISNULL(@Count, 0))
    -- ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as Number
    -- FROM L3 n1
    --SELECT Number as itmID, NTILE(4)OVER(ORDER BY Number) as lcID
    --INTO dbo.Items
    --FROM x
    ----ORDER BY n1.N
    --ALTER TABLE dbo.Items ALTER COLUMN itmID INT NOT NULL
    --ALTER TABLE dbo.Items ADD CONSTRAINT PK PRIMARY KEY CLUSTERED (itmID)
    CREATE TABLE dbo.Items (itmID int NOT NULL PRIMARY KEY, lcID int NOT NULL)
    INSERT INTO dbo.items
    VALUES(1, 1)
    ,(2, 3)
    GO
    CREATE VIEW dbo.vwLocationCodes
    AS
    WITH ru AS
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.lcHID
    ,CAST('/' + lh.lcCode + '/' as varchar(8000)) as LocationPath
    -- to support recursion
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    UNION ALL
    SELECT
    ru.lcID
    ,ru.lcCode
    ,ru.lcHID
    ,CAST('/' + lh.lcCode + ru.LocationPath as varchar(8000)) as LocationPath
    ,lh.lcHIDParent
    FROM dbo.LocationHierarchy lh
    JOIN ru ON ru.lcHIDParent = lh.lcHID
    SELECT
    lh.lcID
    ,lh.lcCode
    ,lh.LocationPath
    ,lh.lcHID
    FROM ru lh
    WHERE lh.lcHIDParent IS NULL
    GO
    -- get data via view
    SELECT
    CONCAT(SPACE(l.lcHID.GetLevel() * 4), lcCode) as LocationIndented
    FROM dbo.vwLocationCodes l
    ORDER BY lcHID
    GO
    --SET SHOWPLAN_XML ON
    GO
    DECLARE @lcID int = 2
    -- I believe this produces bad plan and is defect in SQL Server optimizer.
    -- variable value cardinality is 1 and SQL Server should know that. Optiomal plan is to do index seek with key lookup.
    -- This does not happen.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = @lcID-- OPTION(RECOMPILE) -- bad plan
    -- this is a plan I expect.
    SELECT lcCode FROM dbo.vwLocationCodes l WHERE l.lcID = 2 -- good plan
    SELECT *
    FROM dbo.Items itm
    LEFT JOIN dbo.vwLocationCodes l ON l.lcID = itm.lcID
    OPTION(RECOMPILE)
    SELECT *
    FROM dbo.Items itm
    OUTER APPLY
    SELECT *
    FROM dbo.vwLocationCodes l
    WHERE l.lcID = itm.lcID
    ) l
    -- I reviewed these but I need a view here, can't be SP
    -- http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/17/non-recursive-common-table-expressions-performance-sucks-1-cte-self-join-cte-sub-query-inline-expansion.aspx
    -- http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22d2d580-0ff8-4a9b-b0d0-e6a8345062df/issue-with-select-using-a-recursive-cte-and-parameterizing-the-query?forum=transactsql
    GO
    --SET SHOWPLAN_XML OFF
    GO
    ROLLBACK
    Vladimir Moldovanenko

  • FIELDSELECTION_ITEM method in ME_PROCESS_PO_CUST Badi

    Hi all, this question was posted before but looks not answered directly so I am posting again as I have similar problem.
    We have implemented BADI ME_PROCESS_PO_CUST especially on method FIELDSELECTION_ITEM, I look at the sample code and apply almost the same logic in our implementation of this badi. We implemented FIELDSELECTION_ITEM method, however, no matter what breakpoint I put on this method, the debugger does not stop.
    In some methods such as OPEN, PROCESS_ITEM, PROCESS_HEADER, etc, they are all ok, i.e., it stop at the breakpoint.
    Looks like this method is not being triggered. My question is at what point is this method being triggered?
    Anything we missed here? Or any prerequisite I need to do before.
    Pls advise.
    Thanks in advance.
    UPDATE: I ask SAP about this and they told me that this is only applicable to custom fields and not for SAP standard fields. They acknowledged that the documentation is somehow wrong since it did not say that it is only restricted to custom fields.
    Message was edited by: ABAPOne

    Hello,
    I was wondering if found an answer to your question (abou the debugger). I have a similar problem.
    Thank you,
    Jennet

  • Join hint ignored - very bad query plan results

    I'm trying to get a query that's being generated by SSAS to perform acceptably. Because this query is (at least partially) generated by SSAS, I don't have complete control over the query text.
    The problem - The query looks roughly like this:
    select
    -- a bunch of columns
    from
    T1 -- table with ~40,000,000 rows
    inner loop join T2 on T2.t2id = T1.t2id -- table with ~16,000 rows
    inner loop join T3 on T3.t3id = T1.t3id -- table with ~200,000 rows inner loop join T4 on T4.t4id = T1.t4id -- table with ~200,000 rows
    left loop join T5 on T5.t3id = T1.t3id and T5.t6id = T4.t6id -- table with 0 rows
    where
    -- some uninteresting conditions
    T1 is a Fact (or Measure) table, T2, T3 and T4 are Dimension tables, T5 and T6 are involved in the filtering of the query.  Every row of T1 WILL match exactly one row in each of T1, T2 and T3.
    You'll note that I've hinted all of the joins - according to the documentation, using join hints forces join order (which is consistent with the plan that's produced).  There's no mention that join hints can be transparently ignored by the optimizer,
    but that seems to be precisely what's happening.
    In the plan that results, the join to T4 is done as a hash join, with T1*T2*T3 (40,000,000 rows) on the "top", so it ends up trying to build a hash table with 40,000,000 rows, resulting in very high tempdb activity and very poor performance (I
    don't know how poor - I've never let it finish).
    I can see part of the reason why it's making this join choice - the estimate of T1*T2*T3 is only 35,000 rows, even though T1 has 40,000,000 rows and the join will hit on every row.
    Questions:
    1. What can I do to the query or the database to improve the estimate on the join to T3?
    2. What can I do to the query to force the optimizer to use a loop join like I asked? 
    Version is SQL Server 2008 R2 SP2 Developer Edition X64.
    OS is Windows 2008 R2
    Machine is dual-quad-hyper-threaded CPU with 96Gb of RAM and several Tb of disk spread over 8 spindles and SSDs.
    I've seen this query perform well before - I've been tuning this query for going on 7 years now and I've never seen it perform this badly that I can recall.  Not sure if it's something that's changed in SP2, or something about the distribution
    of data in this particular database that's changed, but something's sure changed.
    -cd Mark the best replies as answers!

    That would indicate that there are no foreign-key constraints, or if they, they are not trusted. (Assuming here that there WHERE clause includes no filter on T1.)
    That, or the statistics on T1 are giving a completely wrong estimates for the number of NULL values in t2id and t3id.
    Erland Sommarskog, SQL Server MVP, [email protected]
    Thanks, Erland.
    There are foreign key constraints, but they're NOCHECK.  I've tried creating and updating statistics on various columns of the tables involved - I'll re-check that I've got up to date statistics on all of the columns involved in these joins.
    What about the join-hint being ignored?  Is there anything I can do, or has something changed here recently?  Interestingly, when I run this query from SSMS, I get loop-joins all around, but when SSAS runs the query, the one join always comes out
    a hash join. Before I added the hints, all joins were hash joins - the hints worked on all joins but the one.
    -cd Mark the best replies as answers!

  • Bad Query Performance in Oracle Text

    Hello everyone, I have the following problem:
    I have a table, TABLE_A from now on, a table of more or less 1,000.000 rows, with a CONTEXT index, using FILE_DATASTORE, CTXSYS.DEFAULT_STORAGE, CTXSYS.NULL_FILTER, CTXSYS.BASIC_LEXER and querying the index in the following way:
    SELECT /*+FIRST_ROWS*/ A.ID, B.ID2, SCORE(1) FROM TABLE_A A, TABLE_B WHERE A.ID = B.ID AND CONTAINS(A.PATH, '<SOME KW>', 1) > 0 ORDER BY SCORE(1) DESC
    where TABLE_B has another 1,000.000 rows.
    The problem is that the query response time is much higher after some time of inactivity regarding those tables. How can I avoid this behavior?. The fact is that those inactivity times (not more than 20min) are core to my application, so I always get long long response times for my queries.
    Is there any cache or cache time parameter that affects this behavior? I have checked the Oracle Text documentation without finding anything about that...
    More data: I am using Oracle 9.2.0.1, but I have tested with the latest patches an the behavior is the same...
    Thank you very much in advance.

    Pablo,
    This appears to be a generic database or OS issue, not a Text specific issue. It really depends on what your application is doing.
    If your application is doing some other database activity such as queries or DMLs on other non-text tables, chances are Oracle Text related data blocks are being aged out of cache. You can either increase the db_cache_size init
    parmater or try to keep the text tables and index tables blocks in cache using ALTER TABLE commands.
    If your app is doing NON-database activity, then chances are your application is taking up much of the machine's physical memory such that OS is swapping ORACLE out of the memory. In which case, you may want to consider to add more memory to the machine or have ORACLE run on a separate machine by itself.

  • Bad Query Performance

    Hi Experts,
    I have a Query which was built on a multiprovider,Which has a slow preformance.
    I think the main problem comes from selecting to many records from
    I think it selects 1,1 million rows to display about 500 rows in the result.
    Another point could be that the complicated restricted and calculated keyfigures, especially might spend a lot of time in the OLAP processor.
    Here are the Statistics of the Query.
    OLAP Initialization      :  3,186906
    Wait Time, User         :   56,971169
    OLAP: Settings               0,983193
    Read Cache                     0,015642
    Delete Cache                   0,019030
    Write Cache                    0,087655
    Data Manager                   462,039167
    OLAP: Data Selection      0,671566
    OLAP: Data Transfer       1,257884.
    ST03 Stat:
    %OLAP       :22,74
    %DB           :77,18
    OLAP Time  :29,2
    DBTime        :99,1
    It seems that the maximum time is consuming in the Database
    Any suggestion to speed up this Query response time would be great.
    Thanks in advance.
    BR
    Srini.

    Hi,
    You need to have standard Query performance tuning done for the underlying cubes like better design, aggregates, etc
    Improve Performance of Queries/Reports on Multi Cubes
    Refer SAP Note Number: 869487
    Performance optimization for MultiCubes
    How to Create Efficient Multi-Provider Queries
    Please see the How to Guide "How to Create Efficient MultiProvider Queries" at http://service.sap.com/bi > SAP NetWeaver 2004 - Release-Specific Information > How-to Guides > Business Intelligence
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/biw/how%20to%20create%20efficient%20multiprovider%20queries.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3f66ba90-0201-0010-ac8d-b61d8fd9abe9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
    Performance of MultiProviders
    Multiprovider performance / aggregate question
    Query Performance
    Multicube performances
    Create Efficient MultiProvider Queries
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b03b7f4c-c270-2910-a8b8-91e0f6d77096
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/751be690-0201-0010-5e80-f4f92fb4e4ab
    Also try
    Achieving BI Query Performance Building Business Intelligence
    http://www.dmreview.com/issues/20051001/1038109-1.html
    tuning, short dumps
    Performance tuning in BW:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
    Also notes
    0000903559 MultiProvider optimization is only partially active
    0000825396 Performance in reports with many selections
    multiprovider explanation i need
    Note 629541 - Multiprovider: Parallel Processing 
    Thanks,
    JituK

  • HR BADI query

    Hi All ,
    In tcode pa30 we are creating a custom infotype and a subtype . When i do a F4 on the subtype the FM called is HR_F4_GET_SUBTYPE.
    This FM checks for a badi using code
      CALL FUNCTION 'HR_GET_BUSINESS_ADD_IN'
        EXPORTING
          exit_name      = 'HR_F4_GET_SUBTYPE'
          flt_val        = infty
        IMPORTING
          is_implemented = is_implemented
        CHANGING
          instance       = exit_obj.
    This FM checks if any BADI is activated exit_name = HR_F4_GET_SUBTYPE.
    I want to write some custom code and check if i can use this badi for my work.
    I have created an implementation ZHR_F4_GET_SUBTYPE. WRitten a small code in one of the methods ..
    BADI is activated . however when i debug pa30 and it comes to this code which checks whether badi is active .. it returns a sy-subrc 4.
    Could you please guide me where am i going wrong .. do i need to do some settings to activate the badi ?

    Thanks for replying,
    Ramesh - Yes both method and implementation is active .
    Satish -  I have not written any code in the method. I am presently checking if the badi can be used for my purpose.

  • How can this bad query be improved?

    Db:11.2.0.3
    We have a 3rd party app and the web app runs very slow. We want to make the 3rd party to fix the issue. for the
    app login process, I did an AWR , found the problem query it runs 10 mins. Then I did the sqltrace
    here is it:
    select clndr_id , count(*)
    from
    task where (clndr_id = :"SYS_B_0") group by clndr_id union select clndr_id ,
      count(*) from project where (clndr_id = :"SYS_B_1") group by clndr_id
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.01       0.00          0          0          0           0
    Fetch        2     53.32     612.03      81650      58920          0           2
    total        4     53.34     612.04      81650      58920          0           2
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 34  (PX)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             2          2          2  SORT UNIQUE (cr=58923 pr=81650 pw=22868 time=113329109 us cost=58277 size=24 card=2)
             2          2          2   UNION-ALL  (cr=58923 pr=81650 pw=22868 time=113329001 us)
             1          1          1    SORT GROUP BY NOSORT (cr=58330 pr=81070 pw=22868 time=104312437 us cost=58128 size=7 card=1)
       5589739    5589739    5589739     VIEW  index$_join$_003 (cr=58330 pr=81070 pw=22868 time=619784236 us cost=57240 size=38875249 card=5553607)
       5589739    5589739    5589739      HASH JOIN  (cr=58330 pr=81070 pw=22868 time=617373467 us)
       5590158    5590158    5590158       INDEX RANGE SCAN NDX_TASK_CALENDAR (cr=21676 pr=21676 pw=0 time=113637058 us cost=11057 size=38875249 card=5553607)(object id 24749)
       6673774    6673774    6673774       INDEX FAST FULL SCAN NDX_TASK_PROJ_RSRC (cr=36651 pr=36526 pw=0 time=213370625 us cost=21921 size=38875249 card=5553607)(object id 217274)
             1          1          1    SORT GROUP BY NOSORT (cr=593 pr=580 pw=0 time=9016527 us cost=149 size=17 card=1)
        136390     136390     136390     INDEX FAST FULL SCAN NDX_PROJECT_CALENDAR (cr=593 pr=580 pw=0 time=165434 us cost=132 size=2315876 card=136228)(object id 154409)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          2   SORT (UNIQUE)
          2    UNION-ALL
          1     SORT (GROUP BY NOSORT)
    5589739      TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'TASK'
                     (TABLE)
    5589739       INDEX   MODE: ANALYZED (RANGE SCAN) OF
                      'NDX_TASK_CALENDAR' (INDEX)
    5590158     SORT (GROUP BY NOSORT)
    6673774      INDEX   MODE: ANALYZED (RANGE SCAN) OF
                     'NDX_PROJECT_CALENDAR' (INDEX)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      Disk file operations I/O                        2        0.00          0.00
      db file sequential read                     22235        1.61        138.66
      direct path write                            1620        3.25        177.42
      db file scattered read                       2313        1.89        238.98
      direct path read                              385        1.72         19.52
      SQL*Net message from client                     2        0.11          0.21Please make your comments.
    Thanks in Advance.

    Salman Qureshi wrote:
    Hi,
    It looks to me that end result will give you distinct values because of distinct clndr_id. If my thinking is correct, can you use UNION ALL istead of UNION? This will reduce your query execution time by not spending time on removing duplication of results (UNION removes duplication).
    Do you have fresh statistics on the tables/indexes involved in this query?
    SalmanIt is a 3rd party app, not sure the query is exactly doing for, a good input though,
    I have given a try as comparison.
    Found
    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    UNION
    select clndr_id , count(*)
    from
    task where (clndr_id = :"SYS_B_0") group by clndr_id union select clndr_id ,
      count(*) from project where (clndr_id = :"SYS_B_1") group by clndr_id
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     31.18      70.39      25288      58920          0           2
    total        4     31.18      70.39      25288      58920          0           2
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 34  (PX)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             2          2          2  SORT UNIQUE (cr=58923 pr=25288 pw=25284 time=70390927 us cost=58277 size=24 card=2)
             2          2          2   UNION-ALL  (cr=58923 pr=25288 pw=25284 time=70390652 us)
             1          1          1    SORT GROUP BY NOSORT (cr=58330 pr=25288 pw=25284 time=70309151 us cost=58128 size=7 card=1)
       5589739    5589739    5589739     VIEW  index$_join$_003 (cr=58330 pr=25288 pw=25284 time=70027453 us cost=57240 size=38875249 card=5553607)
       5589739    5589739    5589739      HASH JOIN  (cr=58330 pr=25288 pw=25284 time=68083254 us)
       5590158    5590158    5590158       INDEX RANGE SCAN NDX_TASK_CALENDAR (cr=21676 pr=0 pw=0 time=2449897 us cost=11057 size=38875249 card=5553607)(object id 24749)
       6673774    6673774    6673774       INDEX FAST FULL SCAN NDX_TASK_PROJ_RSRC (cr=36651 pr=0 pw=0 time=3097204 us cost=21921 size=38875249 card=5553607)(object id 217274)
             1          1          1    SORT GROUP BY NOSORT (cr=593 pr=0 pw=0 time=81462 us cost=149 size=17 card=1)
        136390     136390     136390     INDEX FAST FULL SCAN NDX_PROJECT_CALENDAR (cr=593 pr=0 pw=0 time=68732 us cost=132 size=2315876 card=136228)(object id 154409)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          2   SORT (UNIQUE)
          2    UNION-ALL
          1     SORT (GROUP BY NOSORT)
    5589739      TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'TASK'
                     (TABLE)
    5589739       INDEX   MODE: ANALYZED (RANGE SCAN) OF
                      'NDX_TASK_CALENDAR' (INDEX)
    5590158     SORT (GROUP BY NOSORT)
    6673774      INDEX   MODE: ANALYZED (RANGE SCAN) OF
                     'NDX_PROJECT_CALENDAR' (INDEX)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      direct path write                            3347        1.59         43.26
      direct path read                              130        0.20          0.32
      SQL*Net message from client                     2        0.23          0.27
    ********************************************************************************$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    UNION ALL
    SQL ID: d6z3ag876m67h Plan Hash: 4277397671
    select clndr_id , count(*)
    from
    task where (clndr_id = :"SYS_B_0") group by clndr_id union all select
      clndr_id , count(*) from project where (clndr_id = :"SYS_B_1") group by
      clndr_id
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.01       0.00          0          0          0           0
    Fetch        2     31.77      89.93      22886      58920          0           2
    total        4     31.78      89.94      22886      58920          0           2
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 34  (PX)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             2          2          2  UNION-ALL  (cr=58932 pr=22887 pw=22868 time=89865448 us)
             1          1          1   SORT GROUP BY NOSORT (cr=58339 pr=22887 pw=22868 time=89865428 us cost=57240 size=7 card=1)
       5589739    5589739    5589739    VIEW  index$_join$_003 (cr=58339 pr=22887 pw=22868 time=302390812 us cost=57240 size=38875249 card=5553607)
       5589739    5589739    5589739     HASH JOIN  (cr=58339 pr=22887 pw=22868 time=300505731 us)
       5590158    5590158    5590158      INDEX RANGE SCAN NDX_TASK_CALENDAR (cr=21676 pr=0 pw=0 time=2275780 us cost=11057 size=38875249 card=5553607)(object id 24749)
       6673774    6673774    6673774      INDEX FAST FULL SCAN NDX_TASK_PROJ_RSRC (cr=36651 pr=18 pw=0 time=3233656 us cost=21921 size=38875249 card=5553607)(object id 217274)
             1          1          1   SORT GROUP BY NOSORT (cr=593 pr=0 pw=0 time=77989 us cost=132 size=17 card=1)
        136390     136390     136390    INDEX FAST FULL SCAN NDX_PROJECT_CALENDAR (cr=593 pr=0 pw=0 time=55006 us cost=132 size=2315876 card=136228)(object id 154409)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          2   UNION-ALL
          1    SORT (GROUP BY NOSORT)
    5589739     TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'TASK'
                    (TABLE)
    5589739      INDEX   MODE: ANALYZED (RANGE SCAN) OF 'NDX_TASK_CALENDAR'
                     (INDEX)
    5590158    SORT (GROUP BY NOSORT)
    6673774     INDEX   MODE: ANALYZED (RANGE SCAN) OF
                    'NDX_PROJECT_CALENDAR' (INDEX)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      Disk file operations I/O                        2        0.00          0.00
      direct path write                            2069        3.12         58.90
      db file sequential read                        18        0.78          4.35
      direct path read                               22        0.12          0.15
      SQL*Net message from client                     2        0.46          0.71
    ********************************************************************************found union all used 90s vs union 70s, and the logic and the physical reads are about the same.
    Notice that we now have it ran less that 2 mins for the query vs 10 mins before.
    The before was at the peak hrs and now it is off the peak. the disk read from peak's 81650 reduced to 22886.
    that was the cause of slow -- I/O contentions at peak hrs.
    How can we improve the query performance by increasing disk throughput?
    SQL> show parameter mem
    NAME                                 TYPE        VALUE
    hi_shared_memory_address             integer     0
    memory_max_target                    big integer 4000M
    memory_target                        big integer 3600M
    shared_memory_address                integer     0
    SQL> show parameter db_b
    NAME                                 TYPE        VALUE
    db_block_buffers                     integer     0
    db_block_checking                    string      FALSE
    db_block_checksum                    string      TYPICAL
    db_block_size                        integer     8192
    SQL> 

  • Re-write a bad query

    This query works fine for me but it's not a good query it might have performance issues.
    select count(*) from EMP.PENSIONS
    where FAILURE_ID = (SELECT max(FAILURE_ID) FROM EMP.PENSIONS ) and PERIOD = (select max(PERIOD) from EMP.PENSIONS )
    Can someone let me know the best way to re-write it ?

    Tuning form questions should include more info but I see one point that may help you.
    if you change it like this you will have to query the PENTIONS table only once and if you have an index on (FAILURE_ID, PERIOD ) that should be good for performance.
    select count(*) from EMP.PENSIONS
    where (FAILURE_ID, PERIOD ) IN (SELECT max(PERIOD) , max(FAILURE_ID) FROM EMP.PENSIONS )

  • ME_PROCESS_PO_CUST : BADI for ME21N

    Hi All,
    Can anybody help me how to define the syntax for changing a field on the purchase order header by using this BADI with method PROCESS_HEADER.
    It is not clear to me to program this logic (since I am not an ABAP OO expert) into this method. I want to default field IHREZ.
    thanks
    eric hassenberg
    Oasis consultants

    Hello,
    Did you obtain the badi for IHREZ ?
    Thaks,
    Vanesa

  • ME_PROCESS_PO_CUST BADI

    Hi All,
    I have implemented BADI defenition me_process_po_cust_badi.
    I have added the code in the method check.Now the problem is with the error message display.
    I have to show all the error messages line by line which got generated for each item.Which FM i have to use for this?
    Thanks

    If you're not afraid of objects you can also have a look at static method "cl_message_mm=>create".
    It has a parameter "im_business_obj" that lets you give the header/item your message relates to.
    Let say you implement the badi method "check(...)"
    - For passing the header in the parameter, you can use the BADI parameter "im_header" (interface is IF_PURCHASE_ORDER_MM).
    - If you want to pass an item in the parameter, you have to first get items using "im_header->get_items( )", and then pick your item from the returned table (field "ITEM" of table table row is of interface IF_PURCHASE_ORDER_ITEM_MM). In that case, the message will be linked to the item in the MM message display.
    - To prevent updates in case of error messages, check method "invalidate( )" of interfaces IF_PURCHASE_ORDER_MM and IF_PURCHASE_ORDER_ITEM_MM, and the parameter ch_failed of the badi.
    Hope this will help,

Maybe you are looking for

  • Field Merging in ALV

    Hi,      How to merge the repetitive entries of field, while displaying in ALV. For example:    In my internal table ITAB has 3 fields, VBELN, POSNR, AMOUNT.  If ITAB contains 1 record say 100 with 4 line items 10, 20, 30 & 40. I need to display it a

  • Photo orientation (portrait/landscape) differs between PC and Apple TV

    Hi, I have several pictures that have the correct portrait orientation when I watch them on the PC (with applications: PhotoShop, PaintShop, IrfanView, ...), however they are displayed in landscape on Apple.TV, resulting in a 90 degrees rotated pictu

  • Inbound Processing : Error when changing a BOM

    Hi Experts, I have the following error when I send a BOMMAT IDoc in "Change" Mode (Editing the BOM, to recreate the History inthe Target system) : Start processing in API: CSAP_MAT_BOM_MAINTAIN Group BOM Changes to the BOM exist after 03.11.2008 Date

  • [nQSError: 46036] Internal Assertion: Condition pExpr- IsValueExpr(), file

    Hello This is my first post so bear with me. I get the 46036 error from Answers when I add a field that I created in the BMM of the RPD. We are on OBIEE 10.3.4.1. I added a logical column to a table and inserted the following expression to filter the

  • Could not load DLL or external library

    When I open my TS781784.seq file, I receive the following Run-Time error(s): Run Time Error #1 Details: Could not load DLL or external library 'C:\EADS\DKH\TADS_3584\Development\TestProgramSets\PTS\TS781784\Sequence\TS781784.dll'. Error Code: -17004;