How to use a case statement in where clause

Hi All,
I have a requirement which is to bring all the claims that are created in the last month.So, i wrote a query something like this
select * from claims
where
(Month(ClaimOpenDate) = Month(Getdate())-1 and year(claimopendate) = year(getDate()))
which would give me any new claims created in last month of current year, but this condition fails if we are in the first month of a new year( lets say if we are in 2016 jan then month(getdate())-1 would be 0 and year(getdate()) would be 2016 so we dont
find any records where year is 2016 and month is 0 for claimopen).
So, i would like to use a case statament or something which can help me get around this one.
Can someone please help me with any suggestions?
Thanks

Hi Jason,
Thanks a lot for your help. This is what exactly i am looking for but i just gave a sample query above below is my original query 
select
row_number() over (order by [ClaimNumber]) as DataElementName
,c.PolicyNumber as PolicyNum
, c.FirstName as CustNameF
,c.LastName as CustNameL
,c.PolicyForm as PolType
,'Homesite' as Company
,[ClaimNumber] as ClaimNum
,E.office as Ofc
,e.Supervisior_FullName as Team
, RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FORepF
, case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FORepL
,e.AdjusterID as RepC -- not sure
,CONVERT ( varchar,c.LossDate ,101) as DOL
,convert (varchar,c.ClaimOpenDate,101) as DOR
,rtrim(c.Loss_State) as LossSt
,c.Loss_ZipCode as LossZIP
,c.Loss_City as LossCity
,c.LossType as FOL
,'' as PR
,'' as PRNum
,1 as FeaNum
,'HO' as FeaType
,case when rtrim(c.claimStatus)= 'Closed' then 'Closed' else 'Open' end as FeaStat
,'' as FeaOpen
,'' as FeaClosed
,s.PaymentIndemnityAmount as PaidAmt
,s.ReserveIndemnityAmount as Reserve
,'' as Sub
,'' as Sal
,'' as FeatOwnOfc
,e.Supervisior_FullName as FeatOwnTeam
,RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FeatOwnRepF
,case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FeatOwnRepL
,e.AdjusterID as FeatOwnRepCode
,NULL AS Description --not sure
from [Stg].[HS_DW_RV_Claims] c
inner join [dbo].[Claims_Primary_Adjuster] a on a.CLAIM_NUMBER = c.ClaimNumber
inner join [dbo].[vw_Adjuster] e on e.adjuster_Name = a.primary_ADJUSTER
left outer join [Stg].[HS_DW_LossClaimSummary] s on c.ClaimKey=s.ClaimKey
where c.LoadSource = 'CMS'
and
(s.PaymentIndemnityAmount <>0 or s.PaymentExpenseAmount <>0)
and
ClaimOpenDate BETWEEN DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP) -1, 0) AND DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP), 0)
UNION ALL
select
row_number() over (order by [ClaimNumber]) as DataElementName
,c.PolicyNumber as PolicyNum
, c.FirstName as CustNameF
,c.LastName as CustNameL
,c.PolicyForm as PolType
,'Homesite' as Company
,[ClaimNumber] as ClaimNum
,E.office as Ofc
,e.Supervisior_FullName as Team
, RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FORepF
, case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FORepL
,e.AdjusterID as RepC -- not sure
,CONVERT ( varchar,c.LossDate ,101) as DOL
,convert (varchar,c.ClaimOpenDate,101) as DOR
,rtrim(c.Loss_State) as LossSt
,c.Loss_ZipCode as LossZIP
,c.Loss_City as LossCity
,c.LossType as FOL
,'' as PR
,'' as PRNum
,1 as FeaNum
,'HO' as FeaType
,case when rtrim(c.claimStatus)= 'Closed' then 'Closed' else 'Open' end as FeaStat
,'' as FeaOpen
,'' as FeaClosed
,s.PaymentIndemnityAmount as PaidAmt
,s.ReserveIndemnityAmount as Reserve
,'' as Sub
,'' as Sal
,'' as FeatOwnOfc
,e.Supervisior_FullName as FeatOwnTeam
,RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FeatOwnRepF
,case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FeatOwnRepL
,e.AdjusterID as FeatOwnRepCode
,DESCRIPTION --not sure
from Stg.IG_Document D
inner join [Stg].[HS_DW_RV_Claims] c on D.PARENTREF = C.ClaimNumber
inner join [dbo].[Claims_Primary_Adjuster] a on a.CLAIM_NUMBER = c.ClaimNumber
inner join [dbo].[vw_Adjuster] e on e.adjuster_Name = a.primary_ADJUSTER
left outer join [Stg].[HS_DW_LossClaimSummary] s on c.ClaimKey=s.ClaimKey
where c.LoadSource = 'CMS'
and
DESCRIPTION like '%Denial Letter%'
and
ClaimOpenDate BETWEEN DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP) -1, 0) AND DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP), 0)
So if i use your logic in the end for both the where clauses its been more than 10 minutes and the query is still running however if i use my old method it doesnt even take a second. Looks like its affecting the execution plan. Any suggestions to get around
this one please?
Thanks

