Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Where condition problem

Former Member
0 Kudos

hi experts,

I face a small criticality in finishing the report since

the requirement has been changed .

The below select stmt works perfectly for fetching

Employee no betwen the start date and End Date

Select pernr begda endda rtamt from pa0581

into corresponding fields of table it_pa0581

where pernr in so_pernr and

begda >= pr_begda and

endda <= pr_endda .

But, ...Now, the requirement is that

For E.g

START DATE ENDATE

12.03.2007 31.12.9999

17.03.2006 11.03.2007

if i give the input as 17.03.2006 and 12.03.2007 means

it will fetch only the second row of the e.g data i have

specified above, but they say since 31.12.9999 is considered

as active it(i.e the first row ) it also shud come in the output....

Therefore 2 rows has to be selected in the output for given input.

Iam bit confused how to change the select according,

Please do help me out....

Thanks in Advance

Regards

Rachel Arun

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rachel,

I dont know this effects functionality but gives you solution what you are looking for. Check the enddate is '31.12.9999' as OR condition for enddate condition.

Select pernr begda endda rtamt from pa0581
into corresponding fields of table it_pa0581
where pernr in so_pernr and
begda >= pr_begda and
( endda <= pr_endda or endda = '99991231' ).

Thanks,

Vinay

5 REPLIES 5

faisal_altaf2
Active Contributor
0 Kudos

Hi, Rachel

Use " Provide Endprovide " like bellow.

I think the following Code will help you here in this case I want the get the qualification of the pernr where I Bound the Begda and Endda with the given dates condition, in the result it provide me the record where begda and endda not greater then the give dates for example..

Begda endda slart

01.01.2008 02.02.2008 U1

01.02.2008 03.03.2008 U2

02.03.2008 31.12.9999 U3

In the following example if cdate is 12.02.2008 than it will return you the 2nd record

where slart is U2

provide fields pernr slart from it_pa0022 into wa_it_pa0022
      valid flag1 bounds begda and endda
      where pernr = wa_it1_all_emp-pernr
      between cdate and cdate.
    endprovide.

Please Reply if any problem

Kind Regards,

Faisal

Edited by: Faisal Altaf on Jan 24, 2009 12:10 PM

0 Kudos

Hi faisal

Thanks for your reply but my requirement is

17.03.2006 .18.12.2007 U1

12.03.2008. 12.11. 2009 U2

13.11.2009 31.12.9999 U3

if i give the input as 17.03.2006 to 13.11.2009 means

it should return all the 3 rows that is ( U1 U2 U3)

but as of now its returning only U1 and U2 . since its not considering 31.12.9999

but my consultant say that 31.12.9999 mean the person is ACTIVE so that has also to be

shown in the output....

Hope i have cleared my requirement/.................

Pls help me out..

Thanks in Advance

Regards

Rachel

0 Kudos

Hi Rachel,

try using structure selopt to fill ur requirement.

data : t_selopt type table of selopt,

wa_selopt type selopt.

wa_selopt-sign = I (can be I or E)

wa_selopt-option = (xx , one of the values EQ,NE,CP,NP,GE,LT,LE,GT)

wa_selopt-low = XYZ

wa_selopt-high = XYZ1

append wa_selopt to t_selopt.

and use this in where clause.

May be this can solve ur problem for multiple conditions.

Regards,

Nibha

0 Kudos

Hi,

Test the following code it is working fine i have tested,

TABLES: pa0008.

SELECT-OPTIONS: sopernr FOR pa0008-pernr NO-EXTENSION NO INTERVALS,
                sodate FOR sy-datum.

DATA: it_pa0008 LIKE STANDARD TABLE OF pa0008 WITH HEADER LINE,
      wa_it_pa0008 LIKE pa0008.

SELECT * FROM pa0008
  INTO CORRESPONDING FIELDS OF TABLE it_pa0008
  WHERE pernr IN sopernr
    AND begda IN sodate. " also use like this here (and begda BETWEEN sodate-low and sodate-high.)

in your Code

Select pernr begda endda rtamt from pa0581
into corresponding fields of table it_pa0581
where pernr in so_pernr and
begda >= pr_begda and
endda <= pr_endda . "Just Replace this endda with begda

Please Reply if any Issue, i am waiting for your Reply.

Kind Regards,

Faisal

Edited by: Faisal Altaf on Jan 24, 2009 12:53 PM

Former Member
0 Kudos

Hi Rachel,

I dont know this effects functionality but gives you solution what you are looking for. Check the enddate is '31.12.9999' as OR condition for enddate condition.

Select pernr begda endda rtamt from pa0581
into corresponding fields of table it_pa0581
where pernr in so_pernr and
begda >= pr_begda and
( endda <= pr_endda or endda = '99991231' ).

Thanks,

Vinay