Doubt on IN clause

Hi,
Does having same values in the IN clause of an SQL decrease the performance?
Eg:
Select * from table where col1 in(1,1,1,1,2,2,2,3,3,3)
will the above query be ineffecient than the below one.
Select * from table where col1 in(1,2,3)
Thanks,
Mathew

BluShadow wrote:
There's probably a very very very slight degredation of performance internally caused by it being a set of data, but you're hardly likely to notice it.Give Oracle parser some credit B-). It will eliminte duplicate literals from IN list:
SQL> explain plan for
  2  select ename from emp where empno in (7839,7698,7934,7902)
  3  /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 2355049923
| Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |        |     4 |    40 |     2   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR             |        |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| EMP    |     4 |    40 |     2   (0)| 00:00:01 |
|*  3 |    INDEX UNIQUE SCAN         | PK_EMP |     4 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
   3 - access("EMPNO"=7698 OR "EMPNO"=7839 OR "EMPNO"=7902 OR "EMPNO"=7934)
15 rows selected.
SQL> explain plan for
  2  select ename from emp where empno in (7839,7698,7934,7902,7839,7698,7934,7902)
  3  /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 2355049923
| Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |        |     4 |    40 |     2   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR             |        |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| EMP    |     4 |    40 |     2   (0)| 00:00:01 |
|*  3 |    INDEX UNIQUE SCAN         | PK_EMP |     4 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
   3 - access("EMPNO"=7698 OR "EMPNO"=7839 OR "EMPNO"=7902 OR "EMPNO"=7934)
15 rows selected.
SQL> It is even smarter than that. It will precalculate literal expressions:
SQL> explain plan for
  2  select ename from emp where empno in (7838+1,7700-2,7934,7902,7839,7698,7934,7902)
  3  /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 2355049923
| Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |        |     4 |    40 |     2   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR             |        |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| EMP    |     4 |    40 |     2   (0)| 00:00:01 |
|*  3 |    INDEX UNIQUE SCAN         | PK_EMP |     4 |       |     1   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
   3 - access("EMPNO"=7698 OR "EMPNO"=7839 OR "EMPNO"=7902 OR "EMPNO"=7934)
15 rows selected.
SQL> Now if IN list has variables, you are right, there will be slight degradation. And to answer OP's question:
the distinct above would return say 50K recorsd.degaradation does not depend on number of rows. Oracle will sort IN list and eliminate duplicates (that is the part which produces degardation) once before fetching starts.
SY.