Similar Messages

  • Case statement in where clause ??

    Hello gurus,
    Can we use case statements in where clause ?? Any example will be great!
    And also i would like to know, besides CASE and DECODE statements, Is there any way we can use IF ELSE statements in SELECT clause or in WHERE clause ?
    Thank you!!

    Hi,
    user642297 wrote:
    Hoek,
    Thanks for the reply
    Whatever you return from 'then' should match your criteria.I didnt get this part...can you elaborate this part ?? Thank you!!Remember what a CASE expression does: it returns a single value in one of the SQL data types (or NULL).
    You're probably familiar with conditions such as
    WHERE   col = 1Inthe example above, col could be replaced by any kind of expression: a function call, and operation (such as "d * 24") or a CASE expression, which is exactly what Hoek posted:
    where  case
             when col = 6 then 1
             when col = 9 then 1
           end = 1;I think what Hoek meant about mnatching was this: since the CASE expression is being compared to a NUMBER, then every THEN clause (as well as the ELSE, if there is one) should return the same data type. You can't have one THEN clause return a NUMBER, and another one in the same CASE expression return a DATE, like this:
    where  case
             when col = 6 then 1
             when col = 9 then SYSDATE     -- WRONG! Raises ORA-00932: inconsistent datatypes
           end = 1; 
    By the way, it's rare when a CASE expression really helps in a WHERE clause. CASE is great for doing conitional stuff in places where you otherwise can't (in the ORDER BY clause, for example), but the WHERE clause was designed for conditions.
    Hoek was just trying to give a simple example. If you really wanted those results, it would be simpler to say:
    where  col = 6
    or     col = 9and simpler still to say
    where  col  IN (6, 9)

  • Case statement within where clause

    How can i write a case statement within Where clause of SQL statement.
    Ex:
    If sysdate is less than Dec 31 of 2009 then run the query for 2009 else run the query for 2010.
    belwo query is not working. Please let me know how can i write a case statement within where clause.
    Select * from table
    where
    Case
    when to_char(sysdate,'yyyymmdd')<=20091231 then tax_year=2009
    else tax_year=2010
    End

    Hi,
    You can get the results you want like this:
    Select  *
    from      table
    where   tax_year = Case
                      when  to_char(sysdate,'yyyymmdd') <= 20091231
                      then  2009
                      else  2010
                 End
    ;A CASE expression returns a single value in one of the SQL data types, such as a NUMBER, VARCHAR2 or DATE. There is no boolean type in SQL.

  • How to use the CASE Expression in Where Cluase?

    Hi All,
    I'm trying to use the CASE Expression in the Where Clause at some trigger on the Form?
    I've tried this Code:
    Declare
    N Number;
    begin
    SELECT COUNT(E.EMP_SID)
         INTO N
         FROM EMPLOYEES E, RANKS R
         WHERE CASE WHEN R.qualification_sid = 1104 AND E.rank_sid = 8 THEN
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.spe_per)+1)
         ELSE
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.mili_yea_per)+1)
         END
         BETWEEN TO_DATE('01-07-2011', 'DD-MM-RR') AND TO_DATE('31-07-2011', 'DD-MM-RR');
    END;
    When I run this code as a normal query at any SQL editor it works successfully, But When I Compile it at some trigger on the Form it gives me this error:
    Encountered the symbol "CASE" when expecting one of the following:
    ( - + mod ......
    Heeey how to specify the previous code to be shown as code in the thread?
    Note: I'm using Forms 6i

    OK I tried it and worked but for one condition:
    WHERE DECODE (E.qualification_sid, 1104,
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.spe_per)+1),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.mili_yea_per)+1))
         BETWEEN TO_DATE('01-07-2011', 'DD-MM-RR') AND TO_DATE('31-07-2011', 'DD-MM-RR')
    But how to put two conditions for the same Expression:
    WHERE DECODE ((E.qualification_sid, 1104) AND (E.RANK_SID, 8),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.spe_per)+1),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.mili_yea_per)+1))
         BETWEEN TO_DATE('01-07-2011', 'DD-MM-RR') AND TO_DATE('31-07-2011', 'DD-MM-RR')
    The previous code gives me this error: missing right parenthesis

  • How to use a function in a Where Clause?

    Hi,
    I've got a doubt. If MY_FUNCT is a function that returns a boolean, can I use it in a where clause for writing a query like this?:
    select ...
    from table a
    where ...
    and MY_FUNC (a.field) = true
    Thanks!
    Edited by: Mark1970 on 2-lug-2010 3.27

    Bear in mind that this could kill your performance.
    Depending on what you're doing, how many tables and other predicates are involved, you might want to try to eliminate all other data early before applying your function predicate otherwise your function might be called more times than you might have imagined. Strategies for this include subquery factoring and the old ROWNUM trick for materialising an inline view.
    If performance is impacted, you might also want to consider using a function-based index provided that the function is deterministic.

  • Case statement with where clause.

    I appreciate that there are much simpler ways to run this query but I wondered if anyone else had come across the following -
    select distinct
    product_table.a,
    product_table.b,
    product_table.c,
    CASE WHEN product_table.c IN ('A','AA') THEN 'AAA'     
    WHEN product_table.b = 'B' THEN 'BBB'
    WHEN product_table.c IN ('C','CC','CCC') THEN 'CCC'
    WHEN product_table.b IN ('D','DD') THEN 'DDD'
    WHEN product_table.b LIKE 'E%' THEN 'EEE'
    WHEN product_table.b LIKE 'F%' THEN 'FFF'
    WHEN product_table.b LIKE 'G%' THEN 'GGG'
    ELSE 'UNKNOWN' END
    from product_table                    
    where
    ( CASE WHEN product_table.c IN ('A','AA') THEN 'AAA'     
    WHEN product_table.b = 'B' THEN 'BBB'
    WHEN product_table.c IN ('C','CC','CCC') THEN 'CCC'
    WHEN product_table.b IN ('D','DD') THEN 'DDD'
    WHEN product_table.b LIKE 'E%' THEN 'EEE'
    WHEN product_table.b LIKE 'F%' THEN 'FFF'
    WHEN product_table.b LIKE 'G%' THEN 'GGG'
    ELSE 'UNKNOWN' END) = 'FFF'
    when this query runs its as if the where clause = 'FFF' does not exist and all rows are returned.
    Thanks, Sarah.

    Technical questions should be addressed to one of the technical forums. You'll probably find that the folks in the PL/SQL forum (Products | Database | PL/SQL) have some thoughts.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Using Case Statement in Where Clause

    Hello All,
    I wish to conditionally use different columns for retrieving unique row. This will be dependent upon a parameter passed to the Function/Procedure.
    The SQL framed looks as below:
    +select *+
    from Test_Table
    where column_1 = <some_value>
    and case when p_call_location = 'A' then column_2 like '%ABC%'
    when p_call_location = 'B' then column_2 Not Like '%ABC%'
    when p_call_location = 'C' then column_3 like '%EFG%'
    when p_call_location = 'D' then column_3 like '%IJKL%'
    END;
    However, I am not sure if this works, as I am getting a Missing Right Paranthesis error. Major hinderance is the depedency on multiple columns, which would need to be referred for particular scenario.
    Can somebody please help me with an example or a skeleton of how a query should be formed?
    Appreciate an early reply!!!

    HI,
    i think this may solve your issue...get back to me if u have any qry's on this.
    CREATE TABLE Test_Table
    (p_call_location VARCHAR2(10),
    COLUMN_1 VARCHAR2(20),
    COLUMN_2 VARCHAR2(20),
    COLUMN_3 VARCHAR2(20))
    INSERT INTO Test_Table VALUES('A','COMNVAL','ABC_PER','XXXX');
    INSERT INTO Test_Table VALUES('A','COMNVAL','PER','XXXX');
    INSERT INTO Test_Table VALUES('B','COMNVAL','ABC_PER','XXXX');
    INSERT INTO Test_Table VALUES('B','COMNVAL','PER','XXXX');
    INSERT INTO Test_Table VALUES('C','COMNVAL','ABC_PER','EFG_XXXX');
    INSERT INTO Test_Table VALUES('C','COMNVAL','ABC_PER','XXXX');
    INSERT INTO Test_Table VALUES('D','COMNVAL','ABC_PER','EFG_XXXX_IJKL');
    INSERT INTO Test_Table VALUES('D','COMNVAL','ABC_PER','GGG_XXXX');
    SELECT * FROM Test_Table WHERE ROWID IN (
    select case when p_call_location = 'A' AND column_2 like '%ABC%' THEN ROWID
    when p_call_location = 'B' AND column_2 Not Like '%ABC%' THEN ROWID
    when p_call_location = 'C' AND column_3 like '%EFG%' THEN ROWID
    when p_call_location = 'D' AND column_3 like '%IJKL%' THEN ROWID
    END AS KK
    from Test_Table
    where column_1 = 'COMNVAL');
    even u can use the below qry also
    select *
    from test_table
    where column_1 = 'COMNVAL'
    and (case when p_call_location = 'A' and column_2 like '%ABC%' then 'VALID'
    when p_call_location = 'B' and column_2 Not Like '%ABC%' then 'VALID'
    when p_call_location = 'C' and column_3 like '%EFG%' then 'VALID'
    when p_call_location = 'D' and column_3 like '%IJKL%' then 'VALID'
    else 'INVALID'
    END) = 'VALID';
    thanks
    prasuna.
    Edited by: user13820845 on Feb 21, 2011 10:25 PM

  • How to use maximum date condition in where clause ?

    Hi I want to check if SWITCH_FLAG has 'Y' for the latest batch run..how can write it?
    (select a.SWITCH_FLAG
    from MORTGAGE
    where SYS_EFF_DATE = max(SYS_EFF_DATE)
    ) as expected_result
    Error message:
    ORA-00934: group function is not allowed here

    This will give you the switch_flag for the latest eff_date,
    SELECT SWITCH_FLAG
      FROM (SELECT A.SWITCH_FLAG, ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;
    --if you want to test try this,
    SELECT SWITCH_FLAG,SYS_EFF_DATE
      FROM (SELECT A.SWITCH_FLAG,SYS_EFF_DATE , ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;G.

  • How do I use the CASE statement  in the where clause?

    Hello Everyone,
    I have 2 queries that do what I need to do but I am trying to learn how to use the CASE statement.
    I have tried to combine these 2 into one query using a case statement but don't get the results I need.
    Could use some help on how to use the case syntax to get the results needed.
    thanks a lot
    select segment_name,
    product_type,
    count (distinct account_id)
    FROM NL_ACCT
    where
    ind = 'N'
    and
    EM_ind = 'N'
    and product_type in ('TAX','PAY')
    and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 60)
    GROUP BY 1,2
    order by product_type
    select segment_name,
    product_type,
    count (distinct account_id)
    FROM NL_ACCT
    where
    ind = 'N'
    and
    EM_ind = 'N'
    and product_type not in ('TAX','PAY')
    and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 30)
    group by 1,2
    order by product_type

    Something like:
    SELECT segment_name, product_type,
           SUM(CASE WHEN account_id IN ('TAX','PAY') and
                         acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
                               TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60 THEN 1
                    ELSE 0 END) tax_pay,
           SUM(CASE WHEN account_id NOT IN ('TAX','PAY') and
                         acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
                               TO_DATE('2006-01-17', 'yyyy-mm-dd') + 30 THEN 1
                    ELSE 0 END) not_tax_pay
    FROM NL_ACCT
    WHERE ind = 'N' and
          em_ind = 'N' and
          acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
                               TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60
    GROUP BY segment_name, product_type
    ORDER BY product_typeNote: You cannor GROUP BY 1,2, you need to explicitly name the columns to group by.
    HTH
    John

  • How to use a case ststement in interface?

    how to use a case statement in interface?
    My requirement is in interface for one column for
    Eg: In source column if a.b=c.d then i need to write as "Source"
    else when a.c=d.e then i need to write as "Target".
    please can you help in solving this.
    Regards,
    Sridhar

    You will literally write in the "Implemenation", the following:
    Case when a.b=c.d then "Source"
    Else
    "Target"
    End

  • CASE in a WHERE clause : ORA-00905

    Hi everyone,
    I am trying to use a CASE in a WHERE clause and I got the error ORA-00905: missing keyword. Here is my code :
    SELECT id_reserv,
         concat(nom,concat('_',indice)) as nom,
         libelle,
         num_lot,
         resa_keyword1,
         resa_keyword2,
         resa_keyword3,
         resa_keyword4,
         date_creation,
         comm_creation,
         id_util,
         actif,
         id_env_act,
         (SELECT login from utilisateur u where u.id_util=r.id_util) AS nom_util,
         (SELECT nom from environnement e where e.id_env=r.id_env_act) AS nom_env,
         (SELECT count(*) from reserv_comp rc where rc.id_reserv=r.id_reserv) AS nbComp,
         (SELECT count(*) from reserv_modif mc where mc.id_reserv=r.id_reserv) AS nbModif
    FROM reservation r
         WHERE r.nom NOT LIKE 'RESERV_LOT_%'
         AND id_util='1'
         AND actif='1'
         AND id_env_act>='-1'
         AND CASE sansdemande
         WHEN true THEN id_reserv not in select id_reserv from demande_livraison where id_env_dep>='-1'
         ELSE id_reserv=id_reserv
         END
         AND nom LIKE '%'
    ORDER BY date_creation;
    I already looked at the CASE statement and it seems that the syntax is correct, so I'm not sure I can use it in a WHERE clause.
    Any help would be nice !
    Guich

    Hi,
    it should be something like this:
    AND CASE
      WHEN 'false'='true' THEN (select id_reserv from demande_livraison where id_env_dep>='-1')
      ELSE id_reserv
         END = id_reserv The subquery should give one row back
    But I think it is better to write your query as:
    SELECT id_reserv,
         concat(nom,concat('_',indice)) as nom,
         libelle,
         num_lot,
         resa_keyword1,
         resa_keyword2,
         resa_keyword3,
         resa_keyword4,
         date_creation,
         comm_creation,
         id_util,
         actif,
         id_env_act,
         (SELECT login from utilisateur u where u.id_util=r.id_util) AS nom_util,
         (SELECT nom from environnement e where e.id_env=r.id_env_act) AS nom_env,
         (SELECT count(*) from reserv_comp rc where rc.id_reserv=r.id_reserv) AS nbComp,
         (SELECT count(*) from reserv_modif mc where mc.id_reserv=r.id_reserv) AS nbModif
    FROM reservation r
         WHERE r.nom NOT LIKE 'RESERV_LOT_%'
         AND id_util='1'
         AND actif='1'
         AND id_env_act>='-1'
         AND
                          (  'false'='true' and id_reserv not in (select id_reserv from demande_livraison where id_env_dep>='-1')
                          or
                          ( 'true'= 'true' and id_reserv=id_reserv
         AND nom LIKE '%'
    ORDER BY date_creation;This coding in SQL something as if a=b then c, else d in the simplest form.
    Herald ten Dam
    http://htendam.wordpress.com

  • How to use CASE stmt in Where clause

    Hi,
    How to use CASE stmt in WHERE clause?. I need the code. Please send me as early as possible..........

    Hi,
    1004977 wrote:
    Hi,
    How to use CASE stmt in WHERE clause?. There's no difference between how a CASE expression is used in a WHERE clause, and how it is used in any other clause. CASE ... END always returns a single scalar value, and it can be used almost anywere a single scalar expression (such as a column, a literal, a single-row function, a + operation, ...) can be used.
    CASE expressions aren't needed in WHERE clauses very much. The reason CASE expressions are so useful is that they allow you to do IF-THEN-ELSE logic anywhere in SQL. The WHERE clause already allows you to do IF-THEN-ELSE logic, usually in a more convenient way.
    I need the code.So do the peple who want t help you. Post a query where you'd like to use a CASE expression in the WHERE clause. Post CREATE TABLE and INSERT statements for any tables used unless they are commonly available, such as scott.emp). Also, post the results you want from that sample data, and explain how you get those resuts from that data.
    See the forum FAQ {message:id=9360002}
    Please send me as early as possible..........As mentioned bfore, that's rude. It's also self-defeating. Nobody will refuse to help you because you don't appear pushy enough, but some people will refuse to help you if you appear too pushy.

  • Using :case when  in where clause

    Hello,
    I need some help with using of case statement in a where clause
    Table that contains info about employees taking some coursework:
    Class (values could be SAP, ORACLE, JAVA)
    Code (if Class is SAP then CODE is not null; if class is any other CODE is NULL)
    Start Date (date they began class not null)
    End Date (date then ended the class - could be null)
    Employee Level(numbers from one through five)
    I need a single LOV in forms that should show Employee_Level for input class,code,date.
    How to do this?
    I started off with this but get 'missing statement error'
    select distinct employee_level from e_course
       where (
       case when &class='SAP' then code ='1' and start_date > to_date('20000101','YYYYMMDD') and
                                               end_date < to_date('20000101','YYYYMMDD')
               else
                   null
       end) order by employee_level;Thanks

    Hi,
    user469956 wrote:
    But all these examples have only one condition for each case.Depending on how you count, all WHERE clauses have only one condition.
    I see an example in that thread that has 6 atomic conditions, linked by AND and OR.
    I need to check date & code. This is what is causing the error.Why do you want to use a CASE statement?
    Why can't you put all your conditions directly iinto a WHERE clause, soemthing like this:
    WHERE   (   &class='SAP'
            AND code ='1'
    OR      (   start_date  > to_date('20000101','YYYYMMDD')
            AND end_date    < to_date('20000101','YYYYMMDD')
            )I said "something like this" because I don't know what you really want to do.

  • I have 6 radio buttons.i want to use a case statement to read them.

    i have 6 radio buttons.i grouped them.i want to read them in a subroutine using a case statement.how can i read them

    Hi Leela,
    You cannot use the Case statement to read the radio buttons.
    nstead you will have to use Loop at Screen under At Selection Screen Output.
    Please refer to the below code or the reference:
    *& Report  ZHYPERION                                                   *
    *& Project : SubSea7
    Created on : 07/02/2007
    Created by : Puneet Jhari.
    *& Purpose : For SAP Interface download Hyperion.
    REPORT  zhyperion NO STANDARD PAGE HEADING  MESSAGE-ID zhyper.
    Start of Data Declaration
    TYPE-POOLS : truxs,vrm.
    TABLES : glpct,cepc.
    DATA : var TYPE i,
            total TYPE f.
    DATA : BEGIN OF wa2,
           ryear LIKE glpct-ryear,
           rbukrs LIKE glpct-rbukrs,
           racct LIKE glpct-racct,
           ksl01 LIKE glpct-ksl01,
           END OF wa2.
    DATA : BEGIN OF wa3,
           ryear LIKE glpct-ryear,
           rbukrs LIKE glpct-rbukrs,
           racct LIKE glpct-racct,
           ksl01 LIKE glpct-ksl01,
           END OF wa3.
    DATA : BEGIN OF wa4,
           racct LIKE glpct-racct,
           END OF wa4.
    DATA : BEGIN OF wa5,
           rbukrs LIKE glpct-rbukrs,
           racct LIKE glpct-racct,
           total1(8) TYPE p DECIMALS 2,
           END OF wa5.
    DATA : BEGIN OF wa9,
           khinr LIKE cepc-khinr,
           racct LIKE glpct-racct,
           total1(8) TYPE p DECIMALS 2,
           END OF wa9.
    DATA : BEGIN OF wa6,
           khinr LIKE cepc-khinr,
           prctr LIKE cepc-prctr,
           rprctr LIKE glpct-rprctr,
           ryear LIKE glpct-ryear,
           rbukrs LIKE glpct-rbukrs,
           racct LIKE glpct-racct,
           ksl01 LIKE glpct-ksl01,
           END OF wa6.
    DATA : BEGIN OF wa7,
           khinr LIKE cepc-khinr,
           prctr LIKE cepc-prctr,
           rprctr LIKE glpct-rprctr,
           ryear LIKE glpct-ryear,
           rbukrs LIKE glpct-rbukrs,
           racct LIKE glpct-racct,
           ksl01 LIKE glpct-ksl01,
           END OF wa7.
    DATA : itab3 LIKE TABLE OF wa2,
           itab4 LIKE TABLE OF wa3,
           itab5 LIKE TABLE OF wa4 WITH HEADER LINE,
           itab6 LIKE TABLE OF wa5 WITH HEADER LINE,
           itab7 LIKE TABLE OF wa6,
           itab8 LIKE TABLE OF wa7,
           itab10 LIKE TABLE OF wa9.
    DATA : flag(1) TYPE c,
           temp(6) TYPE c.
    DATA : itab2 TYPE truxs_t_text_data,
           itab9 TYPE truxs_t_text_data WITH HEADER LINE.
    DATA : name TYPE vrm_id,
           list TYPE vrm_values,
           value LIKE LINE OF list,
           FILNAM11 TYPE STRING,
           FILNAM21 TYPE STRING.
    End of Data Declaration
    Begin of Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: r1 DEFAULT 'X' RADIOBUTTON GROUP g1 USER-COMMAND rad1,
    r2 RADIOBUTTON GROUP g1 .
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-005.
    PARAMETERS: rbukrs1 TYPE glpct-rbukrs MODIF ID ful,
                khinr1 TYPE cepc-khinr AS LISTBOX VISIBLE LENGTH 20
                MODIF ID sam ,
                ryear1 TYPE glpct-ryear MODIF ID ful,
                ryear2 TYPE glpct-ryear MODIF ID sam,
                rpmax1 TYPE i MODIF ID ful,
                rpmax2 TYPE i MODIF ID sam,
                filnam1 TYPE rlgrap-filename MODIF ID ful,
                filnam2 TYPE RLGRAP-FILENAME MODIF ID sam.
    SELECTION-SCREEN END OF BLOCK b3.
    End of Selection Screen
    AT SELECTION-SCREEN OUTPUT
    AT SELECTION-SCREEN OUTPUT.
    PERFORM populate.          "For populating the drop-down list.
    CLEAR VALUE.
    REFRESH LIST.
    NAME = 'KHINR1'.
    VALUE-KEY = '1S7_NOCASV'.
    VALUE-TEXT = '1S7_NOCASV'.
    APPEND VALUE TO LIST.
    VALUE-KEY = '1S7_NOCJOT'.
    VALUE-TEXT = '1S7_NOCJOT'.
    APPEND VALUE TO LIST.
    LOOP AT SCREEN.            "For toggling between the selection screens.
        IF r1 EQ 'X'.
          IF screen-group1 = 'SAM'.
            screen-active = 0.
          ENDIF.
        ELSEIF r2 EQ 'X'.
          IF screen-group1 = 'FUL'.
            screen-active = 0.
          ENDIF.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    For the Drop-Down Listbox
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id                    = name
          values                = list
    EXCEPTIONS
      ID_ILLEGAL_NAME       = 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.
    Begin of Data Selection
    START-OF-SELECTION.
    When Company Code radio button is selected.
      IF r1 EQ 'X'.            "If Company Code radio button is selected.
        IF rbukrs1 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF rpmax1 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF ryear1 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF filnam1 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
    MOVE FILNAM1 TO FILNAM11.
        CASE rpmax1.
          WHEN '01'.
            SELECT ryear rbukrs racct ksl01
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '02'.
            SELECT ryear rbukrs racct ksl02
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '03'.
            SELECT ryear rbukrs racct ksl03
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '04'.
            SELECT ryear rbukrs racct ksl04
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '05'.
            SELECT ryear rbukrs racct ksl05
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '06'.
            SELECT ryear rbukrs racct ksl06
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '07'.
            SELECT ryear rbukrs racct ksl07
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '08'.
            SELECT ryear rbukrs racct ksl08
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '09'.
            SELECT ryear rbukrs racct ksl09
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '10'.
            SELECT ryear rbukrs racct ksl10
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '11'.
            SELECT ryear rbukrs racct ksl11
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '12'.
            SELECT ryear rbukrs racct ksl12
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '13'.
            SELECT ryear rbukrs racct ksl13
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '14'.
            SELECT ryear rbukrs racct ksl14
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '15'.
            SELECT ryear rbukrs racct ksl15
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
          WHEN '16'.
            SELECT ryear rbukrs racct ksl16
    FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
        ENDCASE.
        MOVE itab3 TO itab4.
        LOOP AT itab3 INTO wa2.
          flag = 0.
          LOOP AT itab5 INTO wa4.
            IF wa2-racct EQ wa4-racct.
              flag = 1.
              EXIT.
            ENDIF.
          ENDLOOP.
          DELETE ADJACENT DUPLICATES FROM itab5.
          IF flag = 1.
            CONTINUE.
          ENDIF.
          LOOP AT itab4 INTO wa3.
            IF wa2-rbukrs EQ wa3-rbukrs AND wa2-racct EQ wa3-racct AND
            wa2-ryear EQ wa3-ryear.
              total = total + wa3-ksl01.
            ENDIF.
          ENDLOOP.
          wa5-rbukrs = wa2-rbukrs.
          wa5-racct = wa2-racct+4(6).
          wa5-total1 = total.
          APPEND wa5 TO itab6.
          CLEAR total.
          APPEND wa2-racct TO itab5.
        ENDLOOP.
    If no data is available corresponding to the values entered.
        IF itab6[] IS INITIAL.
          MESSAGE i003.
        ENDIF.
    For making the file Comma separated
        CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
          EXPORTING
            i_field_seperator          = ','
    I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
          TABLES
            i_tab_sap_data             = itab6
         CHANGING
           i_tab_converted_data       = itab2
    EXCEPTIONS
      CONVERSION_FAILED          = 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.
    For downloading it to the Presentation Server
       MOVE itab2[] TO itab9[].
       OPEN DATASET filnam1 FOR OUTPUT IN LEGACY TEXT MODE.
       LOOP AT itab9.
         TRANSFER itab9 TO filnam1.
       ENDLOOP.
       CLOSE DATASET filnam1.
       IF sy-subrc EQ 0.
         MESSAGE s004.
       ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        filename                        = FILNAM11
      FILETYPE                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = itab2
      FIELDNAMES                      =
    EXCEPTIONS
      FILE_WRITE_ERROR                = 1
      NO_BATCH                        = 2
      GUI_REFUSE_FILETRANSFER         = 3
      INVALID_TYPE                    = 4
      NO_AUTHORITY                    = 5
      UNKNOWN_ERROR                   = 6
      HEADER_NOT_ALLOWED              = 7
      SEPARATOR_NOT_ALLOWED           = 8
      FILESIZE_NOT_ALLOWED            = 9
      HEADER_TOO_LONG                 = 10
      DP_ERROR_CREATE                 = 11
      DP_ERROR_SEND                   = 12
      DP_ERROR_WRITE                  = 13
      UNKNOWN_DP_ERROR                = 14
      ACCESS_DENIED                   = 15
      DP_OUT_OF_MEMORY                = 16
      DISK_FULL                       = 17
      DP_TIMEOUT                      = 18
      FILE_NOT_FOUND                  = 19
      DATAPROVIDER_EXCEPTION          = 20
      CONTROL_FLUSH_ERROR             = 21
      OTHERS                          = 22
    IF sy-subrc eq 0.
    message s004.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    When Region radio button is selected.
      ELSEIF r2 EQ 'X'.
        IF khinr1 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF rpmax2 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF ryear2 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF filnam2 IS INITIAL.
          MESSAGE i002.
          LEAVE TO SCREEN 1000.
        ENDIF.
    MOVE FILNAM2 TO FILNAM21.
        CASE rpmax2.
          WHEN '01'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl01
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '02'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl02
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '03'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl03
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '04'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl04
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '05'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl05
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '06'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl06
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '07'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl07
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '08'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl08
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '09'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl09
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '10'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl10
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '11'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl11
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '12'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl12
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '13'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl13
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '14'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl14
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '15'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl15
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
          WHEN '16'.
           SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl16
           INTO CORRESPONDING FIELDS OF TABLE itab7
           FROM (  glpct AS g
                   INNER JOIN cepc AS c ON grprctr = cprctr )
           WHERE c~khinr = khinr1 AND
                 g~ryear = ryear2.
        ENDCASE.
        MOVE itab7 TO itab8.
        LOOP AT itab7 INTO wa6.
          flag = 0.
          LOOP AT itab5 INTO wa4.
            IF wa6-racct EQ wa4-racct.
              flag = 1.
              EXIT.
            ENDIF.
          ENDLOOP.
          DELETE ADJACENT DUPLICATES FROM itab5.
          IF flag = 1.
            CONTINUE.
          ENDIF.
          LOOP AT itab8 INTO wa7.
            IF wa6-rbukrs EQ wa7-rbukrs AND wa6-racct EQ wa7-racct AND
            wa6-ryear EQ wa7-ryear.
              total = total + wa7-ksl01.
            ENDIF.
          ENDLOOP.
          wa9-khinr = khinr1.
          wa9-racct = wa6-racct+4(6).
          wa9-total1 = total.
          APPEND wa9 TO itab10.
          CLEAR total.
          APPEND wa6-racct TO itab5.
        ENDLOOP.
    *If no data is available corresponding to the values entered.
        IF itab10 IS INITIAL.
          MESSAGE i003.
        ENDIF.
    For making the file Comma separated
        CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
          EXPORTING
            i_field_seperator          = ','
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
          TABLES
            i_tab_sap_data             = itab10
         CHANGING
           i_tab_converted_data       = itab2
    EXCEPTIONS
      CONVERSION_FAILED          = 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.
    For downloading it to the Presentation Server
       MOVE itab2[] TO itab9[].
       OPEN DATASET filnam2 FOR OUTPUT IN LEGACY TEXT MODE.
       LOOP AT itab9.
         TRANSFER itab9 TO filnam2.
       ENDLOOP.
       CLOSE DATASET filnam2.
       IF sy-subrc EQ 0.
         MESSAGE s004.
       ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        filename                        = FILNAM21
      FILETYPE                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = itab2
      FIELDNAMES                      =
    EXCEPTIONS
      FILE_WRITE_ERROR                = 1
      NO_BATCH                        = 2
      GUI_REFUSE_FILETRANSFER         = 3
      INVALID_TYPE                    = 4
      NO_AUTHORITY                    = 5
      UNKNOWN_ERROR                   = 6
      HEADER_NOT_ALLOWED              = 7
      SEPARATOR_NOT_ALLOWED           = 8
      FILESIZE_NOT_ALLOWED            = 9
      HEADER_TOO_LONG                 = 10
      DP_ERROR_CREATE                 = 11
      DP_ERROR_SEND                   = 12
      DP_ERROR_WRITE                  = 13
      UNKNOWN_DP_ERROR                = 14
      ACCESS_DENIED                   = 15
      DP_OUT_OF_MEMORY                = 16
      DISK_FULL                       = 17
      DP_TIMEOUT                      = 18
      FILE_NOT_FOUND                  = 19
      DATAPROVIDER_EXCEPTION          = 20
      CONTROL_FLUSH_ERROR             = 21
      OTHERS                          = 22
    IF sy-subrc eq 0.
    message s004.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      ENDIF.
    *&      Form  POPULATE
          text
    FORM populate.
      CLEAR value.
      REFRESH list.
      name = 'KHINR1'.
      value-key = '1S7_SUBSEA'.
      value-text = '1S7_SUBSEA'.
      APPEND value TO list.
      value-key = '1S7_GEN'.
      value-text = '1S7_GEN'.
      APPEND value TO list.
      value-key = '1S7'.
      value-text = '1S7'.
      APPEND value TO list.
      value-key = '1S7_CORPTP'.
      value-text = '1S7_CORPTP'.
      APPEND value TO list.
      value-key = '1S7_BRRE'.
      value-text = '1S7_BRRE'.
      APPEND value TO list.
      value-key = '1S7_BRCON'.
      value-text = '1S7_BRCON'.
      APPEND value TO list.
      value-key = '1S7_BRCJOB'.
      value-text = '1S7_BRCJOB'.
      APPEND value TO list.
      value-key = '1S7_BRCJBU'.
      value-text = '1S7_BRCJBU'.
      APPEND value TO list.
      value-key = '1S7_BRCJCO'.
      value-text = '1S7_BRCJCO'.
      APPEND value TO list.
      value-key = '1S7_BRCJIR'.
      value-text = '1S7_BRCJIR'.
      APPEND value TO list.
      value-key = '1S7_BRCJEN'.
      value-text = '1S7_BRCJEN'.
      APPEND value TO list.
      value-key = '1S7_BRCJPI'.
      value-text = '1S7_BRCJPI'.
      APPEND value TO list.
      value-key = '1S7_BRCJSU'.
      value-text = '1S7_BRCJSU'.
      APPEND value TO list.
      value-key = '1S7_BRCJFL'.
      value-text = '1S7_BRCJFL'.
      APPEND value TO list.
      value-key = '1S7_BRCJOT'.
      value-text = '1S7_BRCJOT'.
      APPEND value TO list.
      value-key = '1S7_BRCASV'.
      value-text = '1S7_BRCASV'.
      APPEND value TO list.
      value-key = '1S7_BRCASE'.
      value-text = '1S7_BRCASE'.
      APPEND value TO list.
      value-key = '1S7_BRCOOC'.
      value-text = '1S7_BRCOOC'.
      APPEND value TO list.
      value-key = '1S7_BRCOHD'.
      value-text = '1S7_BRCOHD'.
      APPEND value TO list.
      value-key = '1S7_BRCGEN'.
      value-text = '1S7_BRCGEN'.
      APPEND value TO list.
      value-key = '1S7_BRDRI'.
      value-text = '1S7_BRDRI'.
      APPEND value TO list.
      value-key = '1S7_BRDJOB'.
      value-text = '1S7_BRDJOB'.
      APPEND value TO list.
      value-key = '1S7_BRDASV'.
      value-text = '1S7_BRDASV'.
      APPEND value TO list.
      value-key = '1S7_BRDASE'.
      value-text = '1S7_BRDASE'.
      APPEND value TO list.
      value-key = '1S7_BRDAEW'.
      value-text = '1S7_BRDAEW'.
      APPEND value TO list.
      value-key = '1S7_BRDAEO'.
      value-text = '1S7_BRDAEO'.
      APPEND value TO list.
      value-key = '1S7_BRDAET'.
      value-text = '1S7_BRDAET'.
      APPEND value TO list.
      value-key = '1S7_BRDOOC'.
      value-text = '1S7_BRDOOC'.
      APPEND value TO list.
      value-key = '1S7_BRDOHD'.
      value-text = '1S7_BRDOHD'.
      APPEND value TO list.
      value-key = '1S7_BRVER'.
      value-text = '1S7_BRVER'.
      APPEND value TO list.
      value-key = '1S7_BRVJOB'.
      value-text = '1S7_BRVJOB'.
      APPEND value TO list.
      value-key = '1S7_BRVASV'.
      value-text = '1S7_BRVASV'.
      APPEND value TO list.
      value-key = '1S7_BRVASE'.
      value-text = '1S7_BRVASE'.
      APPEND value TO list.
      value-key = '1S7_BRVOOC'.
      value-text = '1S7_BRVOOC'.
      APPEND value TO list.
      value-key = '1S7_BRVOHD'.
      value-text = '1S7_BRVOHD'.
      APPEND value TO list.
      value-key = '1S7_UKRE'.
      value-text = '1S7_UKRE'.
      APPEND value TO list.
      value-key = '1S7_UKCON'.
      value-text = '1S7_UKCON'.
      APPEND value TO list.
      value-key = '1S7_UKCJOB'.
      value-text = '1S7_UKCJOB'.
      APPEND value TO list.
      value-key = '1S7_UKCJBU'.
      value-text = '1S7_UKCJBU'.
      APPEND value TO list.
      value-key = '1S7_UKCJCO'.
      value-text = '1S7_UKCJCO'.
      APPEND value TO list.
      value-key = '1S7_UKCJIR'.
      value-text = '1S7_UKCJIR'.
      APPEND value TO list.
      value-key = '1S7_UKCJEN'.
      value-text = '1S7_UKCJEN'.
      APPEND value TO list.
      value-key = '1S7_UKCJPI'.
      value-text = '1S7_UKCJPI'.
      APPEND value TO list.
      value-key = '1S7_UKCJSU'.
      value-text = '1S7_UKCJSU'.
      APPEND value TO list.
      value-key = '1S7_UKCJFL'.
      value-text = '1S7_UKCJFL'.
      APPEND value TO list.
      value-key = '1S7_UKCJOT'.
      value-text = '1S7_UKCJOT'.
      APPEND value TO list.
      value-key = '1S7_UKCASV'.
      value-text = '1S7_UKCASV'.
      APPEND value TO list.
      value-key = '1S7_UKCASE'.
      value-text = '1S7_UKCASE'.
      APPEND value TO list.
      value-key = '1S7_UKCOOC'.
      value-text = '1S7_UKCOOC'.
      APPEND value TO list.
      value-key = '1S7_UKBA'.
      value-text = '1S7_UKBA'.
      APPEND value TO list.
      value-key = '1S7_UKBATE'.
      value-text = '1S7_UKBATE'.
      APPEND value TO list.
      value-key = '1S7_UKCOHD'.
      value-text = '1S7_UKCOHD'.
      APPEND value TO list.
      value-key = '1S7_UKCGEN'.
      value-text = '1S7_UKCGEN'.
      APPEND value TO list.
      value-key = '1S7_UKDRI'.
      value-text = '1S7_UKDRI'.
      APPEND value TO list.
      value-key = '1S7_UKDJOB'.
      value-text = '1S7_UKDJOB'.
      APPEND value TO list.
      value-key = '1S7_UKDASV'.
      value-text = '1S7_UKDASV'.
      APPEND value TO list.
      value-key = '1S7_UKDASE'.
      value-text = '1S7_UKDASE'.
      APPEND value TO list.
      value-key = '1S7_UKDAEW'.
      value-text = '1S7_UKDAEW'.
      APPEND value TO list.
      value-key = '1S7_UKDAEO'.
      value-text = '1S7_UKDAEO'.
      APPEND value TO list.
      value-key = '1S7_UKDAET'.
      value-text = '1S7_UKDAET'.
      APPEND value TO list.
      value-key = '1S7_UKDOOC'.
      value-text = '1S7_UKDOOC'.
      APPEND value TO list.
      value-key = '1S7_UKDOHD'.
      value-text = '1S7_UKDOHD'.
      APPEND value TO list.
      value-key = '1S7_UKVER'.
      value-text = '1S7_UKVER'.
      APPEND value TO list.
      value-key = '1S7_UKVJOB'.
      value-text = '1S7_UKVJOB'.
      APPEND value TO list.
      value-key = '1S7_UKVASV'.
      value-text = '1S7_UKVASV'.
      APPEND value TO list.
      value-key = '1S7_UKVASE'.
      value-text = '1S7_UKVASE'.
      APPEND value TO list.
      value-key = '1S7_UKVOOC'.
      value-text = '1S7_UKVOOC'.
      APPEND value TO list.
      value-key = '1S7_UKVOHD'.
      value-text = '1S7_UKVOHD'.
      APPEND value TO list.
      value-key = '1S7_NORE'.
      value-text = '1S7_NORE'.
      APPEND value TO list.
      value-key = '1S7_NOCON'.
      value-text = '1S7_NOCON'.
      APPEND value TO list.
      value-key = '1S7_NOCJOB'.
      value-text = '1S7_NOCJOB'.
      APPEND value TO list.
      value-key = '1S7_NOCJBU'.
      value-text = '1S7_NOCJBU'.
      APPEND value TO list.
      value-key = '1S7_NOCJCO'.
      value-text = '1S7_NOCJCO'.
      APPEND value TO list.
      value-key = '1S7_NOCJIR'.
      value-text = '1S7_NOCJIR'.
      APPEND value TO list.
      value-key = '1S7_NOCJEN'.
      value-text = '1S7_NOCJEN'.
      APPEND value TO list.
      value-key = '1S7_NOCJPI'.
      value-text = '1S7_NOCJPI'.
      APPEND value TO list.
      value-key = '1S7_NOCJSU'.
      value-text = '1S7_NOCJSU'.
      APPEND value TO list.
      value-key = '1S7_NOCJFL'.
      value-text = '1S7_NOCJFL'.
      APPEND value TO list.
      value-key = '1S7_NOCJOT'.
      value-text = '1S7_NOCJOT'.
      APPEND value TO list.
      value-key = '1S7_NOCASV'.
      value-text = '1S7_NOCASV'.
      APPEND value TO list.
      value-key = '1S7_NOCASE'.
      value-text = '1S7_NOCASE'.
      APPEND value TO list.
      value-key = '1S7_NOCOOC'.
      value-text = '1S7_NOCOOC'.
      APPEND value TO list.
      value-key = '1S7_NOCOHD'.
      value-text = '1S7_NOCOHD'.
      APPEND value TO list.
      value-key = '1S7_NOCGEN'.
      value-text = '1S7_NOCGEN'.
      APPEND value TO list.
      value-key = '1S7_NODRI'.
      value-text = '1S7_NODRI'.
      APPEND value TO list.
      value-key = '1S7_NODJOB'.
      value-text = '1S7_NODJOB'.
      APPEND value TO list.
      value-key = '1S7_NODASV'.
      value-text = '1S7_NODASV'.
      APPEND value TO list.
      value-key = '1S7_NODASE'.
      value-text = '1S7_NODASE'.
      APPEND value TO list.
      value-key = '1S7_NODAEW'.
      value-text = '1S7_NODAEW'.
      APPEND value TO list.
      value-key = '1S7_NODAEO'.
      value-text = '1S7_NODAEO'.
      APPEND value TO list.
      value-key = '1S7_NODAET'.
      value-text = '1S7_NODAET'.
      APPEND value TO list.
      value-key = '1S7_NODOOC'.
      value-text = '1S7_NODOOC'.
      APPEND value TO list.
      value-key = '1S7_NODOHD'.
      value-text = '1S7_NODOHD'.
      APPEND value TO list.
      value-key = '1S7_NOVER'.
      value-text = '1S7_NOVER'.
      APPEND value TO list.
      value-key = '1S7_NOVJOB'.
      value-text = '1S7_NOVJOB'.
      APPEND value TO list.
      value-key = '1S7_NOVASV'.
      value-text = '1S7_NOVASV'.
      APPEND value TO list.
      value-key = '1S7_NOVASE'.
      value-text = '1S7_NOVASE'.
      APPEND value TO list.
      value-key = '1S7_NOVOOC'.
      value-text = '1S7_NOVOOC'.
      APPEND value TO list.
      value-key = '1S7_NOVOHD'.
      value-text = '1S7_NOVOHD'.
      APPEND value TO list.
      value-key = '1S7_GORE'.
      value-text = '1S7_GORE'.
      APPEND value TO list.
      value-key = '1S7_GOCON'.
      value-text = '1S7_GOCON'.
      APPEND value TO list.
      value-key = '1S7_GOCJOB'.
      value-text = '1S7_GOCJOB'.
      APPEND value TO list.
      value-key = '1S7_GOCJBU'.
      value-text = '1S7_GOCJBU'.
      APPEND value TO list.
      value-key = '1S7_GOCJCO'.
      value-text = '1S7_GOCJCO'.
      APPEND value TO list.
      value-key = '1S7_GOCJIR'.
      value-text = '1S7_GOCJIR'.
      APPEND value TO list.
      value-key = '1S7_GOCJEN'.
      value-text = '1S7_GOCJEN'.
      APPEND value TO list.
      value-key = '1S7_GOCJPI'.
      value-text = '1S7_GOCJPI'.
      APPEND value TO list.
      value-key = '1S7_GOCJSU'.
      value-text = '1S7_GOCJSU'.
      APPEND value TO list.
      value-key = '1S7_GOCJFL'.
      value-text = '1S7_GOCJFL'.
      APPEND value TO list.
      value-key = '1S7_GOCJOT'.
      value-text = '1S7_GOCJOT'.
      APPEND value TO list.
      value-key = '1S7_GOCASV'.
      value-text = '1S7_GOCASV'.
      APPEND value TO list.
      value-key = '1S7_GOCASE'.
      value-text = '1S7_GOCASE'.
      APPEND value TO list.
      value-key = '1S7_GOCOOC'.
      value-text = '1S7_GOCOOC'.
      APPEND value TO list.
      value-key = '1S7_GOCOHD'.
      value-text = '1S7_GOCOHD'.
      APPEND value TO list.
      value-key = '1S7_GOCGEN'.
      value-text = '1S7_GOCGEN'.
      APPEND value TO list.
      value-key = '1S7_GODRI'.
      value-text = '1S7_GODRI'.
      APPEND value TO list.
      value-key = '1S7_GODJOB'.
      value-text = '1S7_GODJOB'.
      APPEND value TO list.
      value-key = '1S7_GODASV'.
      value-text = '1S7_GODASV'.
      APPEND value TO list.
      value-key = '1S7_GODASE'.
      value-text = '1S7_GODASE'.
      APPEND value TO list.
      value-key = '1S7_GODAEW'.
      value-text = '1S7_GODAEW'.
      APPEND value TO list.
      value-key = '1S7_GODAEO'.
      value-text = '1S7_GODAEO'.
      APPEND value TO list.
      value-key = '1S7_GODAET'.
      value-text = '1S7_GODAET'.
      APPEND value TO list.
      value-key = '1S7_GODOOC'.
      value-text = '1S7_GODOOC'.
      APPEND value TO list.
      value-key = '1S7_GODOHD'.
      value-text = '1S7_GODOHD'.
      APPEND value TO list.
      value-key = '1S7_GOVER'.
      value-text = '1S7_GOVER'.
      APPEND value TO list.
      value-key = '1S7_GOVJOB'.
      value-text = '1S7_GOVJOB'.
      APPEND value TO list.
      value-key = '1S7_GOVASV'.
      value-text = '1S7_GOVASV'.
      APPEND value TO list.
      value-key = '1S7_GOVASE'.
      value-text = '1S7_GOVASE'.
      APPEND value TO list.
      value-key = '1S7_GOVOOC'.
      value-text = '1S7_GOVOOC'.
      APPEND value TO list.
      value-key = '1S7_GOVOHD'.
      value-text = '1S7_GOVOHD'.
      APPEND value TO list.
      value-key = '1S7_GVRE'.
      value-text = '1S7_GVRE'.
      APPEND value TO list.
      value-key = '1S7_GVCON'.
      value-text = '1S7_GVCON'.
      APPEND value TO list.
      value-key = '1S7_GVCJOB'.
      value-text = '1S7_GVCJOB'.
      APPEND value TO list.
      value-key = '1S7_GVCJBU'.
      value-text = '1S7_GVCJBU'.
      APPEND value TO list.
      value-key = '1S7_GVCJCO'.
      value-text = '1S7_GVCJCO'.
      APPEND value TO list.
      value-key = '1S7_GVCJIR'.
      value-text = '1S7_GVCJIR'.
      APPEND value TO list.
      value-key = '1S7_GVCJEN'.
      value-text = '1S7_GVCJEN'.
      APPEND value TO list.
      value-key = '1S7_GVCJPI'.
      value-text = '1S7_GVCJPI'.
      APPEND value TO list.
      value-key = '1S7_GVCJSU'.
      value-text = '1S7_GVCJSU'.
      APPEND value TO list.
      value-key = '1S7_GVCJFL'.
      value-text = '1S7_GVCJFL'.
      APPEND value TO list.
      value-key = '1S7_GVCJOT'.
      value-text = '1S7_GVCJOT'.
      APPEND value TO list.
      value-key = '1S7_GVCASV'.
      value-text = '1S7_GVCASV'.
      APPEND value TO list.
      value-key = '1S7_GVCASE'.
      value-text = '1S7_GVCASE'.
      APPEND value TO list.
      value-key = '1S7_GVCOOC'.
      value-text = '1S7_GVCOOC'.
      APPEND value TO list.
      value-key = '1S7_GVCOHD'.
      value-text = '1S7_GVCOHD'.
      APPEND value TO list.
      value-key = '1S7_GVCGEN'.
      value-text = '1S7_GVCGEN'.
      APPEND value TO list.
      value-key = '1S7_GVDRI'.
      value-text = '1S7_GVDRI'.
      APPEND value TO list.
      value-key = '1S7_GVDJOB'.
      value-text = '1S7_GVDJOB'.
      APPEND value TO list.
      value-key = '1S7_GVDASV'.
      value-text = '1S7_GVDASV'.
      APPEND value TO list.
      value-key = '1S7_GVDASE'.
      value-text = '1S7_GVDASE'.
      APPEND value TO list.
      value-key = '1S7_GVDOOC'.
      value-text = '1S7_GVDOOC'.
      APPEND value TO list.
      value-key = '1S7_GVDOHD'.
      value-text = '1S7_GVDOHD'.
      APPEND value TO list.
      value-key = '1S7_GVVER'.
      value-text = '1S7_GVVER'.
      APPEND value TO list.
      value-key = '1S7_GVVJOB'.
      value-text = '1S7_GVVJOB'.
      APPEND value TO list.
      value-key = '1S7_GVVASV'.
      value-text = '1S7_GVVASV'.
      APPEND value TO list.
      value-key = '1S7_GVVASE'.
      value-text = '1S7_GVVASE'.
      APPEND value TO list.
      value-key = '1S7_GVVOOC'.
      value-text = '1S7_GVVOOC'.
      APPEND value TO list.
      value-key = '1S7_GVVOHD'.
      value-text = '1S7_GVVOHD'.
      APPEND value TO list.
      value-key = '1S7_GCRE'.
      value-text = '1S7_GCRE'.
      APPEND value TO list.
      value-key = '1S7_GCCON'.
      value-text = '1S7_GCCON'.
      APPEND value TO list.
      value-key = '1S7_GCCJOB'.
      value-text = '1S7_GCCJOB'.
      APPEND value TO list.
      value-key = '1S7_GCCJBU'.
      value-text = '1S7_GCCJBU'.
      APPEND value TO list.
      value-key = '1S7_GCCJCO'.
      value-text = '1S7_GCCJCO'.
      APPEND value TO list.
      value-key = '1S7_GCCJIR'.
      value-text = '1S7_GCCJIR'.
      APPEND value TO list.
      value-key = '1S7_GCCJEN'.
      value-text = '1S7_GCCJEN'.
      APPEND value TO list.
      value-key = '1S7_GCCJPI'.
      value-text = '1S7_GCCJPI'.
      APPEND value TO list.
      value-key = '1S7_GCCJSU'.
      value-text = '1S7_GCCJSU'.
      APPEND value TO list.
      value-key = '1S7_GCCJFL'.
      value-text = '1S7_GCCJFL'.
      APPEND value TO list.
      value-key = '1S7_GCCJOT'.
      value-text = '1S7_GCCJOT'.
      APPEND value TO list.
      value-key = '1S7_GCCASV'.
      value-text = '1S7_GCCASV'.
      APPEND value TO list.
      value-key = '1S7_GCCASE'.
      value-text = '1S7_GCCASE'.
      APPEND value TO list.
      value-key = '1S7_GCCOOC'.
      value-text = '1S7_GCCOOC'.
      APPEND value TO list.
      value-key = '1S7_GCCOHD'.
      value-text = '1S7_GCCOHD'.
      APPEND value TO list.
      value-key = '1S7_GCCRD'.
      value-text = '1S7_GCCRD'.
      APPEND value TO list.
      value-key = '1S7_GCCGEN'.
      value-text = '1S7_GCCGEN'.
      APPEND value TO list.
      value-key = '1S7_GCDRI'.
      value-text = '1S7_GCDRI'.
      APPEND value TO list.
      value-key = '1S7_GCDJOB'.
      value-text = '1S7_GCDJOB'.
      APPEND value TO list.
      value-key = '1S7_GCDASV'.
      value-text = '1S7_GCDASV'.
      APPEND value TO list.
      value-key = '1S7_GCDASE'.
      value-text = '1S7_GCDASE'.
      APPEND value TO list.
      value-key = '1S7_GCDOOC'.
      value-text = '1S7_GCDOOC'.
      APPEND value TO list.
      value-key = '1S7_GCDOHD'.
      value-text = '1S7_GCDOHD'.
      APPEND value TO list.
      value-key = '1S7_GCVER'.
      value-text = '1S7_GCVER'.
      APPEND value TO list.
      value-key = '1S7_GCVJOB'.
      value-text = '1S7_GCVJOB'.
      APPEND value TO list.
      value-key = '1S7_GCVASV'.
      value-text = '1S7_GCVASV'.
      APPEND value TO list.
      value-key = '1S7_GCVASE'.
      value-text = '1S7_GCVASE'.
      APPEND value TO list.
      value-key = '1S7_GCVOOC'.
      value-text = '1S7_GCVOOC'.
      APPEND value TO list.
      value-key = '1S7_GCVOHD'.

  • How to use an if statement in javascript code

    Hello,
    I have a batch processing script to search for text "employee signature" on each page in a multiple page file and to then list in the console any pages that do not have the "Employee Signature" text included.
    The script is not yet functional as an if statement needs to be included.
    Can anyone please advise how to use an if statement in javascript code?
    var numpages = this.numPages;
    for (var i=0; i < numpages; i++)
    search.query("Employee Signature", "ActiveDoc");
    console.println('Pages that do not include an employee signature: ' + this.pageNum +' ');
    Any assistance will be most appreciated.

    Thank you very much for your assistance try.
    I have modified the code as suggested and the page numbers are now listing correctly, thank you, but....................,
    The console  lists every page as having an "employee signature" when there are pages in the document that do not have an employee signature.
    The code (revised as follows) is not processing the "getPageNthWord part of the statement" in the console report?
    Can you please advise where the code needs reworking?
    var ckWords; // word pair to test
    var bFound = false; // logical status of found words
    // loop through pages
    for (var i = 0; i < this.numPages; i++ ) {
       bFound = false; // set found flag to false
       numWords = this.getPageNumWords(i); // number of words on page
       // loop through the words on page
       for (var j = 0; j < numWords; j++) {
          // get word pair to test
          ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words
          // check to see if word pair is 'Employee' string is present
          if ( ckWord == "Employee") {
             bFound = true; // indicate found logical value
             console.println('Pages that includes an employee signature: ' + (i + 1) +' ');
             break; // no need to further test for this page
          } // end Employee Signature
       } // end word loop
       // test to see if words not found
       if(bFound == false) {
             console.println('Pages that do include an employee signature: ' + (i + 1) +' ');
        } // end not found on page  
    } // end page loop
    Thank you

Maybe you are looking for