Application Development and Automation 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: 
Read only

Date Selection Error

Former Member
0 Likes
1,202

Hello,

I have 4 parameters for date_low date_high time_low time_high. When there is values in these parameters everything works fine but when there are no values I get a sy-subrc 4 saying that there are no values for the select statement.

select * from ztable where date >= date_low and
                                            date <= date_high and
                                            time >= time_low and
                                            time <= time_high.

Requirement is to use parameters instead of select-options. Everything works fine when there is values but when the parameters are blank it doesnt select any values. Please help me out.> Thanks

Edited by: Vicky Vicky on Feb 27, 2010 12:45 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,166

use OR condition...

9 REPLIES 9
Read only

Former Member
0 Likes
1,167

use OR condition...

Read only

0 Likes
1,166

Hello Subas,

OR condition didnt help for me. Can you give an example. Thanks

Read only

0 Likes
1,166

try this.

select * from ztable where date >= date_low OR

date <= date_high OR

time >= time_low OR

time <= time_high.

Let me know if it not useful....

Read only

0 Likes
1,166

No Subas,

I tried this. This doesnt help because it selects all the values no matter u put in the parameters.

Read only

0 Likes
1,166

hi,

try the below code.

select * from ztable where date >= date_low OR

date <= date_high OR

time >= time_low OR

time <= time_high.

DATA: it_tab type table of ztable with header line.

DATA: date type sy-datum,

time type sy-uzeit.

ranges: r_date for sy-datum,

r_time for syst-uzeit.

if date cn '00000000'.

r_date-sign = 'I'.

r_date-option = 'LE'.

r_date-low = date-low.

r_date-high = date-high.

append r_date.

endif.

if time cn '000000'.

r_time-sign = 'I'.

r_time-option = 'LE'.

r_time-low = time-low.

r_time-high = time-high.

append r_time.

endif.

select * from ztable where date in and time in r_time.

Edited by: subas Bose on Feb 27, 2010 1:35 AM

Edited by: subas Bose on Feb 27, 2010 1:38 AM

Read only

0 Likes
1,166

can anyone help me with this please. Thanks

Read only

0 Likes
1,166

HI Vicky,

Requirement is to use parameters instead of select-options
DATA : R_DATE TYPE RANGE OF SY-DATUM, " Take Suitable one
                       R_TIME TYPE RANGE OF SY-UZEIT,
                       WA_DATE LIKE LINE OF R_DATE,
                      WA_TIME LIKE LINE OF R_TIME.
refresh r_date.
clear wa_date.
wa_date-sign = 'I'.
wa_date-option = 'EQ'. " You can change this to BT
wa_date-low = date-low.
wa_date-high = date-high.
append wa_date to r_date.

refresh r_time.
clear wa_time.
wa_time-sign = 'I'.
wa_time-option = 'EQ'. " You can change this BT
wa_time-low = date-low.
wa_time-high = date-high.
append wa_time to r_time.


select * from ztable where date in r_date  " This is equivalent to Select Options
             and    time in r_time.

" OR Check this one
if not date-low is initial and not date-high is initial.
select * from ztable where date between date_low and date_high
       and time between time_low and time_high.
endif.

CHeers

Ram

Edited by: Ramchander Krishnamraju on Feb 27, 2010 3:50 AM

Read only

Former Member
0 Likes
1,166


if date-high = space.

          date-sign = 'I'.
          date-option = 'BT'.
          date-low  = date-low.
          date-high = date-high.

          append date.
          clear  date.
        else.
          date-sign = 'I'.
          date-option = 'EQ'.
          date-low = date-low.
          append date.
          clear  date.
        endif.


if time-high = space.

          time-sign = 'I'.
          time-option = 'BT'.
          time-low  = time-low.
          time-high = time-high.

          append time.
          clear  time.
        else.
          time-sign = 'I'.
          time-option = 'EQ'.
          time-low = time-low.
          append time.
          clear  time.
        endif.




select * from ztable where date >= date-low and
                                            date <= date-high and
                                            time >= time-low and
                                            time <= time-high.


Edited by: Krupaji on Feb 27, 2010 6:14 AM

Read only

Former Member
0 Likes
1,166

dear vicky,

1) use select-options like parameters means select-options no extension no interval.

2)other wise make all parameter fields are all mandatory.

regards,

srinivas