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 statement

Former Member
0 Likes
650

Hi All,

Requirement,

Fetch the data based on date and time.

Input parameter.

Selection screen :----

Select-options : Entry Date .

Select-options : Entry Time.

I have written code to fetch the data based on Entry Date and Entry time.

Code :----

select *

from tablename

into table i_tab

where entrydate in s_enntdat and

entrytime in s_ennttim.

this code fetches the data from date and time.

But i must get the data betweeb entry date and entry time.

Eg:-.... when I give

Entry Date : 22.09.2008 to 07.11.2008

Entry Time Low : 11:00:20

Entry Time High: 06:00:00.

I am getting only entries from date 22.09.2008.

My requirement is that it has to get all the datas from table between 22.09.2008 to 07.11.2008.

And documents between time 11:00:00 to 06:00:00.

That is data should start from 22.09.2008 and time 11:00:00

and end at 07.11.2008 and time 06:00:00.

If there are any entries between 22.09.2008 and 07.11.2008. Irrespective of time all the entries must be retrived.

how to write a single select query for this.

6 REPLIES 6
Read only

Former Member
0 Likes
622

Hi This is TIME related query ...

So u need to use the TIME macros for this for example..

after GET pernr events.

write

RP_READ_ALL_TIME_ITY PERNR SPACE PN-BEGDA PN-ENDDA.

and after this loop on the pernr based on your requirement and fetch the data and this will solve your requirement.

Regards

Sas

Read only

Former Member
0 Likes
622

Hi Praveen,

According to me u have done only half the code.

U need to now LOOP the internal table and then move the values to an OUTPUT table

LOOP at tablename into wa_tablename.

move: tablename-entrydate to wa_out-entrydate,

tablename-entrytime to wa_out-entrytime.

append wa_out to it_out.

clear wa_out.

regards,

suryakiran

Read only

Former Member
0 Likes
622

Hi......

I think there is no data on 07.11.2008 between this time

11:00:20 & 06:00:00.

that's why data is not coming out......

Just try running you select statement with out time options......

it will work as your select query is fine....

Thanks

Saurabh

Read only

Former Member
0 Likes
622

hi.. try this..

select *

from tablename

into table i_tab

where entrydate between s_enntdat and s_ennttim.

regards,

Padma.

Read only

Former Member
0 Likes
622

Hi,

Try like this.

REPORT YSAMPLE.

tables: vbak.

data: begin of itab occurs 0,

vbeln type VBELN_VA,

erdat type erdat,

erzet type erzet,

end of itab.

SELECTION-SCREEN: begin of block b1 with frame title text-001.

select-OPTIONS: date for vbak-ERDAT,

time for vbak-ERZET.

SELECTION-SCREEN: end of block b1.

select * from vbak into CORRESPONDING FIELDS OF TABLE itab where erdat in date and erzet in time.

loop at itab.

write: / itab-vbeln, itab-erdat, itab-erzet.

endloop.

Thanks,

Srilakshmi

Read only

Former Member
0 Likes
622

Hi Praveen,

I think that the select statement that is written is correct.Have u checked whether data is there in the database for that particular date period and time period?

I think there will be no data.Please check

Rgds,

khadeer.