Why oracle text index column taking long  time

why oracle text index column is taking long time to return result.I created text index on a column if I run the query on a single table result is very fast.If I join table with other table (10 records only )
it is taking long time but in explain plan it is searching by index only.
I created this index for searching a varchar2 column,the data is comma seperated values like ( UK,US,IT,BR) and the table having records 20 lakhs.Normally if I query with like operater
( like '%US%' ) it is taking full table scan because I am using '%' both sides. Please help me on this regard how to search the data with less time. Here is may sample code and explain plan.
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Jan 28 16:54:22 2009
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> set timing on
SQL> set linesize 180
SQL> explain plan for SELECT T.esongid FROM (SELECT A.ESONGID FROM wcmedeco.EDECO_ESONGS_TERR_CTRY 
A WHERE CONTAINS(A.TERR_CTRY_NAMES,'US')>0  
  2  GROUP BY A.ESONGID)K,T
  3  WHERE  K.ESONGID=T.ESONGID;
Explained.
Elapsed: 00:00:00.01
SQL> select *from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id  | Operation                      |  Name                   | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT               |                         |     1 |    26 |     4 |
|   1 |  NESTED LOOPS                  |                         |     1 |    26 |     4 |
|   2 |   VIEW                         |                         |     1 |    13 |     4 |
|   3 |    SORT GROUP BY               |                         |     1 |    89 |     4 |
|   4 |     TABLE ACCESS BY INDEX ROWID| EDECO_ESONGS_TERR_CTRY  |     1 |    89 |     2 |
|   5 |      DOMAIN INDEX              | IDX_TERR_CTRY_NAMES     |       |       |     0 |
|   6 |   INDEX RANGE SCAN             | IDX_ESONGID_T           |     1 |    13 |     1 |
PLAN_TABLE_OUTPUT
Note: cpu costing is off, 'PLAN_TABLE' is old version
14 rows selected.
Elapsed: 00:00:00.00
SQL> Regards,
Rajasekhar

You have not formatted your code properly so we cannot see the query you're executing. Please put some line breaks in.
Secondly, how fresh are the statistics on those tables? Are you really returning one record out of twenty million?
Cheers, APC
blog: http://radiofreetooting.blogspot.com

