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

how to write the select

Former Member
0 Likes
946

i am writting a selection and i want to select from the table HRP1001 only the rows that created this year

i wrote

select *

into itab

from hrp1001

where concatenate begda(4) eq sy-datum(4).

why its not working ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
914

Hi,

Data:w_date type sy-datum.

Concatenate sy-datum+0(4) '%' into w_date.

Simply write:

SELECT * from HRP1001
        into table itab 
     where BEGDA like w_date.

Regards,

Sujit

try with following code.

select *

into itab

from hrp1001

where begda0(4) eq sy-datum0(4).

6 REPLIES 6
Read only

Former Member
0 Likes
914

try with following code.

select *

into itab

from hrp1001

where begda0(4) eq sy-datum0(4).

Read only

Former Member
0 Likes
915

Hi,

Data:w_date type sy-datum.

Concatenate sy-datum+0(4) '%' into w_date.

Simply write:

SELECT * from HRP1001
        into table itab 
     where BEGDA like w_date.

Regards,

Sujit

Read only

Former Member
0 Likes
914

Hi Ami,

concatenate and partial field selection are not part of Open SQL. You could use a pattern:


concatenate sy-datum(4) '%' into lw_year_pattern.
select * into itab
         from hrp1001
        where begda like lw_year_pattern.

or you could use between, probably more efficient:


lw_date_from = lw_date_to = sy-datum.
lw_date_from+4(4) = '0101'.
lw_date_to+4(4) = '1231'.
select * into itab
         from hrp1001
        where begda between lw_date_from and lw_date_to.

Good luck,

Gert.

Read only

0 Likes
914

Good Gert Beukema,

Syed Tayab Shah

Read only

Former Member
0 Likes
914

Well, BEGDA is not the date created.

Rob

Read only

Former Member
0 Likes
914

hi,

u have to take LDATE logical date .. between begda and ennda...

make use of offset to 0(4) represents year field.s

Regards..

Raju Mummidi