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

Select is not working with date range .

Former Member
0 Likes
1,571

In my program doing a simple select from cdhdr table based on date range i have created but it fails .

here is the code I am using.

SELECT SINGLE * FROM tvarv INTO wa_tvarv WHERE name EQ 'Z_SERVICE_CHANGE_DATE' .

move wa_tvarv-low to v_date .

move wa_tvarv-high to v_time .

  • fill the date range

*write v_date to ra_date-low .

move v_date TO ra_date-low .

*write sy-datum to v_dateh .

ra_date-high = sy-datum .

ra_date-sign = 'I' .

ra_date-option = 'BT' .

APPEND ra_date .

  • fill the time range

move v_time TO ra_time-low .

*write sy-uzeit to v_timeh .

ra_time-high = sy-uzeit .

ra_time-sign = 'I' .

ra_time-option = 'BT' .

APPEND ra_time .

*Get all the records from cdhdr table for contract i.e VERKBELEG .

*SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE it_cdhdr*

*WHERE objectclas = 'VERKBELEG'*

*AND udate IN ra_date*

*and UTIME in ra_time .*

above select is creating Problem .

Help will be Appreciated .

In my program doing a simple select from cdhdr table based on date range i have created but it fails .

here is the code I am using.

SELECT SINGLE * FROM tvarv INTO wa_tvarv WHERE name EQ 'Z_SERVICE_CHANGE_DATE' .

move wa_tvarv-low to v_date .

move wa_tvarv-high to v_time .

  • fill the date range

*write v_date to ra_date-low .

move v_date TO ra_date-low .

*write sy-datum to v_dateh .

ra_date-high = sy-datum .

ra_date-sign = 'I' .

ra_date-option = 'BT' .

APPEND ra_date .

  • fill the time range

move v_time TO ra_time-low .

*write sy-uzeit to v_timeh .

ra_time-high = sy-uzeit .

ra_time-sign = 'I' .

ra_time-option = 'BT' .

APPEND ra_time .

*Get all the records from cdhdr table for contract i.e VERKBELEG .

*SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE it_cdhdr*

*WHERE objectclas = 'VERKBELEG'*

*AND udate IN ra_date*

*and UTIME in ra_time .*

above select is creating Problem .

Help will be Appreciated .

3 REPLIES 3
Read only

Former Member
0 Likes
850

I wonder if you have a conflict between your date and time. If you want all records between 3PM and 3AM the next day, that will cause a conflict. That's because the first date should be "before" the second date, wthin a given day.

To troubleshoot, why don't you try taking the time part out of the SQL?

Read only

Former Member
0 Likes
850

Hi ,

Try only using the Date selection criteria.... It's not working because you are trying both data as well as time.

Thanks,

Greetson

Read only

Former Member
0 Likes
850

Building a date range using ranges is risky. You might miss a value in HIGH field.

I would suggest you to use select-option no-display and build the date.

Thanks,

SKJ