Similar Messages

  • Doubt on SAMPLE clause in SELECT statment

    Hi all,
    I am having table with rows of 41. I issued a statement like this
    select * from TABLE_NAME SAMPLE(10);
    and it selected 3 rows (it is varying) . Everytime, i issued this statement, it is
    fetching different number of rows.
    Can anybody please explain what is the basis for it and what is the best
    option to select rows randomly.
    Thanks in advance,
    Pal

    Thanks for your reply.
    Everytime, the selected rows are different sometimes only one record, sometimes
    three, sometimes 7 recoreds, and sometimes 4 records like that.
    So i didnot understand what is going on inside of this query.
    Thanks,
    Pal

  • Doubt with WHERE clause on OCIStmtPrepare statement

    I'm trying to run something like:
    select offc_ipbase
    from nexqoffice, connection_type
    where offc_type = coty_type and offc_lastsincro > to_date('2006/11/3:00:00:00', '>yyyy/mm/dd:hh24:mi:ss')
    order by offc_id
    where 'to_date...' is a variable. How Can I do this. I've been testing several (wrong) ways but all of them sends me an error. The code of my last test is:
    string sSQL = "select offc_ipbase from nexqoffice, connection_type where offc_type = >coty_type and offc_lastsincro >:dSQLDate order by offc_id";
    //Prepare statement
    checkerr(p_err,     OCIStmtPrepare(sqlStatement,p_err,(unsigned char *)
    const_cast<const char *>(sSQL.c_str()),
    strlen(sSQL.c_str()),OCI_NTV_SYNTAX,OCI_DEFAULT));
    //Define Output Variables
    OCIDefine * defnp = (OCIDefine *) 0;
    short name_length=15;
    char name[15];
    checkerr(p_err,     OCIDefineByPos(sqlStatement, &defnp, p_err, 1, (dvoid *) name,
    name_length+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0,
    OCI_DEFAULT));
    // dSQLDate
    char dSQLDate[80]; //to_date('2006/11/3:00:00:00', 'yyyy/mm/dd:hh24:mi:ss')
    OCIBind *p_dSQLDate = NULL; // client and server Ips
    checkerr(p_err,OCIBindByPos(sqlStatement, &p_dSQLDate , p_err, 1, dSQLDate, 80,
    SQLT_CHR, 0, 0, 0, 0, 0, OCI_DEFAULT));
    Then I make the execute statement. I guess the problem is in the dSQLDate variable, but I do not know which is it.
    The error that OCI returns me is:ORA-01858: a non-numeric character was found where a numeric was expected.
    Thank you very much.

    The statement needs to be:
    select offc_ipbase from nexqoffice, connection_type
    where offc_type = >coty_type
    and offc_lastsincro >to_date(:p1, 'yyyy/mm/dd:hh24:mi:ss')
    order by offc_id
    And then you bind only the actual value (without the to_date function itself):
    snprintf(dSQLDate, sizeof(dSQLDate), "2006/11/3:00:00:00");
    OCIBindByPos(sqlStatement, &p_dSQLDate , p_err, 1, dSQLDate, sizeof(dSQLDate), SQLT_CHR, 0, 0, 0, 0, 0, OCI_DEFAULT))

  • Regarding select statement

    Hi Expert,
    Is this select statement is ok ?
    actually i have doubt in where clause when it mix both AND and OR without braces
    SELECT SINGLE * FROM vbfa WHERE
                 vbeln = s_bkpf-awkey AND
                   vbtyp_v = 'C'   OR
                   vbtyp_v = 'E'   OR
                   vbtyp_v = 'M'  OR
                   vbtyp_v = 'J'   OR
                   vbtyp_v = 'R' .
    thanks and regards
    abaper.

    SELECT SINGLE * FROM vbfa WHERE
    vbeln = s_bkpf-awkey AND ( vbtyp_v = 'C' OR
    vbtyp_v = 'E' OR
    vbtyp_v = 'M' OR
    vbtyp_v = 'J' OR
    vbtyp_v = 'R' ).
    OR YOU CAN USE
    SELECT SINGLE * FROM vbfa WHERE
    vbeln = s_bkpf-awkey AND
    vbtyp_v IN ('C', 'E', 'M', 'J', 'R') .
    CHECK THE SPACE NO SPACE BETWEEN  ('C' AFTER , ONE SPACE AND NO SPACE BETWEEN 'R'). GIVE THE SPACE CORRECTLY ...
    REGARDS
    SHIBA DUTTA

  • Cumulative Totals...

    I'm not quite the seasoned pro, but have been working with CF for about 5 years and usually can get it to do what I want.  I thought this would be relatively easy (and prob is to you) to add cumulative costs in the right column of a balance sheet type output, but it's kicked my butt long enough..lol
    Just need it to sum cumulative costs of the items selected, in the order sorted. I've tried varying ways to get this to add and display like I need, dbqueries, loop indexes, using recordcount/currentrow calculations, etc, etc...no joy
    Appreciate your time...really! 
    <form...select...etc>
    <cfquery name="getcosts" datasource="xxx">
    SELECT *
    FROM costs
    ORDER by '#form.sortby#'
    </cfquery>
    <cfoutput query="getcosts">
    *displays columns for #item_name#, #item_cost#, and cumulative cost* based on output sort order
    </cfquery>

    RLByrd78240 wrote:
    <cfquery name="getcosts" datasource="xxx">
    SELECT *
    FROM costs
    ORDER by '#form.sortby#'
    </cfquery>
    <cfoutput query="getcosts">
    *displays columns for #item_name#, #item_cost#, and cumulative cost* based on output sort order
    </cfquery>
    I have some doubts about the clause ORDER by '#form.sortby#'. Does it actually work? should it at least be ORDER by #form.sortby# (without the quotes)? Test by dumping getcosts.
    When grouping a set of records, you should use the order-by column of the query as the group attribute of the cfoutput tag. In other words, something like
    <cfoutput query="getcosts" group="#form.sortby#">
    To get cumulative costs, you could use a construction like
    <cfset cumulative = 0>
    <cfoutput>
    blah blah blah
    <cfset cumulative = cumulative + item_cost>
    </cfoutput>  

  • Doubt regarding multiple criteria in order by clause

    Hi, I don't understand the effect of multiple elements inside the order by clause. I have the following example table:
    factor_x | factor_y | price
    =====================
    1 | 5 | 1000
    2 | 4 | 6970
    3 | 3 | 3688
    4 | 2 | 9087
    5 | 1 | 10000
    =====================
    So I tried: select price from pricetable order by factor_x; results as follows:
    1000
    6970
    3688
    9087
    10000
    Then: select price from pricetable order by factor_y; results as follows:
    10000
    9087
    3688
    6970
    1000
    Then: select price from pricetable order by factor_x, factor_y; results as follows:
    1000
    6970
    3688
    9087
    10000
    which is same as using order by factor_x. Can anyone tells me what is the effect of adding a 2nd, 3rd..... criterion in the order by clause? Because in this example I cannot see the difference. Many thanks.

    Hi,
    I did a little change in your data. Hope it will help you to understand.
    SQL> WITH T AS (SELECT 1 X , 1 Y , 1000 PRICE FROM DUAL UNION A
      2  SELECT 2 , 4 , 6970 FROM DUAL UNION ALL
      3  SELECT 4 , 3 , 3688 FROM DUAL UNION ALL
      4  SELECT 4 , 2 , 9087 FROM DUAL UNION ALL
      5  SELECT 4 , 5 , 10000 FROM DUAL)
      6  SELECT PRICE,X,Y FROM T ORDER BY X;
         PRICE          X          Y
          1000          1          1
          6970          2          4
          9087          4          2
         10000          4          5
          3688          4          3
    SQL> WITH T AS (SELECT 1 X , 1 Y , 1000 PRICE FROM DUAL UNION A
      2  SELECT 2 , 4 , 6970 FROM DUAL UNION ALL
      3  SELECT 4 , 3 , 3688 FROM DUAL UNION ALL
      4  SELECT 4 , 2 , 9087 FROM DUAL UNION ALL
      5  SELECT 4 , 5 , 10000 FROM DUAL)
      6  SELECT PRICE,X,Y FROM T ORDER BY X,Y;
         PRICE          X          Y
          1000          1          1
          6970          2          4
    9087 4 2
    3688 4 3
    10000 4 5
    SQL>Regards
    Avinash

  • Group By -- Having Clause related doubt.

    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ...
    SO how does Having works before grouping the Results..??

    Hi,
    Aijaz Mallick wrote:
    Hello,
    Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?What happens when you try it?
    If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ... Right; the HAVING clause is like another WHERE clause.
    The WHERE clause is applied before the GROUP BY is done, and the aggregate functions are computed.
    The HAVING clause is applied after the GROUP BY is done, and the aggregate functions are computed, so you can use aggregate functions in the HAVING clause.
    SO how does Having works before grouping the Results..??The order in which clauses appear in your code isn't necessarily the order in which they are performed. For example,
    SELECT    job
    ,         COUNT (*)  AS cnt
    FROM      scott.emp
    GROUP BY  job;Does it confuse you that this query can reference COUNT (*) in the SLECT clause, which is before the GROUP BY clause?
    The SELECT clause which always comes before the GROUP BY clause in code. That does not mean that the SELECT clause is completed before the GROUP BY clause is begun.
    If the documentation says that clauses must be in a certain order, then use that order, even if your current version of Oracle allows them to be in a different order. There's no guarantee that the next version of Oracle will allow something that was always said to be wrong.

  • Doubt in order by clause

    Hi,
    I have the below query
    select distinct first_value(column_name) over (partition by table_name order by decode(column_name,'REP','1',
    'END','2','3')),table_name from all_tab_columns where owner='ORCL'
    can someone plz tell me how the order by will function here or how the result will be ordered.
    Thanks,
    Mat

    Its better you post your original query with the actual and expected output..
    The syntex
    decode(column_name,REPORTING_DATE ,'1',END_DATE,'2','3'...
    is not correct for all_tab_cols as teh column names are not enclosed with single quotes.
    Regards
    Arun

  • Largest and 2nd largest number query group by clause doubt

    Hi, I have the following data in the database
    deal id reporting date
    12 6/1/2012
    12 4/1/2012
    12 2/1/2012
    13 3/1/2012
    13 2/1/2012
    13 1/1/2012
    I want for each deal id , the highest reporitng date and the 2nd highest reporting date...
    i.e output
    deal id date1 date2
    12 6/1/2012 4/1/2012
    13 3/1/2012 2/1/2012
    I wrote the following query
    select dealID,reportingDate from XYZ ,(select deal id , max(reportingDate)as d1 from XYZ) B
    where
    dealId=b.dealID
    and reportingDate!=b.d1
    order by reportingDate desc
    the problem is it gets all reporting date but the highest one for each deal ID. I do not want all the dates to come. just the highest and second highest
    plz help
    Edited by: user7963410 on Sep 14, 2012 10:01 PM

    Venkadesh wrote:
    this ?This is one overcomplicated piece of code. And it is incorrect. First of all '6/1/2012' is a string, not a date, so ordering by it will produce incorrect results. For example (I assume '6/1/2012' is Januray 6, 2012), '6/1/2012' > '1/5/2012':
    SQL> with t(id,reporting) as
      2  (
      3  select 12,'6/1/2012' from dual
      4  union all
      5  select 12,'4/1/2012' from dual
      6  union all
      7  select 12,'1/5/2012' from dual
      8  union all
      9  select 13,'3/1/2012' from dual
    10  union all
    11  select 13,'2/1/2012' from dual
    12  union all
    13  select 13,'1/1/2012' from dual
    14  )
    15  select id,regexp_substr(reporting,'\d+.\d+.\d+') date1,
    16  regexp_substr(reporting,'\d+.\d+.\d+',1,2) date2
    17  from (select id,listagg(reporting,' ') within group(order by reporting desc)
    18   reporting from (select id,reporting
    19   from (select id,reporting,row_number() over(partition by id order by reporting desc) rn
    20  from t)
    21  where rn<=2)
    22  group by id)
    23  /
            ID DATE1           DATE2
            12 6/1/2012        4/1/2012
            13 3/1/2012        2/1/2012
    SQL> And code doesn't take into account id,reporting might have duplicates:
    SQL> with t(id,reporting) as
      2  (
      3  select 12,'6/1/2012' from dual
      4  union all
      5  select 12,'6/1/2012' from dual
      6  union all
      7  select 12,'4/1/2012' from dual
      8  union all
      9  select 12,'2/1/2012' from dual
    10  union all
    11  select 13,'3/1/2012' from dual
    12  union all
    13  select 13,'2/1/2012' from dual
    14  union all
    15  select 13,'1/1/2012' from dual
    16  )
    17  select id,regexp_substr(reporting,'\d+.\d+.\d+') date1,
    18  regexp_substr(reporting,'\d+.\d+.\d+',1,2) date2
    19  from (select id,listagg(reporting,' ') within group(order by reporting desc)
    20   reporting from (select id,reporting
    21   from (select id,reporting,row_number() over(partition by id order by reporting desc) rn
    22  from t)
    23  where rn<=2)
    24  group by id)
    25  /
            ID DATE1           DATE2
            12 6/1/2012        6/1/2012
            13 3/1/2012        2/1/2012
    SQL> Anyway, all we need is row_number and max:
    select  id,
            reporting date1,
            prev_reporting date2
      from  (
             select  id,
                     reporting,
                     row_number() over(partition by id order by reporting desc) rn,
                     max(reporting) over(partition by id order by reporting range between unbounded preceding and 1/24/60/60 preceding) prev_reporting
               from  t
      where rn = 1
    /For example:
    with t(id,reporting) as
    select 12,to_date('6/1/2012','dd/mm/yyyy') from dual
    union all
    select 12,to_date('6/1/2012','dd/mm/yyyy') from dual
    union all
    select 12,to_date('4/1/2012','dd/mm/yyyy') from dual
    union all
    select 12,to_date('2/1/2012','dd/mm/yyyy') from dual
    union all
    select 13,to_date('3/1/2012','dd/mm/yyyy') from dual
    union all
    select 13,to_date('2/1/2012','dd/mm/yyyy') from dual
    union all
    select 13,to_date('1/1/2012','dd/mm/yyyy') from dual
    select  id,
            reporting date1,
            prev_reporting date2
      from  (
             select  id,
                     reporting,
                     row_number() over(partition by id order by reporting desc) rn,
                     max(reporting) over(partition by id order by reporting range between unbounded preceding and 1/24/60/60 preceding) prev_reporting
               from  t
      where rn = 1
            ID DATE1           DATE2
            12 06-JAN-12       04-JAN-12
            13 03-JAN-12       02-JAN-12
    SQL> But I prefer:
    select  id,
            reporting date1,
            Nth_highest_reporting date2
      from  (
             select  id,
                     reporting,
                     row_number() over(partition by id order by reporting desc) rn,
                     lead(reporting,:n - 1) over(partition by id order by reporting desc) Nth_highest_reporting
               from  (
                      select  distinct *
                        from  t
      where rn = 1
    /Where :n is Nth highest. For example:
    SQL> variable n number
    SQL> exec :n := 2;
    PL/SQL procedure successfully completed.
    SQL> with t(id,reporting) as
      2  (
      3  select 12,to_date('6/1/2012','dd/mm/yyyy') from dual
      4  union all
      5  select 12,to_date('6/1/2012','dd/mm/yyyy') from dual
      6  union all
      7  select 12,to_date('4/1/2012','dd/mm/yyyy') from dual
      8  union all
      9  select 12,to_date('2/1/2012','dd/mm/yyyy') from dual
    10  union all
    11  select 12,to_date('1/1/2012','dd/mm/yyyy') from dual
    12  union all
    13  select 13,to_date('3/1/2012','dd/mm/yyyy') from dual
    14  union all
    15  select 13,to_date('2/1/2012','dd/mm/yyyy') from dual
    16  union all
    17  select 13,to_date('1/1/2012','dd/mm/yyyy') from dual
    18  )
    19  select  id,
    20          reporting date1,
    21          Nth_highest_reporting date2
    22    from  (
    23           select  id,
    24                   reporting,
    25                   row_number() over(partition by id order by reporting desc) rn,
    26                   lead(reporting,:n - 1) over(partition by id order by reporting desc) Nth_highest_reporting
    27             from  (
    28                    select  distinct *
    29                      from  t
    30                   )
    31          )
    32    where rn = 1
    33  /
            ID DATE1           DATE2
            12 06-JAN-12       04-JAN-12
            13 03-JAN-12       02-JAN-12
    SQL> exec :n := 3;
    PL/SQL procedure successfully completed.
    SQL> /
            ID DATE1           DATE2
            12 06-JAN-12       02-JAN-12
            13 03-JAN-12       01-JAN-12
    SQL> exec :n := 4;
    PL/SQL procedure successfully completed.
    SQL> /
            ID DATE1           DATE2
            12 06-JAN-12       01-JAN-12
            13 03-JAN-12
    SQL> SY.

  • Doubt in Group by

    I have doubt in group by clause.
    System_log table contains
    server_id,
    system_cpu,
    user_cpu,
    time_log
    as fields
    I want to display distinct servers order by (system+user)
    SELECT server_id
    FROM system_log
    WHERE time_log IN (SELECT MAX(time_log)
    FROM system_log
    GROUP BY server_id)
    ORDER BY (system+ user) ASC
    In this query, i'm not getting distinct server_id.
    Can anyone correct me this query?

    Try
    SELECT sl.server_id
      FROM system_log sl
    WHERE time_log =
           (SELECT MAX(time_log) FROM system_log sl2 WHERE sl.server_id = sl2.server_id GROUP BY server_id)or
    SELECT sl2.server_id
      FROM (SELECT sl.*
                  ,ROW_NUMBER() over(PARTITION BY sl.server_id ORDER BY sl.time_log DESC) RN
              FROM system_log sl) sl2
    WHERE sl2.rn = 1Regards...

  • Doubt in report of FI

    Hi every one i have a small doubt in FI report that is i have to give the following output as per the user requirement i had added all the everything in this program i had given u the entire code the only problem is if make comment for the code of city and postal code the remaining everything is working properly and if i remove comment at CITY and POSTAL CODE there is some error can u find out that and help me please
    * Ist-Einzelpostenanzeige EC-PCA                                      *
    * - direkte Aufruf                                                    *
    * - Report Writer                                                     *
    * - Recherche                                                         *
    * 45b MIC: default values for poper and ryear depfr. fiscyear variant *
    * 46a MIC Warning if too few selection parameters                     *
    * 46a MIC: use up to 'whr_size' single values in select statement     *
    * 46a MIC: move'Initialization of Rep-Rep-Interface' to Initialization*
    * 46a MIC: check only new auth-object                                 *
    * 46c MIC: add RMVCT and get more fields from RRI                     *
    REPORT z_rcopca02_1 NO STANDARD PAGE HEADING MESSAGE-ID km
                    LINE-COUNT (2) LINE-SIZE 81.
    * Typen ***************************************************************
    *type-pools: kkblo.
    TYPE-POOLS: slis, ecarc.
    * DDIC-Tabellen *******************************************************
    TABLES: glpca,                         "Einzelposten / Ist
            glu1,                          "Übergabestruktur FI-SL-Anzeige
            t000,
            tka01,
            sscrfields,
            lfa1,
            kna1,
            bseg,
            with_item.
    * Variablen und int. Tabellen *****************************************
    DATA: afield        TYPE slis_fieldcat_alv,
          sp_group      TYPE slis_sp_group_alv,
          t_listheader  TYPE slis_t_listheader WITH HEADER LINE,
          t_layout      TYPE slis_layout_alv,
          t_fieldcat    TYPE slis_t_fieldcat_alv,
          t_spec_groups TYPE slis_t_sp_group_alv,
          event         TYPE slis_alv_event,
          t_events      TYPE slis_t_event,
          g_variant     LIKE disvariant,
          gx_variant    LIKE disvariant,
          g_exit(1)     TYPE c,
          g_save(1)     TYPE c,
          g_repid       LIKE sy-repid,
          msgtyp        LIKE sy-msgty,
          lt_dynpread   LIKE dynpread OCCURS 1 WITH HEADER LINE,
          ls_rpcak      LIKE rpcak,              "note 0310592
          packsize      TYPE i VALUE 1000,
          text1(60)     TYPE c,
          text2(60)     TYPE c,
          oldkokrs      LIKE glpca-kokrs,
          oldracct      LIKE glpca-racct.
    DATA: whr_size    TYPE i VALUE 50,"Maximum of single values per  MIC 46a
                       "charact. in the where-clause of the select-statement
          lines         TYPE i, "number of lines of range table      MIC 46a
          cnt_rldnr     TYPE i, "Zähler Anzahl selektierter Ledger
          cnt_kokrs     TYPE i, "Zähler Anzahl selektierter KoReKreise
          cnt_poper     TYPE i, "Zähler Anzahl selektierter Perioden
          cnt_ryear     TYPE i, "Zähler Anzahl selektierter GeschJahre
          cnt_rvers     TYPE i, "Zähler Anzahl selektierter Versionen
          cnt_bukrs     TYPE i, "Zähler Anzahl selektierter BuKreise
          empge         LIKE dkobr-empge,
          ksl_curr      LIKE tka01-pcacur,
          hsl_curr      LIKE t001-waers,
          a_rec         LIKE rstirec.
    DATA: BEGIN OF dim_data.
            INCLUDE STRUCTURE rgcdi.       "data for dimensions
    DATA: END OF dim_data.
    DATA: BEGIN OF tab_fields OCCURS 80,
            name LIKE dntab-fieldname,     "fields in table i_glpca
          END OF tab_fields.
    DATA: BEGIN OF i_glpca OCCURS 0.
            INCLUDE STRUCTURE rpca2.
    DATA:   racct_ktext LIKE rpcak-ktext,
            psppp LIKE prps-posid,
            name1 LIKE lfa1-name1,
            adrnr like lfa1-adrnr,
            stras like lfa1-stras,
            c_name1 like kna1-name1,
            v_rate like with_item-qsatz,
            qsshb like bseg-qsshb,
            qbshb like bseg-qbshb,
          END OF i_glpca.
    DATA: rw_subrc   LIKE sy-subrc,      "Flag: Report-Writer-Schnittstelle
          re_subrc   LIKE sy-subrc,        "Flag: Recherche-Schnittstelle
          subrc      LIKE sy-subrc.
    DATA: set_id    LIKE sethier-setid,    "Set-ID        "RDI_SETS_4.0
          set_class LIKE sethier-setclass, "Setklasse     "RDI_SETS_4.0
          set_sname LIKE sethier-shortname."Setname (24)  "RDI_SETS_4.0
    DATA: authorised(1),
          s_message(1),
          auth_dbcount LIKE sy-tabix,
    *     Hex-Konstanten für Minimum/Maximum-Werte
          BEGIN OF hex00,
            x1(12) TYPE c,
            x2(12) TYPE c,
          END OF hex00,
          BEGIN OF hexff,
            x1(12) TYPE c,
            x2(12) TYPE c,
          END OF hexff.
    RANGES rclnt FOR glpca-rclnt.
    FIELD-SYMBOLS: <glpca> LIKE LINE OF i_glpca,
                   <glpca_arc> TYPE ecarc_glpca_curr.
    * Selektionsoptionen *************************************************
    SELECT-OPTIONS:
      rldnr    FOR glpca-rldnr   DEFAULT '8A' NO-DISPLAY,
      rassc    FOR glpca-rassc                NO-DISPLAY,
    * rrcty    for glpca-rrcty   default 0,
      rrcty    FOR glpca-rrcty,
      rvers    FOR glpca-rvers   DEFAULT '000',
      kokrs    FOR glpca-kokrs   MEMORY ID cac,
      bukrs    FOR glpca-rbukrs  MEMORY ID buk,
    * poper    for glpca-poper   default sy-datlo+4(2),
    * ryear    for glpca-ryear   default sy-datlo,
      poper    FOR glpca-poper,
      ryear    FOR glpca-ryear,
      prctr    FOR glpca-rprctr  MATCHCODE OBJECT prct,
      pprctr   FOR glpca-sprctr  MATCHCODE OBJECT prct,
    * RACCT    FOR GLPCA-RACCT   MATCHCODE OBJECT KART,      "RD_P30K128304
      racct    FOR glpca-racct,            "RD_P30K128304
      drcrk    FOR glpca-drcrk,
      activ    FOR glpca-activ,
      rhoart   FOR glpca-rhoart,
      rfarea   FOR glpca-rfarea,
      stagr    FOR glpca-stagr,
      rtcur    FOR glpca-rtcur,
      runit    FOR glpca-runit,
      versa    FOR glpca-versa  NO-DISPLAY,
      eprctr   FOR glpca-eprctr NO-DISPLAY,
      afabe    FOR glpca-afabe  NO-DISPLAY,
      rmvct    FOR glpca-rmvct  NO-DISPLAY,
      hrkft    FOR glpca-hrkft  NO-DISPLAY,  "note 550972
      sbukrs   FOR glpca-sbukrs NO-DISPLAY,  "note 550972
      shoart   FOR glpca-shoart NO-DISPLAY,  "note 550972
      sfarea   FOR glpca-sfarea NO-DISPLAY,  "note 550972
      docct    FOR glpca-docct,
      docnr    FOR glpca-docnr,
      refdocct FOR glpca-refdocct,
      refdocnr FOR glpca-refdocnr,
      werks    FOR glpca-werks,
      repmatnr FOR glpca-rep_matnr MATCHCODE OBJECT pca_shlp_rep_matnr,
      rscope   FOR glpca-rscope.
    PARAMETERS: no_rrint NO-DISPLAY DEFAULT ' '." skip       "MICP40K066037
    " report-report-interface
    * display variant                                       ">>MICP40K039857
    SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-e01.
    PARAMETERS: p_vari LIKE disvariant-variant.
    SELECTION-SCREEN COMMENT 47(40) varname FOR FIELD p_vari.
    SELECTION-SCREEN END OF BLOCK 0.
    PARAMETERS log_grp(4) TYPE c NO-DISPLAY DEFAULT 'zKE5Z'.
    "<<MICP40K039857
    RANGES: v_racct  FOR glpca-racct,
            v_prctr  FOR glpca-rprctr,
            v_pprctr FOR glpca-sprctr.
    * Tabelle mit Werten aus den Berichts-Set vom Report-Writer           *
    DATA  BEGIN OF val_tab OCCURS 50.
            INCLUDE STRUCTURE rgciv.
    DATA  END OF val_tab.
    ***************************************************        MICP30K166368
    * feldkatalog und interface für bb-schnittstelle rw        MICP30K166368
    ***************************************************        MICP30K166368
    "MICP30K166368
    DATA  BEGIN OF bbs_fieldtab OCCURS 20. "MICP30K166368
            INCLUDE STRUCTURE rstifields.  "MICP30K166368
    DATA  END OF bbs_fieldtab.             "MICP30K166368
    * archiv
    TYPE-POOLS: rsds.
    TYPES:      BEGIN OF ty_archive_objects,
                   object       LIKE arch_obj-object,
                END   OF ty_archive_objects,
                ty_t_archive_objects TYPE ty_archive_objects OCCURS 2.
    CONSTANTS:  lc_set          TYPE  c           VALUE 'X',
                lc_report       TYPE  progname    VALUE 'ZKE5Z',
                lc_reporttype   TYPE  reporttype  VALUE 'TR'.
    TABLES:     admi_files.
    SELECT-OPTIONS lr_files FOR admi_files-archiv_key NO-DISPLAY.
    PARAMETER:  read_db       TYPE c            DEFAULT 'X' NO-DISPLAY,
                read_ar       TYPE c                        NO-DISPLAY,
                arc_obj       LIKE arch_obj-object          NO-DISPLAY,
                read_as       TYPE c            DEFAULT 'X' NO-DISPLAY.
    DATA  :     lt_arch_obj     TYPE ty_t_archive_objects WITH HEADER LINE,
                ls_selections   TYPE rsds_frange,
                lt_selections   TYPE rsds_frange_t,
                ls_selopt TYPE rsdsselopt,
                lt_glpca_archiv TYPE ecarc_t_glpca_curr.
    *********************************************************>>MICP40K039857
    * INITIALIZATION
    INITIALIZATION.
    * Diverse Initialisierungen
      PERFORM init_vars.
      g_repid = sy-repid.
    * Set default values for record type
      rrcty-sign = 'I'.
      rrcty-option = 'EQ'.
      rrcty-low    = '0'.
      APPEND rrcty.
      rrcty-low = '2'.
      APPEND rrcty.
    * Set default values for period and year (if kokrs or bukrs is known)
      GET PARAMETER ID 'BUK' FIELD bukrs-low.
      GET PARAMETER ID 'CAC' FIELD kokrs-low.
      IF     kokrs-low IS INITIAL       "get contr. area from company code
         AND NOT bukrs-low IS INITIAL.
        CALL FUNCTION 'KOKRS_GET_FROM_BUKRS'
          EXPORTING
            i_bukrs        = bukrs-low
          IMPORTING
            e_kokrs        = kokrs-low
          EXCEPTIONS
            no_kokrs_found = 1
            OTHERS         = 2.
        IF sy-subrc <> 0.
          CLEAR kokrs-low.
        ENDIF.
      ENDIF.
      IF NOT kokrs-low IS INITIAL.
        CALL FUNCTION 'K_KOKRS_READ'       "get fiscal year variant
             EXPORTING
                  kokrs           = kokrs-low
              IMPORTING
                  e_tka01         = tka01
            EXCEPTIONS
                  not_found       = 1
                  not_found_gjahr = 2
                  OTHERS          = 3.
        IF sy-subrc = 0.
          CALL FUNCTION 'G_PERIOD_GET'
            EXPORTING
              date                           = sy-datlo
              variant                        = tka01-lmona
            IMPORTING
              period                         = poper-low
              year                           = ryear-low
            EXCEPTIONS
              ledger_not_assigned_to_company = 1
              period_not_defined             = 2
              variant_not_defined            = 3
              OTHERS                         = 4.
          IF sy-subrc = 0.
            poper-sign = 'I'.
            poper-option = 'EQ'.
            APPEND poper.
            ryear-sign = 'I'.
            ryear-option = 'EQ'.
            APPEND ryear.
          ENDIF.
        ENDIF.
      ENDIF.
    * Settings for display variants
      g_save = 'A'.  "Schalter Varianten benutz./allg. speichern
      CLEAR g_variant.
      g_variant-report = g_repid.
      g_variant-log_group = log_grp.
      g_variant-username = sy-uname.
    * Get default variant
      gx_variant = g_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = g_save
        CHANGING
          cs_variant = gx_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        p_vari = gx_variant-variant.
      ENDIF.
    * Set variant
      IF p_vari IS INITIAL.
        p_vari = '1SAP'.
        MOVE p_vari TO gx_variant-variant.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            i_save     = g_save
          CHANGING
            cs_variant = gx_variant
          EXCEPTIONS
            not_found  = 1.
        IF sy-subrc NE 0.
          CLEAR p_vari.
          CLEAR gx_variant-variant.
        ENDIF.
      ENDIF.
      varname = gx_variant-text.
      "<<MICP40K039857
    * archiv
      CALL FUNCTION 'KARL_DATA_INPUT_INIT'
        EXPORTING
          i_report     = lc_report
          i_reporttype = lc_reporttype
        IMPORTING
          e_xusedb     = read_db
          e_xusear     = read_ar
          e_archobj    = arc_obj
          e_infosys    = read_as
        TABLES
          t_arch_sel   = lr_files.
      DATA: lt_excluding LIKE sy-ucomm OCCURS 0 WITH HEADER LINE.
      CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
        EXPORTING
          p_status  = 'SELSCREEN'
          p_program = 'RCOPCA02'
        TABLES
          p_exclude = lt_excluding.
    * Initialisieren der Bericht/Bericht-Schnittstellen                   *
      DATA: ld_no_rrint TYPE boole_d.      "note 490484 begin
      IMPORT rri = ld_no_rrint FROM MEMORY ID 'RCOPCA02_NO_RRI'.
      IF ld_no_rrint = 'X'.
        FREE MEMORY ID 'RCOPCA02_NO_RRI'.
      ELSE.                                "note 490484 end
        CALL FUNCTION 'G_REPORT_INTERFACE_INIT'   "Report-Writer?
            EXPORTING                      "MICP30K166368
                 table = 'GLPCT'           "MICP30K166368
             IMPORTING
                 subrc = rw_subrc          "MICP30K166368
            TABLES                         "MICP30K166368
                 it_fieldr = bbs_fieldtab. "MICP30K166368
        CALL FUNCTION 'RSTI_APPL_STACK_POP'"oder Recherche?
             IMPORTING
                  i_rec                      = a_rec
             EXCEPTIONS
                  appl_stack_not_initialized = 1.
        re_subrc = sy-subrc.
        IF re_subrc = 0.
    *    check Receiver is this report
          IF NOT ( ( a_rec-rtool = 'RT' AND a_rec-ronam = 'Z_RCOPCA02_1' )
                   OR ( a_rec-rtool = 'TR' AND a_rec-ronam = 'ZKE5Z' ) ) .
            re_subrc = 2.
          ENDIF.
        ENDIF.
      ENDIF.
    * AT SELCTION-SCREEN on value request**********************************
    *at selection-screen on value-request for racct-low.          "RD "4.6a
    *                                                             "RD "4.6a
    * call function 'K_RACCT_VALUE_REQUEST'                       "RD "4.6a
    *      importing                                              "RD "4.6a
    *           e_racct      = racct-low.                         "RD "4.6a
    *                                                             "RD "4.6a
    *                                                             "RD "4.6a
    *at selection-screen on value-request for racct-high.         "RD "4.6a
    *                                                             "RD "4.6a
    * call function 'K_RACCT_VALUE_REQUEST'                       "RD "4.6a
    *      importing                                              "RD "4.6a
    *           e_racct      = racct-high.                        "RD "4.6a
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.         "MICP40K039857
      PERFORM f4_for_variant.              "MICP40K039857
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR poper-low.         "RD "4.6a
    * begin of insertion note 522715
      CALL FUNCTION 'K_KOKRS_READ'
        EXPORTING
          kokrs           = kokrs-low
        EXCEPTIONS
          not_found       = 1
          not_found_gjahr = 2
          OTHERS          = 3.
      IF sy-subrc = 0.
    * end of insertion note 522715
        CALL FUNCTION 'ECPCA_RPMAX_VALUE_REQUEST'               "RD "4.6a
             EXPORTING                                          "RD "4.6a
                  i_kokrs     = kokrs-low                       "RD "4.6a
                  i_ryear     = ryear-low                       "RD "4.6a
             IMPORTING                                          "RD "4.6a
                  e_rpmax     = poper-low                       "RD "4.6a
    * begin of insertion note 522715
             EXCEPTIONS
                  table_empty = 1.
      ENDIF.
    * end of insertion note 522715
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR poper-high.        "RD "4.6a
    * begin of insertion note 522715
      CALL FUNCTION 'K_KOKRS_READ'
        EXPORTING
          kokrs           = kokrs-low
        EXCEPTIONS
          not_found       = 1
          not_found_gjahr = 2
          OTHERS          = 3.
      IF sy-subrc = 0.
    * end of insertion note 522715
        CALL FUNCTION 'ECPCA_RPMAX_VALUE_REQUEST'               "RD "4.6a
             EXPORTING                                          "RD "4.6a
                  i_kokrs     = kokrs-low                       "RD "4.6a
                  i_ryear     = ryear-low                       "RD "4.6a
             IMPORTING                                          "RD "4.6a
                  e_rpmax     = poper-high                      "RD "4.6a
    * begin of insertion note 522715
             EXCEPTIONS
                  table_empty = 1.
      ENDIF.
    * end of insertion note 522715
    * AT SELCTION-SCREEN ***************************************************
    AT SELECTION-SCREEN.
      PERFORM pai_of_selection_screen.
    * begin of insertion note 522715
      IF NOT kokrs-low IS INITIAL.
        CALL FUNCTION 'K_KOKRS_READ'
          EXPORTING
            kokrs           = kokrs-low
          EXCEPTIONS
            not_found       = 1
            not_found_gjahr = 2
            OTHERS          = 3.
        IF sy-subrc <> 0.
          MESSAGE e101(ki) WITH kokrs-low.
        ENDIF.
      ENDIF.
    * end of insertion note 522715
    * archiv
      IF sy-ucomm = 'FC01' OR sy-ucomm = 'UCDS'
        OR sy-ucomm = 'ONLI' AND read_ar = 'X'
        AND read_as IS INITIAL AND lr_files[] IS INITIAL.
        IF lt_arch_obj[] IS INITIAL.
          lt_arch_obj-object = 'PCA_OBJECT'. APPEND lt_arch_obj.
          lt_arch_obj-object = 'EC_PCA_ITM'. APPEND lt_arch_obj.
        ENDIF.
        CALL FUNCTION 'KARL_DATA_INPUT_SELECT'
          EXPORTING
            i_db_and_arc       = lc_set
            i_infosys_possible = lc_set
            i_object_fixed     = 'V'
            i_documentation    = 'KARL_DATA_INPUT_SEL_KE5YZ'
            i_report           = lc_report
            i_reporttype       = lc_reporttype
          TABLES
            t_objects          = lt_arch_obj
            t_arch_sel         = lr_files
          CHANGING
            c_xusedb           = read_db
            c_xusear           = read_ar
            c_archobj          = arc_obj
            c_infosys          = read_as.
      ENDIF.
    * START-OF-SELECTION **************************************************
    START-OF-SELECTION.
    *   Default-Werte löschen, falls Aufruf über Recherche
    *   oder Report-Writer erfolgt ist
      IF no_rrint IS INITIAL AND ld_no_rrint IS INITIAL.        "note 490484
        IF rw_subrc EQ 0 OR re_subrc EQ 0.
          REFRESH: rldnr, rrcty, rvers,  kokrs, bukrs, poper,  ryear,
                   racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
                   versa, afabe, eprctr,
                   v_racct, v_prctr, v_pprctr.
          CLEAR:   rldnr, rrcty, rvers,  kokrs, bukrs, poper,  ryear,
                   racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
                   versa, afabe, eprctr,
                   v_racct, v_prctr, v_pprctr.
          IF NOT read_as IS INITIAL.                           "note 625581
            CLEAR: lr_files, lr_files[].                       "note 625581
          ENDIF.                                               "note 625581
        ENDIF.
    * Parameter einlesen über Report-Writer-Schnittstelle                 *
        IF rw_subrc EQ 0.
          PERFORM rw_get_parameters.
    * oder Parameter einlesen über Recherche-Schnittstelle                *
        ELSEIF re_subrc EQ 0.
          PERFORM re_get_parameters.
        ENDIF.
      ENDIF.
      IF read_db = 'X'.                     " read from DB (archiv)
    * Bewegungsdaten einlesen und puffern...................................
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            text = 'Einzelposten selektieren'(p10).
    * Use dirty trick to mislead DB-optimizer
        CALL FUNCTION 'DB_DO_NOT_USE_CLIENT_INDEX'
          EXPORTING
            value    = sy-mandt
          TABLES
            mandttab = rclnt.
        SELECT (tab_fields) FROM glpca
           CLIENT SPECIFIED
           PACKAGE SIZE packsize
           APPENDING CORRESPONDING FIELDS OF TABLE i_glpca
           WHERE rldnr     IN rldnr
             AND rrcty     IN rrcty
             AND rvers     IN rvers
             AND kokrs     IN kokrs
             AND rbukrs    IN bukrs
             AND ryear     IN ryear
             AND rassc     IN rassc
             AND hrkft     IN hrkft   "note 550972
             AND sbukrs    IN sbukrs  "note 550972
             AND shoart    IN shoart  "note 550972
             AND sfarea    IN sfarea  "note 550972
             AND racct     IN racct
             AND rprctr    IN prctr
             AND sprctr    IN pprctr
             AND poper     IN poper
             AND drcrk     IN drcrk
             AND activ     IN activ
             AND rhoart    IN rhoart
             AND rfarea    IN rfarea
             AND versa     IN versa
             AND eprctr    IN eprctr
             AND afabe     IN afabe
             AND rmvct     IN rmvct
             AND docct     IN docct
             AND docnr     IN docnr
             AND stagr     IN stagr
             AND rtcur     IN rtcur
             AND runit     IN runit
             AND refdocct  IN refdocct
             AND refdocnr  IN refdocnr
             AND werks     IN werks
             AND rep_matnr IN repmatnr       "RDIP40K020663
             AND rscope    IN rscope         "RDIP40K020663
          AND rclnt     IN rclnt.       "dirty trick to mislead DB-optimizer
          IF sy-dbcnt > 1.
            text1 = sy-dbcnt.
            CONDENSE text1.
            CONCATENATE text1 text-m01 INTO text2 SEPARATED BY space.
            CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
              EXPORTING
                text = text2.          " ... Datensätze gelesen
          ENDIF.
        ENDSELECT.
    * Entfernt nicht zugehörige Einträge....................................
        LOOP AT i_glpca WHERE ( NOT rprctr IN v_prctr  )
                           or ( not SPRCTR in v_pprctr )
                           OR ( NOT racct  IN v_racct  ).
          DELETE i_glpca.
        ENDLOOP.
      ENDIF.
    *archiv
      IF read_ar = 'X' AND NOT
        ( read_as IS INITIAL AND lr_files[] IS INITIAL ).
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            text = 'Lesen im Archiv'(p12).
        DEFINE fill_lt_selections.
          if not &2[] is initial.
            clear ls_selections.
            move &1 to ls_selections-fieldname.
            loop at &2.
              clear ls_selopt.
              move-corresponding &2 to ls_selopt.
              append ls_selopt to ls_selections-selopt_t.
            endloop.
            append ls_selections to lt_selections.
          endif.
        END-OF-DEFINITION.
        fill_lt_selections 'RLDNR'  rldnr.
        fill_lt_selections 'RRCTY'  rrcty.
        fill_lt_selections 'RVERS'  rvers.
        fill_lt_selections 'KOKRS'  kokrs.
        fill_lt_selections 'RBUKRS' bukrs.
        fill_lt_selections 'POPER'  poper.
        fill_lt_selections 'RYEAR'  ryear.
        fill_lt_selections 'RPRCTR' prctr.
        fill_lt_selections 'SPRCTR' pprctr.
        fill_lt_selections 'RACCT'  racct.
        fill_lt_selections 'DRCRK'  drcrk.
        fill_lt_selections 'ACTIV'  activ.
        fill_lt_selections 'RHOART' rhoart.
        fill_lt_selections 'RFAREA' rfarea.    "note 401961
        fill_lt_selections 'STAGR'  stagr.
        fill_lt_selections 'RTCUR'  rtcur.
        fill_lt_selections 'RUNIT'  runit.
        fill_lt_selections 'VERSA'  versa.
        fill_lt_selections 'EPRCTR' eprctr.
        fill_lt_selections 'AFABE'  afabe.
        fill_lt_selections 'RMVCT'  rmvct.
        fill_lt_selections 'DOCCT'  docct.
        fill_lt_selections 'DOCNR'  docnr.
        fill_lt_selections 'REFDOCCT' refdocct.
        fill_lt_selections 'REFDOCNR' refdocnr.
        fill_lt_selections 'WERKS'  werks.
        fill_lt_selections 'REP_MATNR' repmatnr.
        fill_lt_selections 'RSCOPE' rscope.
        fill_lt_selections 'HRKFT'  hrkft.   "note 550972
        fill_lt_selections 'SBUKRS' sbukrs.  "note 550972
        fill_lt_selections 'SHOART' shoart.  "note 550972
        fill_lt_selections 'SFAREA' sfarea.  "note 550972
        CALL FUNCTION 'EC_PCA_SELECT_FROM_ARCHIVE'
          EXPORTING
            i_selections            = lt_selections[]
            i_files_sequential_read = lr_files[]
          IMPORTING
            e_glpca                 = lt_glpca_archiv[]
          EXCEPTIONS
            no_infostruc_found      = 1.
        IF sy-subrc = 1.
          MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CLEAR i_glpca.
        LOOP AT lt_glpca_archiv ASSIGNING <glpca_arc>
                        WHERE ( rprctr IN v_prctr  )
                          and ( sprctr IN v_pprctr )
                          AND ( racct  IN v_racct  ).
          MOVE-CORRESPONDING <glpca_arc> TO i_glpca.
          APPEND i_glpca.
        ENDLOOP.
    * delete duplicate records                                   note 639647
        IF NOT read_db IS INITIAL AND NOT lt_glpca_archiv[] IS INITIAL.
          SORT i_glpca.
          DELETE ADJACENT DUPLICATES FROM i_glpca.
        ENDIF.
      ENDIF.
      IF i_glpca[] IS INITIAL.         "Info,nichts gefunden
        MESSAGE s000.
        EXIT.
      ENDIF.
    * get texts for accounts ...............................................
      SORT i_glpca BY kokrs racct.
      LOOP AT i_glpca ASSIGNING <glpca>.
        IF <glpca>-kokrs <> oldkokrs OR <glpca>-racct <> oldracct. "AT NEW
          CLEAR ls_rpcak.
          oldkokrs = <glpca>-kokrs.
          oldracct = <glpca>-racct.
          CALL FUNCTION 'K_RACCT_SINGLE_CHECK'         "note 0310592
               EXPORTING
                    i_kokrs    = <glpca>-kokrs
                    i_racct    = <glpca>-racct
                    i_spras    = sy-langu
                    i_textflag = 'X'
               IMPORTING
                    e_rpcak    = ls_rpcak
               EXCEPTIONS
                    not_valid  = 1
                    OTHERS     = 2.
          IF sy-subrc NE 0.
            CLEAR ls_rpcak.
          ENDIF.
        ENDIF.                             "ENDAT
        <glpca>-racct_ktext = ls_rpcak-ktext.
    * Fetching vendor name from vendor number
    *break-point.
         SELECT SINGLE * FROM LFA1
             WHERE LIFNR = <glpca>-LIFNR AND
             SPRAS = SY-LANGU.
         IF SY-SUBRC eq 0.
            <glpca>-name1 = lfa1-name1.
            <glpca>-adrnr = lfa1-adrnr.
            <glpca>-stras = lfa1-stras.
         ENDIF.
    * Fetching customer name from customer number
         SELECT SINGLE * FROM kna1
             WHERE KUNNR = <glpca>-KUNNR.
         IF SY-SUBRC eq 0.
            <glpca>-c_name1 = kna1-name1.
         ENDIF.
         SELECT SINGLE * FROM bseg
                WHERE BUKRS EQ <glpca>-rbukrs AND
                      BELNR EQ <glpca>-refdocnr AND
                      GJAHR EQ <glpca>-ryear AND
                      KTOSL EQ 'WIT' AND
                      BUZEI EQ <glpca>-refdocln.
         IF SY-SUBRC eq 0.
           SELECT SINGLE * FROM WITH_ITEM
                  WHERE BUKRS EQ <glpca>-rbukrs AND
                        BELNR EQ <glpca>-refdocnr AND
                        GJAHR EQ <glpca>-ryear." AND
    *                    BUZEI EQ <glpca>-refdocln AND
    *                    WITHT EQ BSEG-QSSKZ.
           IF SY-SUBRC eq 0.
              <glpca>-v_rate = with_item-qsatz.
              <glpca>-qsshb = with_item-WT_QSSHB.
              <glpca>-qbshb = with_item-WT_QBSHB.
           ENDIF.
         ENDIF
      ENDLOOP.
    * Liste mit Einzelposten geeignet sortieren.............................
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Einzelposten sortieren'(p30).
    *  if show_ref is initial.
    *    sort i_glpca by rldnr ryear rbukrs rrcty rvers
    *                    docct docnr docln.
    *  else.
      SORT i_glpca BY rldnr kokrs ryear rbukrs rrcty rvers poper
                      refdocct refdocnr refdocln.
    *  endif.
    * Berechtigungsprüfung und gemerkte Belege aufbereiten .................
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Berechtigungsprüfungen'(p40).
      CLEAR: cnt_rldnr, cnt_kokrs, cnt_ryear, cnt_rvers, cnt_bukrs.
      LOOP AT i_glpca ASSIGNING <glpca>.
    *   Berechtigungscheck
        PERFORM check_repo_authority CHANGING authorised.
        IF authorised IS INITIAL.
          DELETE i_glpca.
          s_message = 'X'.
    *     zählen der Sätze ohne Berechtigung
          auth_dbcount = auth_dbcount + 1.
        ELSE. "Weitere Bearbeitung nur für berechtigte Belege...
    *     Zusätzlich merken der Anzahl der Ausprägungen
    *     bestimmter Dimensionen
          ON CHANGE OF <glpca>-rldnr.
            ADD 1 TO cnt_rldnr.
          ENDON.
          ON CHANGE OF <glpca>-kokrs.
            ADD 1 TO cnt_kokrs.
            CALL FUNCTION 'G_CURRENCY_FROM_CT_GET'
              EXPORTING
                ct       = '90'
                kokrs    = <glpca>-kokrs
                rldnr    = <glpca>-rldnr
              IMPORTING
                currency = ksl_curr.
          ENDON.
          ON CHANGE OF <glpca>-poper.
            ADD 1 TO cnt_poper.
          ENDON.
          ON CHANGE OF <glpca>-ryear.
            ADD 1 TO cnt_ryear.
          ENDON.
          ON CHANGE OF <glpca>-rvers.
            ADD 1 TO cnt_rvers.
          ENDON.
          ON CHANGE OF <glpca>-rbukrs.
            ADD 1 TO cnt_bukrs.
            CALL FUNCTION 'G_CURRENCY_FROM_CT_GET'
              EXPORTING
                bukrs    = <glpca>-rbukrs
                ct       = '10'
              IMPORTING
                currency = hsl_curr.
          ENDON.
    *     externe Immobilienbezeichnung                     "ww/kb
    *     on change of i_glpca-imkey.
          IF ( NOT <glpca>-imkey IS INITIAL ).
            CALL FUNCTION 'REMD_IMKEY_TO_EMPGE'
                 EXPORTING
                      i_imkey    = <glpca>-imkey
                      i_dabrz    = <glpca>-dabrz
    *                 I_length   = 20
                 IMPORTING
                      e_empge    = <glpca>-empge
                      e_konty    = <glpca>-konty
                 EXCEPTIONS
                      not_found  = 1.
            IF sy-subrc NE 0.
              CLEAR <glpca>-empge.
              CLEAR <glpca>-konty.
            ENDIF.
    *       CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
          ENDIF.
    *     endon.
    *     on change of i_glpca-dabrz.
    *        call function 'REMD_IMKEY_TO_EMPGE'
    *             exporting
    *                  i_imkey    = i_glpca-imkey
    *                  i_dabrz    = i_glpca-dabrz
    **                 i_length   = 20
    *             importing
    *                  e_empge    = i_glpca-empge
    *                  e_konty    = i_glpca-konty.
    **       CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
    *      endon.
    *     Konvertierungsproblem mit PSP-Nummer bereinigen
          IF NOT <glpca>-ps_psp_pnr IS INITIAL.
            IF <glpca>-ps_psp_pnr EQ space.
              CLEAR <glpca>-ps_psp_pnr.
            ELSE.
              WRITE <glpca>-ps_psp_pnr TO <glpca>-psppp.
              CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'
                EXPORTING
                  input  = <glpca>-psppp
                IMPORTING
                  output = <glpca>-psppp.
            ENDIF.
          ENDIF.
    *     Währungen in Hilfsfeldern speichern
          IF <glpca>-hsl_curr IS INITIAL.
            <glpca>-hsl_curr = hsl_curr.
          ENDIF.
          IF <glpca>-ksl_curr IS INITIAL.
            <glpca>-ksl_curr = ksl_curr.
          ENDIF.
    *     modify i_glpca.
        ENDIF.
      ENDLOOP.
    * Nachricht, wenn nicht alle Einzelposten angezeigt werden.
      IF NOT s_message IS INITIAL.
        MESSAGE s407(km) WITH auth_dbcount.
      ENDIF.
    * EP ausgeben...........................................................
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Einzelposten ausgeben'(p50).
      t_layout-detail_initial_lines = 'X'.
      t_layout-detail_popup         = 'X'.
      t_layout-f2code               = 'PIC1'.                "MICP40K039857
      t_layout-get_selinfos         = 'X'.
      t_layout-group_change_edit    = 'X'.                   "note 576149
      PERFORM fill_listheader.
      PERFORM fieldcat_fill.
      PERFORM spec_groups_fill.
      PERFORM events_fill.                 "MICP40K039857
      ">>MICP40K039857
    *  call function 'K_KKB_LIST_DISPLAY'
    *       exporting
    *            i_callback_program       = 'Z_RCOPCA02_1
    *            i_callback_user_command  = 'USR_CMD'
    *            i_callback_top_of_page   = 'TOP_OF_PAGE'
    **           I_CALLBACK_END_OF_PAGE   =
    **           I_CALLBACK_END_OF_LIST   =
    *            i_callback_pf_status_set = 'SET_PF_STATUS'
    **           I_CALLBACK_LAYOUT_SAVE   =
    **           I_CALLBACK_FIELDCAT_SAVE =
    *            i_tabname                = 'I_GLPCA'
    *            is_layout                = t_layout
    *            it_fieldcat              = t_fieldcat
    **           I_FCTYPE                 = 'R'
    **           IT_EXCLUDING             =
    *            it_special_groups        = t_spec_groups
    **           IT_SORT                  =
    **           IS_SEL_HIDE              =
    **           I_SCREEN_START_COLUMN    = 0
    **           I_SCREEN_START_LINE      = 0
    **           I_SCREEN_END_COLUMN      = 0
    **           I_SCREEN_END_LINE        = 0
    *       tables
    *            t_outtab                 = i_glpca
    *       exceptions
    *            others                   = 1.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
         EXPORTING
    *         I_INTERFACE_CHECK        = ' '
               i_callback_program       = 'Z_RCOPCA02_1'
               i_callback_pf_status_set = 'SET_PF_STATUS'
               i_callback_user_command  = 'USR_CMD'
               i_structure_name         = 'I_GLPCA'
               is_layout                = t_layout
               it_fieldcat              = t_fieldcat
    *         IT_EXCLUDING             =
               it_special_groups        = t_spec_groups
    *         IT_SORT                  =
    *         IT_FILTER                =
    *         IS_SEL_HIDE              =
               i_default                = 'X'
               i_save                   = g_save
               is_variant               = g_variant
               it_events                = t_events
    *         IT_EVENT_EXIT            =
    *         IS_PRINT                 =
    *         I_SCREEN_START_COLUMN    = 0
    *         I_SCREEN_START_LINE      = 0
    *         I_SCREEN_END_COLUMN      = 0
    *         I_SCREEN_END_LINE        = 0
    *    IMPORTING
    *         E_EXIT_CAUSED_BY_CALLER  =
    *         ES_EXIT_CAUSED_BY_USER   =
          TABLES
               t_outtab                 = i_glpca
        EXCEPTIONS
             program_error            = 1
             OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      "<<MICP40K039857
      CLEAR i_glpca.
    *&      Form  CHECK_REPO_AUTHORITY
    *  Check only new auth-object K_PCA                                    *
    *  -->  p1        text
    *  <--  p2        text
    FORM check_repo_authority CHANGING authorized LIKE authorised.
    * fill structure for userexit in K_PCA_RESP_AUTHORITY_CHECK
      DATA: auth LIKE pca_i_auth.          "46a MIC check K_PCA and G_GLTP
      auth-bukrs = <glpca>-rbukrs.
      auth-rldnr = <glpca>-rldnr.
      auth-rvers = <glpca>-rvers.
      auth-rrcty = <glpca>-rrcty.
      CLEAR authorized.
    * check PrCtr/account/activity
      CALL FUNCTION 'K_PCA_RESP_AUTHORITY_CHECK'
        EXPORTING
          i_kokrs             = <glpca>-kokrs
          i_prctr             = <glpca>-rprctr
          i_kstar             = <glpca>-racct
          i_vorgn             = 'REPP'
          i_actvt             = '28'
          i_auth              = auth
          i_no_dialog_message = 'X'
        EXCEPTIONS
          no_authority        = 1
          data_missing        = 2
          OTHERS              = 3.
      IF sy-subrc = 0.                                          "ok
    * check ledger/version/record type
        CALL FUNCTION 'PCA_G_GLTP_AUTH_CHECK'
          EXPORTING
            rldnr            = <glpca>-rldnr
            rvers            = <glpca>-rvers
            rrcty            = <glpca>-rrcty
          EXCEPTIONS
            no_authorisation = 1
            OTHERS           = 2.
        IF sy-subrc = 0.                   "ok, User is authorized
          authorized = 'X'.
        ENDIF.
      ENDIF.
    ENDFORM.                               " CHECK_REPO_AUTHORITY
    *&      Form  INIT_VARS
    *       Initialisieren diverser Hilfsvariablen und -tabellen           *
    FORM init_vars.
      DATA BEGIN OF nametab OCCURS 80. "Tabelle mit Feldern aus der RPCA2
              INCLUDE STRUCTURE dntab.
      DATA END OF nametab.
      SELECT SINGLE * FROM t000
                      CLIENT SPECIFIED
                      WHERE mandt = sy-mandt.
      REFRESH nametab.
      CALL FUNCTION 'NAMETAB_GET'
        EXPORTING
          only    = 'T'
          tabname = 'RPCA2'
        TABLES
          nametab = nametab.
    * Übernehmen der Feldnamen, die auch in der GLPCA
    * vorkommen.
      LOOP AT nametab WHERE fieldname NE 'KSL_CURR'
                        AND fieldname NE 'HSL_CURR'
                        AND fieldname NE 'EMPGE'               "ww/kb
                        AND fieldname NE 'KONTY'.              "ww/kb
        MOVE nametab-fieldname TO tab_fields-name.
        APPEND tab_fields.
      ENDLOOP.
    * fill Fields of receiver for BBS                          "MIC46C
      CALL FUNCTION 'RSTI_REPORT_FIELDS_FIND'
        EXPORTING
          e_repid   = 'Z_RCOPCA02_1'
          e_type    = 'R'
        TABLES
          it_fields = bbs_fieldtab.
    * correct fieldnames
      READ TABLE bbs_fieldtab WITH KEY rfield = 'PRCTR'.
      IF sy-subrc = 0.
        bbs_fieldtab-rfield = 'RPRCTR'.
        MODIFY bbs_fieldtab INDEX sy-tabix.
      ENDIF.
      READ TABLE bbs_fieldtab WITH KEY rfield = 'PPRCTR'.
      IF sy-subrc = 0.
        bbs_fieldtab-rfield = 'SPRCTR'.
        MODIFY bbs_fieldtab INDEX sy-tabix.
      ENDIF.
      READ TABLE bbs_fieldtab WITH KEY rfield = 'BUKRS'.
      IF sy-subrc = 0.
        bbs_fieldtab-rfield = 'RBUKRS'.
        MODIFY bbs_fieldtab INDEX sy-tabix.
      ENDIF.
    * Unicode
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      CLEAR hex00 WITH cl_abap_char_utilities=>minchar.
      CLEAR hexff WITH cl_abap_char_utilities=>maxchar.
    ENDFORM.                               " INIT_VARS
    *       FORM FILL_LISTHEADER                                          *
    *       List-Header in Abhängigkeit der selektierten Daten            *
    FORM fill_listheader.
      READ TABLE i_glpca INDEX 1.
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Ledger              '(h01).
      IF cnt_rldnr <= 1.
        t_listheader-info = i_glpca-rldnr.
      ELSE.
        t_listheader-info = '*'.
      ENDIF.
      APPEND t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Kostenrechnungskreis'(h02).
      IF  cnt_kokrs <= 1.
        t_listheader-info = i_glpca-kokrs.
      ELSE.
        t_listheader-info = '*'.
      ENDIF.
      APPEND t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Buchungskreis       '(h03).
      IF cnt_bukrs <= 1.
        t_listheader-info = i_glpca-rbukrs.
      ELSE.
        t_listheader-info = '*'.
      ENDIF.
      APPEND t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Buchungsperiode     '(h04).
      IF cnt_poper <= 1.
        t_listheader-info = i_glpca-poper.
      ELSE.
        t_listheader-info = '*'.
      ENDIF.
      APPEND t_listheader.
      IF cnt_ryear <= 1.
        t_listheader-typ  = 'S'.
        t_listheader-key  = 'Geschäftsjahr       '(h05).
        t_listheader-info = i_glpca-ryear.
        APPEND t_listheader.
      ENDIF.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Version             '(h06).
      IF cnt_rvers <= 1.
        t_listheader-info = i_glpca-rvers.
      ELSE.
        t_listheader-info = '*'.
      ENDIF.
      APPEND t_listheader.
    ENDFORM.                    "fill_listheader
    *&      Form  FIELDCAT_FILL
    *&      Aufbau des Feldkataloges für den K_KKB_LIST_DISPLAY,           *
    *&      bzw REUSE_ALV_LIST_DISPLAY,                                    *
    *&      weitere Infos enthält die FktBaustein-Doku                     *
    FORM fieldcat_fill.
      DATA: i TYPE i VALUE 0.
      REFRESH t_fieldcat.
    * Ledger
    *  if cnt_rldnr > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RLDNR'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
    *   afield-key         = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Satzart
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RRCTY'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    * Version
    *  if cnt_rvers > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RVERS'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Periode
    *  if cnt_poper > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'POPER'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Geschäftsjahr
    *  if cnt_ryear > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RYEAR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Referenzbelegtyp
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'REFDOCCT'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '2'.
      afield-seltext_s   = 'Typ'(t01).
      afield-seltext_m   = 'Belegtyp'(t02).
      afield-seltext_l   = 'Ref.Belegtyp'(t03).
      afield-outputlen   = 3. "Platz für die Sterne der Zwischensummen
    *  if not show_ref is initial.
      afield-key = 'X'.
    *  else.
    *    afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Referenzbelegnummer
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'REFDOCNR'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '2'.
      afield-seltext_s  = 'Refbeleg'(t04).
      afield-seltext_m  = 'Refbelegnr'(t05).
      afield-seltext_l  = 'Ref.Belegnummer'(t06).
    *  if not show_ref is initial.
      afield-key = 'X'.
    *  else.
    *    afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Referenzbelegzeile
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'REFDOCLN'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '2'.
      afield-seltext_s   = 'Zeile'(t07).
      afield-seltext_m   = 'Belegzeile'(t08).
      afield-seltext_l   = 'Ref.Belegzeile'(t09).
    *  if not show_ref is initial.
      afield-key = 'X'.
    *  else.
    *    afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Belegtyp PCA
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'DOCCT'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '1'.
      afield-outputlen   = 3. "Platz für die Sterne der Zwischensummen
    *  if show_ref is initial.
      afield-key = 'X'.
    *  else.
      afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Belegnummer PCA
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'DOCNR'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '1'.
    *  if show_ref is initial.
      afield-key = 'X'.
    *  else.
      afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Belegzeile PCA
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'DOCLN'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '1'.
    *  if show_ref is initial.
      afield-key = 'X'.
    *  else.
      afield-no_out = 'X'.
    *  endif.
      APPEND afield TO t_fieldcat.
    * Kostenrechnungskreis
    *  if cnt_kokrs > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'KOKRS'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Buchungskreis
    *  if cnt_bukrs > 1.
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RBUKRS'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
      afield-seltext_s  = 'BuKrs'(b01).
      afield-seltext_m  = 'BuKrs'(b02).
      afield-seltext_l  = 'Empfänger-BuKrs'(b03).
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    *  endif.
    * Profit Center
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RPRCTR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
    * Eliminierungs-Profit-Center
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'EPRCTR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
    * Sender-Profit-Center
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'SPRCTR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
    * Konto
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RACCT'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
      ADD 1 TO i.
    * Kontentext
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RACCT_KTEXT'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'RPCAK'.
      afield-ref_fieldname = 'KTEXT'.
      afield-seltext_s   = 'Kont-txt.'(m11).
      afield-seltext_m   = 'Kontentext'(m12).
      afield-seltext_l   = 'Kontentext'(m13).
      afield-sp_group    = '7'.
      APPEND afield TO t_fieldcat.
      ADD 1 TO i.
    * Statistische Kennzahl
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'STAGR'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '12'.
      APPEND afield TO t_fieldcat.
    * Soll/Haben-Kennzeichen
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'DRCRK'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      APPEND afield TO t_fieldcat.
    * Wert in Profit-Center-Währung
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'KSL'.
      afield-do_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
    *  AFIELD-SELTEXT_S   = 'PrCtr-Hauswhr.'(P01).
    *  AFIELD-SELTEXT_M   = 'PrCtr-Hauswährung'(P02).
    *  AFIELD-SELTEXT_L   = 'Profit-Center-Hauswährung'(P03).
      afield-cfieldname  = 'KSL_CURR'.
      afield-sp_group    = '3'.
      APPEND afield TO t_fieldcat.
    * Währungsschlüssel KSL
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos       = i.
      afield-fieldname     = 'KSL_CURR'.
      afield-ref_tabname   = 'TKA01'.
      afield-ref_fieldname = 'PCACUR'.
      afield-no_sum        = 'X'.
      afield-no_out        = 'X'.
      afield-seltext_s     = 'PrCtrHW'(t10).
      afield-seltext_m     = 'Währungsschl. PrCtrHW'(t11).
      afield-seltext_l     = 'Währungsschl. PrCtrHW'(t12).
      afield-sp_group      = '3'.
      APPEND afield TO t_fieldcat.
    * Betrag in Hauswährung
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'HSL'.
      afield-do_sum      = 'X'.
      afield-no_out      = 'X '.
      afield-ref_tabname = 'GLPCA'.
      afield-cfieldname  = 'HSL_CURR'.
      afield-sp_group    = '4'.
      APPEND afield TO t_fieldcat.
    * Währungsschlüssel Hauswährung
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos       = i.
      afield-fieldname     = 'HSL_CURR'.
      afield-ref_tabname   = 'T001'.
      afield-ref_fieldname = 'WAERS'.
      afield-no_sum        = 'X'.
      afield-no_out        = 'X '.
      afield-seltext_s     = 'BukrW.'(t13).
      afield-seltext_m     = 'Währungsschl. BukrW'(t14).
      afield-seltext_l     = 'Währungsschl. BukrW'(t15).
      afield-sp_group      = '4'.
      APPEND afield TO t_fieldcat.
    * Betrag in Transaktionswährung
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'TSL'.
      afield-no_out      = 'X '.
      afield-ref_tabname = 'GLPCA'.
      afield-cfieldname  = 'RTCUR'.
      afield-sp_group    = '5'.
      APPEND afield TO t_fieldcat.
    * Währungsschlüssel Transaktionswährung
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos       = i.
      afield-fieldname     = 'RTCUR'.
      afield-ref_tabname   = 'GLPCA'.
      afield-ref_fieldname = 'RTCUR'.
      afield-no_sum        = 'X'.
      afield-no_out        = 'X '.
      afield-seltext_s     = 'TW  '(t16).
      afield-seltext_m     = 'Währungsschl. TW'(t17).
      afield-seltext_l     = 'Währungsschl. TW'(t18).
      afield-sp_group      = '5'.
      APPEND afield TO t_fieldcat.
    * Menge
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'MSL'.
      afield-qfieldname  = 'RUNIT'.
      afield-no_out      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group      = '6'.
      APPEND afield TO t_fieldcat.
    * Mengeneinheit
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RUNIT'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group      = '6'.
      APPEND afield TO t_fieldcat.
    * Herkunftsobjektart
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RHOART'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group      = '7'.
      APPEND afield TO t_fieldcat.
    * Funktionsbereich
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RFAREA'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group      = '7'.
      APPEND afield TO t_fieldcat.
    * Objektklasse
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RSCOPE'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group      = '1'.
      APPEND afield TO t_fieldcat.
    * G/L-Vorgang
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'ACTIV'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-seltext_s     = 'Vorg.'(t31).
      afield-seltext_m     = 'Vorgang'(t32).
      afield-seltext_l     = 'Betriebswirt. Vorgang'(t33).
      afield-sp_group      = '1'.
      APPEND afield TO t_fieldcat.
    * Geschäftsbereich
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'GSBER'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group      = '8'.
      APPEND afield TO t_fieldcat.
    * Kostenstelle
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'KOSTL'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '9'.
      APPEND afield TO t_fieldcat.
    * CO-Auftrag
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'AUFNR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '9'.
      APPEND afield TO t_fieldcat.
    * Projekt
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'PSPPP'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
      afield-sp_group    = '9'.
      afield-ref_tabname   = 'PRPS'.
      afield-ref_fieldname = 'POSID'.
      APPEND afield TO t_fieldcat.
    * Debitor
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'KUNNR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-seltext_s   = 'Debitor'(d01).
      afield-seltext_m   = text-d01.
      afield-seltext_l   = text-d01.
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    * Customer Name
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'C_NAME1'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'KNA1'.
      afield-no_out      = 'X'.
      afield-seltext_s   = 'Customer Name'.
      afield-seltext_m   = 'Cust Name'.
      afield-seltext_l   = 'C Name'.
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    * Kreditor
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'LIFNR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-seltext_s   = 'Kreditor'(k01).
      afield-seltext_m   = text-k01.
      afield-seltext_l   = text-k01.
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    * Vendor name
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'NAME1'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'LFA1'.
      afield-no_out      = 'X'.
      afield-seltext_s   = 'Vendor Name'(v01).
      afield-seltext_m   = text-v01.
      afield-seltext_l   = text-v01.
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    * Withholding tax rate
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'V_RATE'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'WITH_ITEM'.
      afield-no_out      = 'X'.
      afield-seltext_s   = 'Withholding tax rate'.
      afield-seltext_m   = 'With. tax rate'.
      afield-seltext_l   = 'W. Tax rate'.
      afield-sp_group    = '8'.
      APPEND afield TO t_fieldcat.
    * Withholding Tax Base Amount
      ADD 1 TO i.
      CLEAR afield.
      afield-col_pos     = i.
      afield-fieldname   = 'QSSHB'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = '

    Hi pavan.
    something is definitely wrong with your code: You have an internal table for display with fields from rpca 2 and additional some more fields. I do not see a field ORT01 for CITY or PSTLZ for POSTAL CODE, at least to in table GLPCA from where the data are extracted.
    You must fill PSTLZ and ORT01 (if it is for the supplier):
         SELECT SINGLE * FROM LFA1
             WHERE LIFNR = <glpca>-LIFNR AND
             SPRAS = SY-LANGU.
         IF SY-SUBRC eq 0.
            <glpca>-name1 = lfa1-name1.
            <glpca>-adrnr = lfa1-adrnr.
            <glpca>-stras = lfa1-stras.
    **** add here: ***
      select single ort01 pstlz
        into corresponding fields of <glpca>
        from adrc
        where adrnr = <glpca>-adrnr.
         ENDIF.
    Make sure that fields ORT01 and PSTLZ are defined for internal table i_glpca.
    Regards,
    Clemens

  • Doubt In a Select Query..

    Hi..
    I have a Doubt in a simple Query from the table NAST.
    My query is as follows:--
    Select kappl
           objky
           kschl
           parnr
           parvw
           nacha
           vsztp
    from nast into table vit_nast
    where kappl =   p_kappl
    and   kschl in s_kschl
    and   parnr in s_parnr
    and   nacha =   p_nacha
    and   vsztp in s_vsztp.
    Now I want to select all the NAST records which are either not processed (NAST-VSTAT = 0) or incompletely processed (NAST-VSTAT = 2)(the field in the table NAST is VSTAT which denotes the Processing status of message)
    So Can I add both the conditions in the WHERE clause of the the above Select Query?
    Is there any other optimised way I can do that?
    Thanks

    ranges: r_stat for nast-vstat.
    r_stat-low = '0'.
    r_stat-option = 'EQ'.
    r_stat-sign = 'I'.
    append r_stat.
    clear r_stat.
    r_stat-low = '2'.
    r_stat-option = 'EQ'.
    r_stat-sign = 'I'.
    append r_stat.
    clear r_stat.
    Select kappl
    objky
    kschl
    parnr
    parvw
    nacha
    vsztp
    from nast into table vit_nast
    where kappl = p_kappl
    and kschl in s_kschl
    and parnr in s_parnr
    and nacha = p_nacha
    and vsztp in s_vsztp
    <b>and vstat in r_stat.</b>
    check this..
    Regards
    vijay

  • WITH clause in CURSOR

    Hi,
    I was going through some docs on using WITH clause in curosr...but coulcn't understand.
    I was going through existing code for customization, that has 'WITH' clause.
    I'm trying to understand below piece of code.
    could you let me know what the below code is about..
      CURSOR CUR_CRK
      IS
      WITH PTLPM_WITH AS
        (SELECT
          /*+ INDEX(P_TR_LOAN_PAST_MONTHLY PK_P_TR_LOAN_PAST_MONTHLY) */
        FROM INF.P_TR_LOAN_PAST_MONTHLY
        WHERE POST_DATE    =P_POST_DATE
        AND TREND_GROUP_ID = 'M'
        AND APPL_ID       IN ('FL','LN')
      UIGL_INF_WITH AS
      (SELECT * FROM INF.U_IM_GALL_LOAN
      XHCC_INF_WITH as
      (SELECT * FROM DWC.XREF_HIER_COST_CENTER_11SEP12 --INF.XREF_HIER_COST_CENTER
      )Thanks.

    Perhaps a simple example will make it clear...
    SQL> ed
    Wrote file afiedt.buf
      1  select e.empno, e.ename, d.dname
      2  from        (select * from emp) e
      3         join (select * from dept) d
      4*        on   (e.deptno = d.deptno)
    SQL> /
         EMPNO ENAME      DNAME
          7369 SMITH      RESEARCH
          7499 ALLEN      SALES
          7521 WARD       SALES
          7566 JONES      RESEARCH
          7654 MARTIN     SALES
          7698 BLAKE      SALES
          7782 CLARK      ACCOUNTING
          7788 SCOTT      RESEARCH
          7839 KING       ACCOUNTING
          7844 TURNER     SALES
          7876 ADAMS      RESEARCH
          7900 JAMES      SALES
          7902 FORD       RESEARCH
          7934 MILLER     ACCOUNTING
    14 rows selected.Ok, a bit of a nonsense query in itself, but it's demonstrating that we have two subqueries that we are getting our data from.
    Now, writing the same query using a WITH clause...
    SQL> ed
    Wrote file afiedt.buf
      1  with e as (select * from emp)
      2      ,d as (select * from dept)
      3  select e.empno, e.ename, d.dname
      4* from   e join d on (e.deptno = d.deptno)
    SQL> /
         EMPNO ENAME      DNAME
          7369 SMITH      RESEARCH
          7499 ALLEN      SALES
          7521 WARD       SALES
          7566 JONES      RESEARCH
          7654 MARTIN     SALES
          7698 BLAKE      SALES
          7782 CLARK      ACCOUNTING
          7788 SCOTT      RESEARCH
          7839 KING       ACCOUNTING
          7844 TURNER     SALES
          7876 ADAMS      RESEARCH
          7900 JAMES      SALES
          7902 FORD       RESEARCH
          7934 MILLER     ACCOUNTING
    14 rows selected.As you can see, the subqueries have been moved out of the main query and put into the WITH clause, and then the main query just references those subqueries aliases.
    In the above example, there's not much point in doing this, but in more complex queries, you may have a subquery that is used several times, in which case having it in the WITH clause means that that subquery is processed just once and used many times, (you can also look at the MATERIALIZE hint to help improve performance with such subqueries if necessary)
    The difficulty with finding this in the documentation is because you will no doubt be trying to search for "WITH", which isn't a very good search term to be using as it's used in the english language too much for an accurate hit... so... when you learn it's called "Subquery Factoring" (because you are factoring out the subqueries from the main query), it then becomes easier to find...
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2161315
    ... and you see it's included as part of the documentation for the SQL SELECT statement.

  • Order By Clause in View

    Hi,
    I have a doubt regarding Order By Clause in Views.
    As per my knowledge, we can't put an order by clause in the subquery that defines view. But when i created a view in Oracle 9i with the order by clause, view got created.
    Please see the my view code below :
    create or replace view testview
    as select * from employees
    order by 1,2;
    Could anyone please confirm that we can have order by clause in Views in oracle 9i?
    Thanks,
    Tandra

    According to the SQL Reference doc, there is no such restriction for a non-updatable view:
    The view subquery cannot select the CURRVAL or NEXTVAL pseudocolumns.
    If the view subquery selects the ROWID, ROWNUM, or LEVEL pseudocolumns, those columns must have aliases in the view subquery.
    If the view subquery uses an asterisk (*) to select all columns of a table, and you later add new columns to the table, the view will not contain those columns until you re-create the view by issuing a CREATE OR REPLACE VIEW statement.
    For object views, the number of elements in the view subquery select list must be the same as the number of top-level attributes for the object type. The datatype of each of the selecting elements must be the same as the corresponding top-level attribute.
    You cannot specify the SAMPLE clause.
    This restriction exists only for updatable views:
    If you want the view to be inherently updatable, it must not contain any of the following constructs:
    A set operator
    A DISTINCT operator
    An aggregate or analytic function
    A GROUP BY, ORDER BY, CONNECT BY, or START WITH clause
    A collection expression in a SELECT list
    A subquery in a SELECT list
    Joins (with some exceptions as described in the paragraphs that follow).

  • IN clause with ORDER BY clause in sub-queries

    Hello,
    We generate dynamic queries with the following statement pattern (could be many union/intersect sub-queries):
    select my_col
    from my_table
    where my_col IN
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    I know that I can do just the sub-queries w/ an ORDER BY clause as follows (as long as the 2nd parameter in the select stmts are of the same type):
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    order by 2 desc
    But my questions are:
    1. What is (if there is) the syntax that will ensure that the result set order will be that of the ordering of the sub-queries?
    Or does my SQL stmt have to have syntactically (but not semantically) change to achieve this?
    Thanks,
    Jim

    Randolf Geist wrote:
    just a minor doubt - I think it is not officially supported to have separate ORDER BYs in a compound query with set operators (e.g. UNION / UNION ALL subsets). Of course one could use inline views with NO_MERGE + NO_ELIMINATE_OBY hints, but I think the only officially supported approach is to use a single, final ORDER BY (that needs to use positional notation as far as I remember).
    Randolf,
    You're right, of course, about the separate "order by" clauses.
    Interestingly the following type of thing does work though (in 10.2.0.3, at least):
    with v1 as (
        select * from t1 where col1 = 'ABC' order by col2
    v2 as (
        select * from t1 where col1 = 'DEF' order by col2
    select * from v1
    union all
    select * from v2
    ;A quick check the execution plan suggsts that Oracle appears to be convering this to the following - even though its technically not acceptable in normal circumstances:
    select * from t1 where col1 = 'ABC' order by col2
    union all
    select * from t1 where col1 = 'DEF' order by col2
    ;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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Ipad 2 & ios7 issue with HDMI adapter

    I have problem with connecting ipad2 to TV using HDMI adapter (genuine apple) after upgrading to ios 7.0 TV shows static or blinking black screen   Worked perfect with 6.1.3.  Pls advice.

  • Custom command set problems

    Hi, I am having some problems with my custom Avid based command set. I have had the "A" and "S" keys assigned to "Go to prev/next edit" to simulate Avid but want to change it to "Up" and "Down" which does pretty much the same in the timeline but allo

  • Legend placement in Excel

    Hi, I'm trying to control the placement of a chart legend in Excel from Labview using active X. The VBA lines I need to perform in Labview are as follows: ActiveChart.Legend.Select Selection.Position = xlBottom The problem I'm having is that I can't

  • Open zip/rar files in mail

    Hello, I am using the Mail app on my iphone 4s and my ipad3. When someone send me a zip file and I click on it nothing happens.... I can't open it through the email app or download it and open it through another app (I have iZip app....) Why is that

  • I downloaded firefox on my computer but I can not open it

    firefox crushed in my computer, I delete the brogram and downloaded again but I am not able to open. I repated this few time but no success.