Similar Messages

  • Oracle 10 gr studio taking long time to open the home/login page

    Hi,
    Oracle 10g studio taking the long time to open the home/ login page; when clicked on the launch workspace option.
    Thanks,
    Brijesh Kumar Singh.

    How much memory do you have in your machine?
    Are you running VMWare? How much physical (not logical) memory do you have allocated.
    What else do you have concurrently running on your machine?
    Dan

  • Create Index Step taking long time

    I have a create index step in process chain for a infocube. The Create Index step is takes more time. The requests in this cube are rolled up and compressed. The batch process are also avaliable. But still the create index step takes more time. Any suggestions to reduce the time of create index step?

    Hi,
    If you have more Data in Cube then it will take some time..check any Dumps in ST22 and SM21. Ask Basis Team any Error messages in DB02 and check.
    Else goto to RSRV
    Tests in Transaction RSRV --> Database --> Database Indices of an InfoCube and Its Aggregates
    Give Cube name and execute it and see the errors then if any RED color, ckick on Repaire Icon and see.
    Thanks
    Reddy

  • Index synchronization taking long time

    We are trying to do content search on documents in a table. We have around 320 Gigs of data on version 9.0.1.1.0 of IFS.
    When we try to run index synchronization on the table it has taken more than 48 hours and hasn't completed.
    begin
    ctx_ddl.sync_index ( idx_name => 'ifs_text' );
    end
    We can’t afford to let it run for that long.
    Any help is greatly appreciated.

    First try the easy things -
    * Increase the memory setting in your call to SYNC_INDEX - if you are able.
    * Run in parallel
    * Do it off-peak hours of course
    If still not acceptable, a couple of more questions will help clarify the situation some.
    * How many records are pending (ctx_pending)
    * Run ctx_report.describe_index and ctx_report.index_size and report those (send them to my e-mail if too big to post - [email protected] )
    I think the remainder of my questions will be answered by the ctx_report output. If you need help on ctx_report, I have an Oracle magazine article on the subject that might help you generate the output. It is at: http://www.oracle.com/technology/oramag/oracle/04-sep/o54text.html.
    -Ron

  • HT201250 my time capsule is taking too much time indexing backup and then taking longer time to back up ( 207 days ) or longer !!! what shall i do ?

    my time capsule is taking too much time indexing backup and then taking longer time to back up ( 207 days ) or longer !!! what shall i do ?

    Try 10.7.5 supplemental update.
    This update seems to have solved this problem for many.
    Best.

  • Help with creating oracle text index on 2 columns with partial html data

    Hi,
    I need to create an oracle text index on 2 columns.
    TITLE - varchar(255) = contains plain text data
    DESCRIPTION - CLOB = contains partial HTML data
    This is what I created.
    begin
    ctx_ddl.create_preference ('Title_Description_Pref', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('Title_Description_Pref', 'columns', 'TITLE, DESCRIPTION');
    end;
    begin
    ctx_ddl.create_preference ('bid_lexer', 'BASIC_LEXER');
    ctx_ddl.set_attribute('bid_lexer', 'index_stems', 'ENGLISH');
    ctx_ddl.create_section_group('htmgroup', 'HTML_SECTION_GROUP');
    end;
    create index Bid_Title_Index on Bid(title) indextype is ctxsys.context parameters ('LEXER bid_lexer sync (every "sysdate+(1/24)")');
    create index Bid_Title_Desc_Index on Bid(description) indextype is ctxsys.context parameters ('LEXER bid_lexer DATASTORE Title_Description_Pref sync (every "sysdate+(1/24)") filter ctxsys.null_filter section group htmgroup');
    The problem is when I do a CONTAINS(description, '$(auction)')>0. I get results where the descriptions have the "auction" word (which is correct). But, the results also returned rows where the search word is inside an IMG tag. e.g. <img src="http://auction.de/120483" alt="Auction Logo"/>.
    What I would like is to exclude rows where the search word is inside HTML tag attributes, results expected are rows having <a>Auction</a> or <p>For Auction</p> ... etc. Basically stripping the html tags and leave the text contents.
    I'd appreciate some input.
    Thanks,
    Amiel

    Hi,
    I need to create an oracle text index on 2 columns.
    TITLE - varchar(255) = contains plain text data
    DESCRIPTION - CLOB = contains partial HTML data
    This is what I created.
    begin
    ctx_ddl.create_preference ('Title_Description_Pref', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('Title_Description_Pref', 'columns', 'TITLE, DESCRIPTION');
    end;
    begin
    ctx_ddl.create_preference ('bid_lexer', 'BASIC_LEXER');
    ctx_ddl.set_attribute('bid_lexer', 'index_stems', 'ENGLISH');
    ctx_ddl.create_section_group('htmgroup', 'HTML_SECTION_GROUP');
    end;
    create index Bid_Title_Index on Bid(title) indextype is ctxsys.context parameters ('LEXER bid_lexer sync (every "sysdate+(1/24)")');
    create index Bid_Title_Desc_Index on Bid(description) indextype is ctxsys.context parameters ('LEXER bid_lexer DATASTORE Title_Description_Pref sync (every "sysdate+(1/24)") filter ctxsys.null_filter section group htmgroup');
    The problem is when I do a CONTAINS(description, '$(auction)')>0. I get results where the descriptions have the "auction" word (which is correct). But, the results also returned rows where the search word is inside an IMG tag. e.g. <img src="http://auction.de/120483" alt="Auction Logo"/>.
    What I would like is to exclude rows where the search word is inside HTML tag attributes, results expected are rows having <a>Auction</a> or <p>For Auction</p> ... etc. Basically stripping the html tags and leave the text contents.
    I'd appreciate some input.
    Thanks,
    Amiel

  • Report Taking long time in QA system

    Gurus,
    I have developed a report which works fine in dev.Though in QA system its performance is not okay.Please go through th ecode and help me through.
    TABLES: REGUH,BSAK,BSIS,LFA1,LFB1,BSAS.
    ****    Internal table declaration starts.
    ***    To Store Vendor clearing Document.
    ***    Internal table for credit card sub total.
    DATA : BEGIN OF I_BSAK OCCURS 0,
           XBLNR LIKE BSAK-XBLNR,
           LIFNR LIKE REGUH-LIFNR,
           PRCTR LIKE BSEG-PRCTR,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           GJAHR LIKE BSAK-GJAHR,
           BELNR LIKE BSAK-BELNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           HKONT LIKE BSEG-HKONT,
           END OF I_BSAK.
    ***    Internal table for Vendor sub total.
    DATA : BEGIN OF I_BSAK_LIFNR OCCURS 0,
           LIFNR LIKE REGUH-LIFNR,
           XBLNR LIKE BSAK-XBLNR,
           PRCTR LIKE BSEG-PRCTR,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           GJAHR LIKE BSAK-GJAHR,
           BELNR LIKE BSAK-BELNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           HKONT LIKE BSEG-HKONT,
           END OF I_BSAK_LIFNR.
    ***    Internal table for Profit center sub total.
    DATA : BEGIN OF I_BSAK_PRCTR OCCURS 0,
           PRCTR LIKE BSEG-PRCTR,
           BELNR LIKE BSAK-BELNR,
           GJAHR LIKE BSAK-GJAHR,
           LIFNR LIKE REGUH-LIFNR,
           XBLNR LIKE BSAK-XBLNR,
           HKONT LIKE BSEG-HKONT,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           END OF I_BSAK_PRCTR.
    ***  Work area for sub totals.
    DATA: WA LIKE I_BSAK.
    DATA : I_BSAK_INIT LIKE I_BSAK OCCURS 0 WITH HEADER LINE.
    ***    To store line item.
    DATA : BEGIN OF I_BSEG OCCURS 0,
           BELNR LIKE BSEG-BELNR,
           GJAHR LIKE BSEG-GJAHR,
           BUZEI LIKE BSEG-BUZEI,
           HKONT LIKE BSEG-HKONT,
           SHKZG LIKE BSEG-SHKZG,
           DMBTR LIKE BSEG-DMBTR,
           PRCTR LIKE BSEG-PRCTR,
           LIFNR LIKE REGUH-LIFNR,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR LIKE BSAK-XBLNR,
           XBLNR1 LIKE BSAK-XBLNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           NAME1 LIKE LFA1-NAME1,
           END OF I_BSEG.
    DATA : BEGIN OF I_BSEG_COPY OCCURS 0,
          PRCTR LIKE BSEG-PRCTR,
          BELNR LIKE BSEG-BELNR,
          GJAHR LIKE BSEG-GJAHR,
          BUZEI LIKE BSEG-BUZEI,
          HKONT LIKE BSEG-HKONT,
          SHKZG LIKE BSEG-SHKZG,
          DMBTR LIKE BSEG-DMBTR,
          LIFNR LIKE REGUH-LIFNR,
          AUGDT LIKE BSAK-AUGDT,
          AUGBL LIKE BSAK-AUGBL,
          XBLNR LIKE BSAK-XBLNR,
          XBLNR1 LIKE BSAK-XBLNR,
          BLDAT LIKE BSAK-BLDAT,
          BLART LIKE BSAK-BLART,
          NAME1 LIKE LFA1-NAME1,
          END OF I_BSEG_COPY.
    ***    To store GL account name
    DATA: BEGIN OF I_SKAT OCCURS 0,
          SAKNR LIKE SKAT-SAKNR,
          TXT50 LIKE SKAT-TXT50,
          END OF I_SKAT.
    ***   To store Vendor detail
    DATA: BEGIN OF I_LFA1 OCCURS 0,
          LIFNR LIKE LFA1-LIFNR,
          NAME1 LIKE LFA1-NAME1,
          KTOKK LIKE LFA1-KTOKK,
          END OF I_LFA1.
    DATA: I_INACT TYPE TABLE OF SY-UCOMM.
    ***  End of Internal table declaration.
    ***  Constant for company code
    CONSTANTS : C_BUKRS(4) VALUE '0010'.
    ***  Data declaration.
    DATA: FR_LAUFDT LIKE REGUH-LAUFD,
          TO_LAUFDT LIKE REGUH-LAUFD,
          COL,
          HEADING(80),
          HEADING1(10),
          HEADING2(80),
          AUTH_RESTRICT,
          G_DETAIL,
          G_SORTV,
          G_SORTP,
          G_SORTC,
          G_FLAG,
          V_XBLNR LIKE BSAK-XBLNR,
          V_UCOMM LIKE SY-UCOMM,
          V_AUGBL LIKE BSAS-AUGBL,
          V_BELNR LIKE BSAS-BELNR.
    DATA : BEGIN OF I_SEL OCCURS 0 ,
           AUGBL LIKE BSAK-AUGBL,
           END OF I_SEL.
    DATA: PROGNAME TYPE SY-REPID,
          DYNNUM   TYPE SY-DYNNR,
          DYNPRO_VALUES TYPE TABLE OF DYNPREAD,
          FIELD_VALUE LIKE LINE OF DYNPRO_VALUES,
          VALUES_TAB LIKE I_SEL OCCURS 0 WITH HEADER LINE.
    DATA : RETURN_TAB LIKE  DDSHRETVAL OCCURS 0 WITH HEADER LINE.
    ***  Selection screen.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(30) TXT_PD FOR FIELD P_LAUFDF.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS P_LAUFDF LIKE REGUH-LAUFD OBLIGATORY.
    SELECTION-SCREEN COMMENT 52(5) TXT_TO FOR FIELD P_LAUFDT.
    SELECTION-SCREEN POSITION POS_HIGH.
    PARAMETERS P_LAUFDT LIKE REGUH-LAUFD.
    SELECTION-SCREEN END OF LINE.
    SELECT-OPTIONS: S_KTOKK FOR LFA1-KTOKK.
    PARAMETERS: P_RWBTR LIKE REGUH-RWBTR.
    SELECT-OPTIONS: S_LIFNR FOR REGUH-LIFNR.
    * S_XBLNR FOR BSAK-XBLNR MATCHCODE OBJECT ZXBLNR.
    **** Added By Rajesh On 17 OCT 08 (DEVK914797) ****
    SELECT-OPTIONS: S_BELNR  FOR BSAK-BELNR.
    **** End of Addition By Rajesh *****
    *** Added By Samir On 04 Sep 08 (DEVK914623) ***
    SELECTION-SCREEN SKIP.
    PARAMETERS: CHK_REC AS CHECKBOX.
    *** End Of Addition By Samir ***
    SELECTION-SCREEN END OF BLOCK B1.
    ***  Initialization.
    INITIALIZATION.
      TXT_PD = 'Payment Date'.
      TXT_TO = 'to' .
      G_SORTC = 'X'.
    ***  At selection-screen.
    AT SELECTION-SCREEN.
      FR_LAUFDT =  P_LAUFDF.
      IF P_LAUFDT IS INITIAL.
        TO_LAUFDT = FR_LAUFDT.
      ELSE.
        IF P_LAUFDT LT P_LAUFDF.
          MESSAGE E000(ZMSG) WITH 'To Date is less than From date'.
        ENDIF.
        TO_LAUFDT = P_LAUFDT.
      ENDIF.
    ***  Heading.
      WRITE FR_LAUFDT TO HEADING1.
      WRITE TO_LAUFDT TO HEADING2.
      IF HEADING1 <> HEADING2.
        CONCATENATE 'Vendor Credit Card(s) Report for the Payment Date'
        HEADING1 'To' HEADING2 INTO HEADING2 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Vendor Credit Card(s) Report for the Payment Date'
        HEADING1 INTO HEADING2 SEPARATED BY SPACE.
      ENDIF.
    ***  Start of selection.
    START-OF-SELECTION.
      G_DETAIL = 'X'.
      PERFORM GET_DATA.
      PERFORM MODIFY_ITAB.                          "Process and for authority check.
    *** Added By Samir On 04 Sep 08 (DEVK914623) ***
    **** Changed By Rajesh On 17 OCT 08 (DEVK914797) ****
      IF CHK_REC = 'X'.
        LOOP AT I_BSAK.
          SELECT SINGLE BELNR
          INTO   V_BELNR
          FROM   BSAS
          WHERE  BUKRS = C_BUKRS
            AND  HKONT = '0000002012'
            AND  BELNR = I_BSAK-AUGBL
            AND  BUDAT = I_BSAK-AUGDT
            AND  BELNR IN S_BELNR.               " For displaying only reconciled items.
    **** End of Addition By Rajesh *****
          IF SY-SUBRC <> 0.
            DELETE I_BSAK.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *** End Of Addition By Samir ***
      LOOP AT I_BSAK.
        MOVE-CORRESPONDING I_BSAK TO: I_BSAK_LIFNR.
        APPEND: I_BSAK_LIFNR.
        CLEAR:  I_BSAK_LIFNR.
      ENDLOOP.
      LOOP AT I_BSAK.
        MOVE-CORRESPONDING I_BSAK TO: I_BSAK_PRCTR.
        READ TABLE I_BSEG WITH KEY BELNR = I_BSAK-BELNR.
        I_BSAK_PRCTR-HKONT = I_BSEG-HKONT.
        APPEND: I_BSAK_PRCTR.
        CLEAR:  I_BSAK_PRCTR.
      ENDLOOP.
    *loop at i_bseg.
    *   MOVE-CORRESPONDING I_BSAK TO: I_BSAK_PRCTR.
    *endloop.
    *perform write_data.
      PERFORM DISPLAY_OUTPUT.
    AT USER-COMMAND.
      CASE SY-UCOMM.
        WHEN 'EXPA'.
          G_DETAIL = 'X'.
        WHEN 'COLL'.
          CLEAR G_DETAIL.
        WHEN 'SORTV'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTV'.
          G_SORTV = 'X'.
          CLEAR G_SORTP.
          CLEAR G_SORTC.
        WHEN 'SORTC'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTC'.
          CLEAR G_SORTV.
          CLEAR G_SORTP.
          G_SORTC = 'X'.
        WHEN 'SORTP'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTP'.
          CLEAR G_SORTV.
          CLEAR G_SORTC.
          G_SORTP = 'X'.
      ENDCASE.
      PERFORM DISPLAY_OUTPUT.
    *perform write_data.
    ***  To get the header text in the output.
    TOP-OF-PAGE.
      PERFORM TOP_OF_PAGE.
    TOP-OF-PAGE DURING LINE-SELECTION.
      PERFORM TOP_OF_PAGE.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA .
      SY-LSIND = 0.
      P_RWBTR = P_RWBTR * -1.
      REFRESH I_BSAK_INIT.
      CLEAR I_BSAK_INIT.
      SELECT A~LIFNR A~LAUFD A~VBLNR A~RWBTR
              B~KTOKK B~NAME1
                FROM REGUH AS A INNER JOIN LFA1 AS B
                ON   A~LIFNR = B~LIFNR
                INTO CORRESPONDING FIELDS OF TABLE I_BSAK_INIT
                WHERE A~LAUFD BETWEEN FR_LAUFDT AND TO_LAUFDT AND
                      A~XVORL <> 'X' AND
                      A~ZBUKR = C_BUKRS  AND
                      A~LIFNR IN S_LIFNR AND
                      A~RZAWE = 'X' AND
                      A~RWBTR LE P_RWBTR AND
                      B~KTOKK IN S_KTOKK.
      IF SY-SUBRC <> 0.
        MESSAGE 'Records Not Found' TYPE 'I'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    *---------------------PERFORMANCE ISSUE--------------------------
    delete adjacent duplicates from i_bsak_init.
      IF NOT I_BSAK_INIT[] IS INITIAL.
       SELECT LIFNR AUGDT AUGBL GJAHR BELNR CPUDT BLDAT XBLNR
               BLART SHKZG DMBTR AUGGJ
                  FROM BSAK
                  INTO CORRESPONDING FIELDS OF TABLE I_BSAK
                  FOR ALL ENTRIES IN I_BSAK_INIT
                  WHERE BUKRS = C_BUKRS  AND
                  AUGBL = I_BSAK_INIT-VBLNR AND
                  XZAHL <> 'X'.
      ENDIF.
    ***  Selecting all line item records from BSEG table.
      IF I_BSAK[] IS NOT INITIAL.
        SELECT BELNR GJAHR BUZEI HKONT SHKZG DMBTR PRCTR
               FROM BSEG
               INTO CORRESPONDING FIELDS OF TABLE I_BSEG
               FOR ALL ENTRIES IN I_BSAK
               WHERE BUKRS = C_BUKRS      AND
                     BELNR = I_BSAK-BELNR AND
                     GJAHR = I_BSAK-GJAHR AND
                     BELNR <> I_BSAK-AUGBL AND
                     KOART <> 'K'.
      ENDIF.
    ***  Selecting gl account name from SKAT table.
      IF I_BSEG[] IS NOT INITIAL.
        SELECT SAKNR TXT50
               FROM SKAT
               INTO CORRESPONDING FIELDS OF TABLE I_SKAT
               FOR ALL ENTRIES IN I_BSEG
               WHERE SPRAS = 'E'     AND
                     KTOPL = C_BUKRS AND
                     SAKNR = I_BSEG-HKONT.
      ENDIF.
      SORT I_BSAK BY BELNR.
      SORT I_BSAK_INIT BY VBLNR.
      SORT I_BSEG BY BELNR GJAHR.
    *** Selecting Credit Card No. into I_XBLNR table.
      LOOP AT I_BSAK.
        I_BSAK-XBLNR1 = I_BSAK-XBLNR.
        CLEAR: V_XBLNR.
        SELECT SINGLE XBLNR FROM BKPF INTO V_XBLNR
                              WHERE BUKRS = C_BUKRS  AND
                              BELNR = I_BSAK-AUGBL.
        IF SY-SUBRC EQ 0.
          I_BSAK-XBLNR = V_XBLNR.
        ENDIF.
        READ TABLE I_BSEG WITH KEY BELNR = I_BSAK-BELNR
                                   GJAHR = I_BSAK-GJAHR
                                   BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          I_BSAK-PRCTR = I_BSEG-PRCTR.
        ENDIF.
        READ TABLE I_BSAK_INIT WITH KEY VBLNR = I_BSAK-AUGBL BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          I_BSAK-NAME1 = I_BSAK_INIT-NAME1.
          I_BSAK-LAUFD = I_BSAK_INIT-LAUFD.
          I_BSAK-KTOKK = I_BSAK_INIT-KTOKK.
        ENDIF.
        MODIFY I_BSAK TRANSPORTING XBLNR XBLNR1 PRCTR NAME1 LAUFD KTOKK.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  MODIFY_ITAB
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM MODIFY_ITAB .
    ***  Process on internal table
      LOOP AT I_BSAK.
        AUTHORITY-CHECK OBJECT 'F_LFA1_GRP'
                             ID 'KTOKK'
                          FIELD I_BSAK-KTOKK.
        IF SY-SUBRC NE 0.
          DELETE I_BSAK WHERE KTOKK EQ I_BSAK-KTOKK.
          AUTH_RESTRICT = 'X'.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      IF AUTH_RESTRICT EQ 'X'.
        MESSAGE S005(ZMSG).
      ENDIF.
      LOOP AT I_BSAK.
        IF I_BSAK-SHKZG = 'S'.
          I_BSAK-DMBTR = I_BSAK-DMBTR * -1.
          MODIFY I_BSAK .
        ENDIF.
      ENDLOOP.
      LOOP AT I_BSEG.
        IF I_BSEG-SHKZG = 'H'.
          I_BSEG-DMBTR = I_BSEG-DMBTR * -1.
          MODIFY I_BSEG .
        ENDIF.
      ENDLOOP.
    ***  Default Sorting on internal table .
      SORT I_BSAK BY XBLNR LIFNR BELNR.
      SORT I_BSEG BY BELNR HKONT.
      SORT I_SKAT BY SAKNR.
    ENDFORM.                    " MODIFY_ITAB
    *&      Form  DISPLAY_OUTPUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_OUTPUT .
    ***  Coding for detail output starts
      CLEAR SY-LSIND.
      REFRESH I_INACT.
      IF G_DETAIL EQ 'X'.
        APPEND 'EXPA' TO I_INACT.
      ELSE.
        APPEND 'COLL' TO I_INACT.
      ENDIF.
      IF G_SORTV EQ 'X'.
        APPEND 'SORTV' TO I_INACT.
        SORT I_BSAK BY LIFNR.
        SORT I_BSAK_LIFNR BY LIFNR.
      ELSEIF G_SORTP EQ 'X'.
        APPEND 'SORTP' TO I_INACT.
        SORT I_BSAK BY PRCTR.
        SORT I_BSAK_PRCTR BY PRCTR.
      ELSE.
        APPEND 'SORTC' TO I_INACT.
        SORT I_BSAK BY XBLNR.
      ENDIF.
      SET PF-STATUS 'STAT' EXCLUDING I_INACT.
      IF V_UCOMM = 'SORTC'.
        PERFORM WRITE_DATA.
      ELSEIF V_UCOMM = 'SORTV' .     "Subroutine for card sub total.
        PERFORM WRITE_DATA_VENDOR.   "Subroutine for vendor sub total.
      ELSEIF V_UCOMM = 'SORTP'.      "Subroutine for profit center sub total.
    *    PERFORM WRITE_DATA_PROFIT.
        PERFORM WRITE_DATA_PROFIT_NEW.  " New subroutine for profit center.
      ELSE.
        PERFORM WRITE_DATA.
      ENDIF.
    ENDFORM.                    " DISPLAY_OUTPUT
    *&      Form  F_COLOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_COLOR .
      IF COL = 'X'.
        FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
        CLEAR COL.
      ELSE.
        FORMAT COLOR COL_NORMAL INTENSIFIED ON.
        COL = 'X'.
      ENDIF.
    ENDFORM.                    " F_COLOR
    *&      Form  TOP_OF_PAGE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM TOP_OF_PAGE .
    ***  Top-of-page is Common for summary and detail report.
    ***  To display top of page only on first page.
      IF SY-PAGNO = 1 .
        CALL FUNCTION 'Z_NPL_HEADING'
          EXPORTING
            LINE_SIZE = SY-LINSZ
            HEADING1  = HEADING
            HEADING2  = HEADING2.
        FORMAT COLOR COL_HEADING INTENSIFIED ON.
    ****  To get output columns text descprition
        ULINE.
        WRITE:/ SY-VLINE NO-GAP, (10) 'Vendor' NO-GAP,
                SY-VLINE NO-GAP, (35) 'Name of Payee' NO-GAP,
                SY-VLINE NO-GAP, (10) 'G/L Num' NO-GAP,
                SY-VLINE NO-GAP, (42) 'G/L Name' NO-GAP,
                SY-VLINE NO-GAP, (07) 'Profit Center' NO-GAP,
                SY-VLINE NO-GAP, (16) 'Credit Card NO.' NO-GAP,
                SY-VLINE NO-GAP, (10) 'Pmnt Date' NO-GAP,
                SY-VLINE NO-GAP, (08) 'Doc.Type' NO-GAP,
                SY-VLINE NO-GAP, (10) 'Inv.Date' NO-GAP,
                SY-VLINE NO-GAP, (16) 'Invoice' NO-GAP,
                SY-VLINE NO-GAP, (14) 'Amount Paid' NO-GAP,
                SY-VLINE.
        ULINE.
      ENDIF.
    ENDFORM.                    " TOP_OF_PAGE
    *&      Form  WRITE_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA .
      LOOP AT I_BSAK.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSAK TO WA.
        PERFORM WRITE.
        AT END OF XBLNR.                             "Card sub total
          IF G_SORTC EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
            WRITE:/ SY-VLINE NO-GAP, (25) 'Credit Card Total:', I_BSAK-XBLNR ,
                    (35) I_BSAK-NAME1 NO-GAP.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Credit card Detail
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK loop
    ENDFORM.                    " WRITE_DATA
    *&      Form  WRITE_DATA_VENDOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_VENDOR .
      LOOP AT I_BSAK_LIFNR.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSAK_LIFNR TO WA.
        PERFORM WRITE.
        AT END OF LIFNR.                           "Vendor sub Total
          IF G_SORTV EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(15) 'Vendor Total:', I_BSAK_LIFNR-LIFNR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK_LIFNR-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Vendor Total
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK_LIFNR-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_LIFNR loop
    ENDFORM.                    " WRITE_DATA_VENDOR
    *&      Form  WRITE_DATA_PROFIT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_PROFIT .
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
      LOOP AT I_BSAK_PRCTR.
        READ TABLE I_BSAK WITH KEY BELNR = I_BSAK_PRCTR-BELNR
                                   GJAHR = I_BSAK_PRCTR-GJAHR.
        IF SY-SUBRC = 0.
          I_BSAK_PRCTR-LIFNR  = I_BSAK-LIFNR.
          I_BSAK_PRCTR-NAME1  = I_BSAK-NAME1.
          I_BSAK_PRCTR-XBLNR  = I_BSAK-XBLNR.
          I_BSAK_PRCTR-LAUFD  = I_BSAK-LAUFD.
          I_BSAK_PRCTR-BLART  = I_BSAK-BLART.
          I_BSAK_PRCTR-BLDAT  = I_BSAK-BLDAT.
          I_BSAK_PRCTR-XBLNR1 = I_BSAK-XBLNR1.
          MODIFY I_BSAK_PRCTR TRANSPORTING LIFNR NAME1 XBLNR LAUFD BLART BLDAT XBLNR1.
        ENDIF.
      ENDLOOP.
    *** End Of Changes By Samir On 18 Sep 08 ***
      SORT I_BSAK_PRCTR BY PRCTR.
      LOOP AT I_BSAK_PRCTR.
        PERFORM F_COLOR.
        IF G_DETAIL = 'X'.
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
          READ TABLE I_SKAT WITH KEY SAKNR = I_BSAK_PRCTR-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) I_BSAK_PRCTR-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
                  SY-VLINE NO-GAP, (07) I_BSAK_PRCTR-PRCTR NO-GAP,
                  SY-VLINE NO-GAP, (16) I_BSAK_PRCTR-XBLNR NO-GAP,     " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) I_BSAK_PRCTR-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) I_BSAK_PRCTR-XBLNR1 NO-GAP.
          WRITE:  SY-VLINE NO-GAP, (14) I_BSAK_PRCTR-DMBTR NO-GAP.
          WRITE:  SY-VLINE.
        ENDIF.
    *** End Of Changes By Samir On 18 Sep 08 ***
        AT END OF PRCTR.                           "Profit Center sub Total
          IF G_SORTP EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(07) 'Profit Center Total:', I_BSAK_PRCTR-PRCTR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK_PRCTR-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                    "End of Profit Center Total
    ****  Grand total
        AT LAST.                                  "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK_PRCTR-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_PRCTR loop
    ENDFORM.                    " WRITE_DATA_PROFIT
    *&      Form  WRITE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE .
      IF G_DETAIL = 'X'.
        IF WA-KTOKK = 'Z001'.                   " For HR Vendors
          PERFORM F_COLOR.
          READ TABLE I_BSEG WITH KEY BELNR = WA-BELNR GJAHR = WA-GJAHR BINARY SEARCH .
          READ TABLE I_SKAT WITH KEY SAKNR = I_BSEG-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSEG-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
    *             SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
                  SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 18 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,        " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14) WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
        ELSE.
          LOOP AT I_BSEG WHERE BELNR = WA-BELNR AND GJAHR = WA-GJAHR .
            PERFORM F_COLOR.
            READ TABLE I_SKAT WITH KEY SAKNR = I_BSEG-HKONT BINARY SEARCH.
            WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                    SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                    SY-VLINE NO-GAP, (10) I_BSEG-HKONT NO-GAP,
                    SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 17 Sep 08 (DEVK914671) ***
    *               SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
                    SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 17 Sep 08 ***
                    SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,     " CREDIT CARD NO.
                    SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                    SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                    SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                    SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
            WRITE: SY-VLINE NO-GAP, (14)  I_BSEG-DMBTR NO-GAP.
            WRITE: SY-VLINE.
          ENDLOOP.                                 "End   for I_BSEG loop
        ENDIF.                                     "Endif for I_PAYR-KTOKK = 'Z001'
      ENDIF.                                       "Endif for g_detail = 'X'.
    ENDFORM.                    " WRITE
    *&      Form  WRITE_DATA_PROFIT_NEW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_PROFIT_NEW .
      REFRESH I_BSEG_COPY.
      CLEAR I_BSEG_COPY.
    *  DATA I_BSEG_COPY LIKE I_BSEG OCCURS 0 WITH HEADER LINE.
    *  I_BSEG_COPY[] = I_BSEG[].
      LOOP AT I_BSEG.
        MOVE-CORRESPONDING I_BSEG TO I_BSEG_COPY.
        APPEND I_BSEG_COPY.
        CLEAR I_BSEG_COPY.
      ENDLOOP.
      LOOP AT I_BSEG_COPY.
        READ TABLE I_BSAK_PRCTR WITH KEY BELNR = I_BSEG_COPY-BELNR GJAHR = I_BSEG_COPY-GJAHR ."HKONT = I_BSEG_COPY-HKONT.
        IF SY-SUBRC = 0.
          I_BSEG_COPY-LIFNR = I_BSAK_PRCTR-LIFNR.
          I_BSEG_COPY-XBLNR = I_BSAK_PRCTR-XBLNR.
          I_BSEG_COPY-NAME1 = I_BSAK_PRCTR-NAME1.
          I_BSEG_COPY-AUGDT = I_BSAK_PRCTR-AUGDT.
          I_BSEG_COPY-AUGBL = I_BSAK_PRCTR-AUGBL.
          I_BSEG_COPY-XBLNR1 = I_BSAK_PRCTR-XBLNR1.
          I_BSEG_COPY-BLDAT = I_BSAK_PRCTR-BLDAT.
          I_BSEG_COPY-BLART = I_BSAK_PRCTR-BLART.
          MODIFY I_BSEG_COPY TRANSPORTING LIFNR XBLNR NAME1 AUGDT AUGBL XBLNR1 BLDAT BLART.
        ENDIF.
      ENDLOOP.
      SORT I_BSAK_PRCTR BY PRCTR BELNR.
      SORT I_BSEG BY BELNR.
      SORT I_BSEG_COPY BY PRCTR.
      DATA COUNT TYPE I.
      DATA G_BELNR LIKE BSAK-BELNR.
      LOOP AT I_BSEG_COPY.
        CLEAR G_BELNR.
        G_BELNR = I_BSEG_COPY-BELNR.
        COUNT = COUNT + 1.
        READ TABLE I_BSAK WITH KEY BELNR = I_BSEG_COPY-BELNR.
        IF SY-SUBRC <> 0.
          DELETE I_BSEG_COPY WHERE BELNR = G_BELNR."INDEX count.
        ENDIF.
      ENDLOOP.
    *  LOOP AT I_BSAK_PRCTR.
      LOOP AT I_BSEG_COPY.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSEG_COPY TO WA.
        PERFORM WRITE_PRCTR.
        AT END OF PRCTR.                           "Profit center sub Total
          IF G_SORTP EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(20) 'Profit Center Total:', I_BSEG_COPY-PRCTR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSEG_COPY-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Vendor Total
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSEG_COPY-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_LIFNR loop
    *ENDFORM.                    " WRITE_DATA_VENDOR
    ENDFORM.                    " WRITE_DATA_PROFIT_NEW
    *&      Form  WRITE_PRCTR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_PRCTR .
      IF G_DETAIL = 'X'.
        IF WA-KTOKK = 'Z001'.                   " For HR Vendors
          PERFORM F_COLOR.
    *      READ TABLE I_BSEG WITH KEY BELNR = WA-BELNR GJAHR = WA-GJAHR PRCTR = WA-PRCTR BINARY SEARCH .
          READ TABLE I_SKAT WITH KEY SAKNR = WA-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
                  SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
    *             SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 18 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,        " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14) WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
        ELSE.
    *      LOOP AT I_BSEG WHERE BELNR = WA-BELNR AND GJAHR = WA-GJAHR AND PRCTR = WA-PRCTR .
          PERFORM F_COLOR.
          READ TABLE I_SKAT WITH KEY SAKNR = WA-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 17 Sep 08 (DEVK914671) ***
                 SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
    *              SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 17 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,     " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14)  WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
    *      ENDLOOP.                                 "End   for I_BSEG loop
        ENDIF.                                     "Endif for I_PAYR-KTOKK = 'Z001'
      ENDIF.                                       "Endif for g_detail = 'X'.
    ENDFORM.                    " WRITE_PRCTR
    Thanks in advance
    Raj.

    Ralph,
    Thanks for the reply.
    I have marked the sql statement in the code that is taking long time to run but Its my mistake not explaining the same in the description.
    When I was debugging the code the below sql statement was taking long time.
      IF NOT I_BSAK_INIT[] IS INITIAL.
       SELECT LIFNR AUGDT AUGBL GJAHR BELNR CPUDT BLDAT XBLNR
               BLART SHKZG DMBTR AUGGJ
                  FROM BSAK
                  INTO CORRESPONDING FIELDS OF TABLE I_BSAK
                  FOR ALL ENTRIES IN I_BSAK_INIT
                  WHERE BUKRS = C_BUKRS  AND
                  AUGBL = I_BSAK_INIT-VBLNR AND
                  XZAHL <> 'X'.
      ENDIF.
    Any suggestions on the code?
    Regards,
    Raj.

  • Create index is taking more time

    Hi,
    One of the concurrent program is taking more time , We generate the trace file and found that the create index is taking more time.
    Below is from the trace file and such type of index creation is happening lot of time in Oracle standard program.
    Can somebody let me know why there is a big difference between cpu and elapse time.
    We are seeing the PX Deq: Execute Reply Event as well.look idle time for database.
    Please let me know which parameter of the database is affecting this.
    CREATE INDEX ITEM_CATEGORIES_N2_BD9 ON ITEM_CATEGORIES_BD9(CATEGORY_SET_ID,
    SR_CATEGORY_ID,ORGANIZATION_ID,SR_INSTANCE_ID) PARALLEL TABLESPACE MSCX
    STORAGE( INITIAL 40960 NEXT 33554432 PCTINCREASE 0) PCTFREE 10 INITRANS 11
    MAXTRANS 255
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 3 0 0
    Execute 1 0.35 364.82 131168 117945 60324 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.35 364.83 131168 117948 60324 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 80 (recursive depth: 2)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    reliable message 1 0.00 0.00
    enq: KO - fast object checkpoint 1 0.01 0.01
    PX Deq: Join ACK 6 0.00 0.00
    PX Deq Credit: send blkd 112 0.00 0.01
    PX qref latch 7 0.00 0.00
    PX Deq: Parse Reply 3 0.00 0.00
    PX Deq: Execute Reply 604 1.96 364.42
    log file sync 1 0.00 0.00
    PX Deq: Signal ACK 1 0.00 0.00
    latch: session allocation 2 0.00 0.00
    Regards,

    user12121524 wrote:
    CREATE  INDEX ITEM_CATEGORIES_N2_BD9 ON ITEM_CATEGORIES_BD9(CATEGORY_SET_ID,
    SR_CATEGORY_ID,ORGANIZATION_ID,SR_INSTANCE_ID) PARALLEL  TABLESPACE MSCX
    STORAGE(  INITIAL 40960 NEXT 33554432 PCTINCREASE 0) PCTFREE 10 INITRANS 11
    MAXTRANS 255
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          3          0           0
    Execute      1      0.35     364.82     131168     117945      60324           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.35     364.83     131168     117948      60324           0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 80     (recursive depth: 2)
    Elapsed times include waiting on following events:
    Event waited on                             Times   Max. Wait  Total Waited
    ----------------------------------------   Waited  ----------  ------------
    reliable message                                1        0.00          0.00
    enq: KO - fast object checkpoint                1        0.01          0.01
    PX Deq: Join ACK                                6        0.00          0.00
    PX Deq Credit: send blkd                      112        0.00          0.01
    PX qref latch                                   7        0.00          0.00
    PX Deq: Parse Reply                             3        0.00          0.00
    PX Deq: Execute Reply                         604        1.96        364.42
    log file sync                                   1        0.00          0.00
    PX Deq: Signal ACK                              1        0.00          0.00
    latch: session allocation                       2        0.00          0.00
    What you've given us is the query co-ordinator trace, which basically tells us that the the coordinator waited 364 seconds for the PX slaves to tell it that they had completed their tasks ("PX Deq: Execute Reply" time). You need to look at the slave traces to find out where they spent their time - and that's probably not going to be easy if there are lots of parallel pieces of processing going on.
    If you want to do some debugging (in general) one option is to add a query against V$pq_tqstat after each piece of parallel processing and log the results to a named file, or write them to a table with a tag, as this will tell you how many slaves were involved, how, and what the distribution of work and time was.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan

  • Query taking long time for EXTRACTING the data more than 24 hours

    Hi ,
    Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
    SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
    2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
    to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
    to_char(nvl(i.payment_due_date,
    to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
    due_date, ah.current_balance-ah.previous_balance amount,
    decode(ah.invoice_id,null,'A','I') transaction_type
    3 4 5 6 7 8 from account a,account_history ah,invoice i_+
    where a.account_id=ah.account_id
    and a.account_type_id=1000002
    and round(a.account_balance,2) > 0
    and (ah.invoice_id is not null or ah.adjustment_id is not null)
    and ah.CURRENT_BALANCE > ah.previous_balance
    and ah.invoice_id=i.invoice_id(+)
    AND a.account_balance > 0
    order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
    | 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
    |* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
    |* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
    |* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
    |* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
    | 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
    Predicate Information (identified by operation id):
    2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
    3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
    ROUND("A"."ACCOUNT_BALANCE",2)>0)
    4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
    5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
    IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
    22 rows selected.
    Index Details:+_
    SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
    2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
    INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
    OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
    OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
    OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
    32 rows selected.
    Regards,
    Bathula
    Oracle-DBA

    I have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
    Also, you do not need two lines for these conditions:
    and round(a.account_balance, 2) > 0
    AND a.account_balance > 0
    You can just use: and a.account_balance >= 0.005
    So the formatted query isselect a.account_id,
           round(a.account_balance, 2) account_balance,
           nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
           to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
           to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
                   'DD-MON-YYYY') due_date,
           ah.current_balance - ah.previous_balance amount,
           decode(ah.invoice_id, null, 'A', 'I') transaction_type
      from account a, account_history ah, invoice i
    where a.account_id = ah.account_id
       and a.account_type_id = 1000002
       and (ah.invoice_id is not null or ah.adjustment_id is not null)
       and ah.CURRENT_BALANCE > ah.previous_balance
       and ah.invoice_id = i.invoice_id(+)
       AND a.account_balance >= .005
    order by a.account_id, ah.effective_start_date desc;You will probably want to select:
    1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
    2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
    3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
    Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
    create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
    create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
    Try the query after creating these indexes.
    A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
    alter session set sort_area_size = 2147483647;
    alter session set hash_area_size = 2147483647;

  • Sql code taking long time

    Hello Everyone,
    In Oracle 10g,I have table emp_history and column name hired_date,which has the
    values in the following format 7/8/2011 12:55:55 PM
    ('mm/dd/yyyy hh12:mi:ss AM') ana this table has more than 50 thousand records,
    when I tried to get the employees whose hired_date between 01/04/2011 and 30/04/2011
    its taking long time(16 to 19 minutes) just to fetch 845 records.
    I tried the following codes,
    select * from emp_history where to_char(hired_date,'mmddyyyy') between
    04012011' and 04302011' and ...;and
      select * from emp_history where to_char(hired_date,'ddmmyyyy') between
    '01042011' and 30042011' and ....It having some other where condition also but If I commented the above where condition alone its working fine,
    If I include i taking long time.
    Can anyone tell me how to modify the code.
    Thank you.
    Edited by: Gurujothi on Aug 3, 2012 4:21 AM

    Do you have an index on HIRED_DATE column? If yes then your index will not be considered.
    You need to write your query like this.
    select *
      from emp_history
    where hired_date between to_date('04012011', 'mmddyyyy') and (to_date('04302011', 'mmddyyyy') + 1) - interval '1' second
       and ...;Use of function on a column makes that column index unusable.
    Further to assist you please read the following link and post the required details
    {message:id=9360003}

  • Delete statements are taking longer time

    Hi All,
    I have an issue with delete statement. below are my oracle DB details.
    SQL>select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    TNS for Linux: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    I have a schema in the database which has 120 tables in it. The problem is, when the QA team is deleting the customers from customer table, it is running long time and haven't completed. this customer table have FK relation with other tables and have all the right indexes in place. then i have tried to identified the problem, why it is taking long time, and found that when they are running this delete query at the same time application is also running. the sessions created by application are locked most of the table and at the same time the delete session is also waiting for exclusive lock on those table. I given the same info to QA team and asked to stop the application when they deleting the customers. Then they said, they don't want to stop the application and the delete has to work and they asked for different solution. Here i am not sure, what solution i need to provide them.
    Can you please suggest me a approach and Thanks in advance.

    Hari wrote:
    and at the same time the delete session is also waiting for exclusive lock on those table. The only way the delete session could be waiting for an exclusive lock on the table is if the code to delete from the customer includes the command: lock table customer in exclusive mode;Unless your original description is wrong, either the deletion code has to change or the application has to stop modifying the customer table.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • Oracle Text Index on Materialized View

    Hello,
    I have designed a search engine for an internet application.
    We have different tables for our main business objects, the search is based on the content of all these dependent entities (Product, Company etc...)
    So I have created a materialized view to embody this aggregation.
    Then I have created a Multi column datastore index on top of the snapshot.
    The search engine has to be refreshed automatically 3 times a day, and manually anytime.
    This is achieved by executing a complete refresh on the view and rebuild the index, programmatically via Toplink (SqlCall).
    The MV refresh looks like this :
    alter index usr_batiprod.fullTextMulticolIdx rebuild
    and the index rebuild:
    begin
    DBMS_MVIEW.REFRESH('FT_TEST','C');
    end;
    Everything was fine until now, we have had lots of tuning on the index side, the refresh process was working fine...
    We have let the users access the engine since Thursday (the index had been created on the production environment a fews weeks ago) and since yesterday (or maybe before) we have been experiencing data incoherency on the index...
    I've tracked down the pb to the Fulltext Search's refresh process (manual and automatic share the same code) that was crashing on the Materialized view refresh :
    java.sql.SQLException: ORA-20000: Oracle Text error:
    DRG-50610: internal error: drexdsync
    DRG-50857: oracle error in drekrtd (lob erase)
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 832
    ORA-06512: at line 2
    Again, we had tested the functionality thoroughly and never experienced such behaviour before... even while refreshing the materialized view and the index 3 times (or more) a day..
    Once I dropped the Oracle Text Index, I was able to refresh the MV again..
    so it looks like the index was in some incoherent state and was holding a lock on the materialized view...
    Maybe my Index refresh call is wrong, and a stronger load on the functionality leads quickly to this pb, I dont know..
    I had always been a bit doubtful towards my index rebuild call, so Im thinking about using a more complete call :
    alter index usr_batiprod.fullTextMulticolIdx rebuild parameters ('sync')
    is it enough, or do I have to switch to a 'Oracle Text' specific call ?
    Is there another possible reason for the MV lock ?
    Thank you for your support
    Best Regards
    Olivier Cuzacq

    MVs are constructed in different ways and have lots of different uses.
    Why not just use MV as temp table for OT (Oracle Text) index?
    Refresh MV OT_TEMP.
    Delete all not matching rows from OT.
    Insert all missing missing rows from OT_TEMP to OT.
    sync OT index (online).
    Query table OT.

  • Connecting to the database taking long time to connect database server

    Hi
    When I execute procedure i am getting the below message at bottom of the Oracle SQL Developer
    "Connecting to the database"
    it is taking more than 10 min plz guide

    Hi
    have you installed a normal Oracle Client also on your Host? normal Oracle Client
    Did you connect with host:port:sid or with a Oracle Naming Service? through TNS Service
    Can you test tnsping <alias> yes, It is working fine
    Did other user have the same problem? yes
    Did you connect through WAN or LAN connection? LAN (Intranet)
    Can you tell more about you client/database setup?
    Database setup:
    OS: Window 2008 server
    version: 11.1.0
    Client: 11.1.0
    OS: Window 2008 server
    Now I am not able to execute single select query which table contains 6 records and 15 columns it is taking long time I have waited 30 min still no resutls
    only one table is behaving like this remaining is working fine
    Edited by: user9235224 on Oct 6, 2012 7:06 PM

  • Simple query is taking long time

    Hi Experts,
    The below query is taking long time.
    [code]SELECT   FS.*
      FROM   ORL.FAX_STAGE FS
             INNER JOIN
                   ORL.FAX_SOURCE FSRC
                INNER JOIN
                   GLOBAL_BU_MAPPING GBM
                ON GBM.BU_ID = FSRC.BUID
             ON UPPER (FSRC.FAX_NUMBER) = UPPER (FS.DESTINATION)
    WHERE       FSRC.IS_DELETED = 'N'
             AND GBM.BU_ID IS NOT NULL
             AND UPPER (FS.FAX_STATUS) ='COMPLETED';[/code]
    this query is returning 1645457 records.
    [code]PLAN_TABLE_OUTPUT
    | Id  | Operation           | Name                   | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT    |                        |   625K|   341M| 45113   (1)|
    |   1 |  HASH JOIN          |                        |   625K|   341M| 45113   (1)|
    |   2 |   NESTED LOOPS      |                        |   611 | 14664 |    22   (0)|
    |   3 |    TABLE ACCESS FULL| FAX_SOURCE             |  2290 | 48090 |    22   (0)|
    |   4 |    INDEX RANGE SCAN | GLOBAL_BU_MAPPING_BUID |     1 |     3 |     0   (0)|
    |   5 |   TABLE ACCESS FULL | FAX_STAGE              |  2324K|  1214M| 45076   (1)|
    PLAN_TABLE_OUTPUT
    Note
       - 'PLAN_TABLE' is old version
    15 rows selected.[/code]
    The distinct number of records in each table.
    [code]SELECT FAX_STATUS,count(*)
    FROM fax_STAGE
    GROUP BY FAX_STATUS;
    FAX_STATUS    COUNT(*)
    BROKEN          10
    Broken - New    9
    Completed    2324493
    New             20
    SELECT is_deleted,COUNT(*)
    FROM  FAX_SOURCE
    GROUP BY IS_DELETED;
    IS_DELETED COUNT(*)
    N         2290
    Y         78[/code]
    Total number of records in each table.
    [code]SELECT COUNT(*) FROM ORL.FAX_SOURCE FSRC-- 2368
    SELECT COUNT(*) FROM ORL.FAX_STAGE--2324532
    SELECT COUNT(*) FROM APPS_GLOBAL.GLOBAL_BU_MAPPING--9
    [/code]
    To improve the performance of this query I have created the following indexes.
    [code]Functional based index on UPPER (FSRC.FAX_NUMBER) ,UPPER (FS.DESTINATION) and UPPER (FS.FAX_STATUS).
    Bitmap index on FSRC.IS_DELETED.
    Normal Index on GBM.BU_ID and FSRC.BUID.
    [/code]
    But still the performance is bad for this query.
    What can I do apart from this to improve the performance of this query.
    Please help me .
    Thanks in advance.

    <I have created the following indexes.
    CREATE INDEX ORL.IDX_DESTINATION_RAM ON ORL.FAX_STAGE(UPPER("DESTINATION"))
    CREATE INDEX ORL.IDX_FAX_STATUS_RAM ON ORL.FAX_STAGE(LOWER("FAX_STATUS"))
    CREATE INDEX ORL.IDX_UPPER_FAX_STATUS_RAM ON ORL.FAX_STAGE(UPPER("FAX_STATUS"))
    CREATE INDEX ORL.IDX_BUID_RAM ON ORL.FAX_SOURCE(BUID)
    CREATE INDEX ORL.IDX_FAX_NUMBER_RAM ON ORL.FAX_SOURCE(UPPER("FAX_NUMBER"))
    CREATE BITMAP INDEX ORL.IDX_IS_DELETED_RAM ON ORL.FAX_SOURCE(IS_DELETED)
    After creating the following indexes performance got improved.
    But our DBA said that new BITMAP index at FAX_SOURCE table (ORL.IDX_IS_DELETED_RAM) can cause locks
    on multiple rows if IS_DELETED column is in use. Please proceed with detailed tests.
    I am sending the explain plan before creating indexes and after indexes has been created.
    SELECT  FS.*
    FROM  ORL.FAX_STAGE FS
                    INNER JOIN
                    ORL.FAX_SOURCE FSRC
                  INNER JOIN
                      GLOBAL_BU_MAPPING GBM
                    ON GBM.BU_ID = FSRC.BUID
                ON UPPER (FSRC.FAX_NUMBER) = UPPER (FS.DESTINATION)
    WHERE      FSRC.IS_DELETED = 'N'
              AND GBM.BU_ID IS NOT NULL
              AND UPPER (FS.FAX_STATUS) =:B1;
    --OLD without indexes
    PLAN_TABLE_OUTPUT
    Plan hash value: 3076973749
    | Id  | Operation          | Name                  | Rows  | Bytes | Cost (%CPU)| Time    |
    |  0 | SELECT STATEMENT    |                        |  141K|    85M| 45130  (1)| 00:09:02 |
    |*  1 |  HASH JOIN          |                        |  141K|    85M| 45130  (1)| 00:09:02 |
    |  2 |  NESTED LOOPS      |                        |  611 | 18330 |    22  (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL| FAX_SOURCE            |  2290 | 59540 |    22  (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN | GLOBAL_BU_MAPPING_BUID |    1 |    4 |    0  (0)| 00:00:01 |
    |*  5 |  TABLE ACCESS FULL | FAX_STAGE              | 23245 |    13M| 45106  (1)| 00:09:02 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
      1 - access(UPPER("FSRC"."FAX_NUMBER")=UPPER("FS"."DESTINATION"))
      3 - filter("FSRC"."IS_DELETED"='N')
      4 - access("GBM"."BU_ID"="FSRC"."BUID")
          filter("GBM"."BU_ID" IS NOT NULL)
      5 - filter(UPPER("FS"."FAX_STATUS")=SYS_OP_C2C(:B1))
    21 rows selected.
    --NEW with indexes.
    PLAN_TABLE_OUTPUT
    Plan hash value: 665032407
    | Id  | Operation                        | Name                    | Rows  | Bytes | Cost (%CPU)| Time    |
    |  0 | SELECT STATEMENT                |                          |  5995 |  3986K|  3117  (1)| 00:00:38 |
    |*  1 |  HASH JOIN                      |                          |  5995 |  3986K|  3117  (1)| 00:00:38 |
    |  2 |  NESTED LOOPS                  |                          |  611 | 47658 |    20  (5)| 00:00:01 |
    |*  3 |    VIEW                          | index$_join$_002        |  2290 |  165K|    20  (5)| 00:00:01 |
    |*  4 |    HASH JOIN                    |                          |      |      |            |      |
    |*  5 |      HASH JOIN                  |                          |      |      |            |      |
    PLAN_TABLE_OUTPUT
    |  6 |      BITMAP CONVERSION TO ROWIDS|                          |  2290 |  165K|    1  (0)| 00:00:01 |
    |*  7 |        BITMAP INDEX SINGLE VALUE | IDX_IS_DELETED_RAM      |      |      |            |      |
    |  8 |      INDEX FAST FULL SCAN      | IDX_BUID_RAM            |  2290 |  165K|    8  (0)| 00:00:01 |
    |  9 |      INDEX FAST FULL SCAN        | IDX_FAX_NUMBER_RAM      |  2290 |  165K|    14  (0)| 00:00:01 |
    |* 10 |    INDEX RANGE SCAN              | GLOBAL_BU_MAPPING_BUID  |    1 |    4 |    0  (0)| 00:00:01 |
    |  11 |  TABLE ACCESS BY INDEX ROWID    | FAX_STAGE                | 23245 |    13M|  3096  (1)| 00:00:38 |
    |* 12 |    INDEX RANGE SCAN              | IDX_UPPER_FAX_STATUS_RAM |  9298 |      |  2434  (1)| 00:00:30 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
      1 - access(UPPER("DESTINATION")="FSRC"."SYS_NC00035$")
      3 - filter("FSRC"."IS_DELETED"='N')
      4 - access(ROWID=ROWID)
      5 - access(ROWID=ROWID)
      7 - access("FSRC"."IS_DELETED"='N')
      10 - access("GBM"."BU_ID"="FSRC"."BUID")
          filter("GBM"."BU_ID" IS NOT NULL)
      12 - access(UPPER("FAX_STATUS")=SYS_OP_C2C(:B1))
    31 rows selected
    Please confirm on the DBA comment.Is this bitmap index locks rows in my case.
    Thanks.>

  • Retry recovery action is taking long time to complete

    Hi,
    I am in the process of testing error handling for my BPEL process.
    As part of it, I have given the default recover action in the fault policy of the process as retry with a retry count of 3 times with retry interval as 2.
    To test this, i have changed the target end point uri of the target service to some invalid url and ran the process.
    First I was not able to find the BPEL process instance at all in the console.
    Later I was able to find the instance after half an hour. When I saw the instance, if retry had happened or not.
    I found that the retry happened for 3 times, but it took 30 mins for the first retry to complete and start the second retry.
    Can anyone please let me know why the retry is taking long time although the retry interval I gave is only 2 seconds.
    THanks in advance!!!!

    Hi,
    Please find below the fault policy file:
    <?xml version="1.0" encoding="UTF-8"?>
    <faultPolicy version="2.0.1" id="TestFaultPolicy" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.oracle.com/bpel/faultpolicy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <Conditions>
         <faultName>
         <condition>
         <action ref="aia-ora-retry"/>
         </condition>
         </faultName>
         </Conditions>
         <Actions>
              <Action id="aia-ora-retry">
                   <retry>
                        <retryCount>3</retryCount>
                        <retryInterval>2</retryInterval>
                        <exponentialBackoff/>
                        <retryFailureAction ref="aia-ora-java"/>
                        <retrySuccessAction ref="aia-ora-java"/>
                   </retry>
              </Action>
              <!-- This is an action will cause a replay scope fault-->
              <Action id="ora-replay-scope">
                   <replayScope/>
              </Action>
              <!-- This is an action will bubble up the fault-->
              <Action id="ora-rethrow-fault">
                   <rethrowFault/>
              </Action>
              <!-- This is an action will mark the work item to be "pending recovery from console"-->
              <Action id="ora-human-intervention">
                   <humanIntervention/>
              </Action>
              <!-- This action will cause the instance to terminate-->
              <Action id="ora-terminate">
                   <abort/>
              </Action>
              <Action id="aia-ora-java">
              <javaAction className="oracle.apps.aia.core.eh.BPELJavaAction" defaultAction="ora-rethrow-fault">
              <returnValue value="REPLAY" ref="ora-terminate"/>
              <returnValue value="RETRHOW" ref="ora-rethrow-fault"/>
              <returnValue value="ABORT" ref="ora-terminate"/>
              <returnValue value="RETRY" ref="aia-ora-retry"/>
              <returnValue value="MANUAL" ref="ora-human-intervention"/>
              </javaAction>
    </Action>     
         </Actions>
    </faultPolicy>

Maybe you are looking for

  • Macbook Pro Super Drive Loud Whirring Sound during Burn and Verify

    Hi there! I am using Toast 7 and when I burn DVD's I have noticed that the Super Drive gets a very loud whirring sound that seems to get louder and softer during the first 2 minutes of burning and then during the first 2 minutes of verifying; then it

  • Changed sort now it wont open

    I changed my sort by and now Aperture will not open. Just spinning icon and "Opening Aperture Library"

  • Error Windows 7-64 and Bluetooth with my Q10

    Hello First, sorry for my poor english Second : When I try to connect my new BB Q10 with my Dell XPS on Windows 7-64b, I have an error in installation with the pilote "Bluetooth Enumerator". I cant found the drivers... Can you help me ? Thanks a lot

  • RFC Sender error could not create function template for...

    Hi, I am trying to send an async RFC to XI. Since I use IN BACKGROUND TASK and COMMIT WORK I got following error in the SM58 of the back end system Server repository could not create function template for 'XYZ' In the XI, I see nothing (no message, n

  • Photoshop Features to appear on Linux?  Please?

    Hey, Im a relative newcomer to the world of photoshop.  As a student, I like to flick between various options and alternatives.  One of the things I have found is the number of posts concerning the market potential for photoshop within a  Linux userb