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 Query

Former Member
0 Likes
947

Hi,

i am using a select statement where i am writing,

select objectclas from cdhdr where udate = sy-datum+0(4).

this particular statement i feel ll not work as udate is ddmmyyy where i am checking wth only year.

\

can anyone tell me how can i go further on this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
906

hi

u can select all the objects whose year matches

for that you need to have a range of date type

range-sign = 'EQ'.
range-option =  'I'.
concatenate '%' sy-datum+0(4) into string
range-low = string.

select objectclas from cdhdr into table itab where udate in range.

Regards

Sajid

8 REPLIES 8
Read only

Former Member
0 Likes
907

hi

u can select all the objects whose year matches

for that you need to have a range of date type

range-sign = 'EQ'.
range-option =  'I'.
concatenate '%' sy-datum+0(4) into string
range-low = string.

select objectclas from cdhdr into table itab where udate in range.

Regards

Sajid

Read only

0 Likes
906

but here udate and range is different right...

udate is full date format where as sydatum+0(4) is just year im considering.

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
906

Hi Poonam

Take one variable(lv_date) and assign the value lv_date = sy-datum+0(4) to that variable before selection.

Now call the select query

select objectclas from cdhdr where udate eq lv_date.

It will work for sure.

Regards,

Sreeram

Read only

0 Likes
906

udate is ddmmyyyy and lvdate is yyyy

how to compare this?/?

Read only

Former Member
0 Likes
906

Hi

Use the sy-datum ie yyyymmdd that system internaly use to get the data from tables if no alfa conversion routines are maintained in domain of any fiels.

UDATE having domain as DATUM(yyyymmdd) .Soinsteed of usung sy-datum+0(4) use SY-datum in where clause.

Thanks,

Deepanker Dwivedi

Read only

0 Likes
906

but my requiremnt is just to compare with the current year.

Read only

0 Likes
906

data: date_from like sy-datum,  "start date 
         date_to     like sy-datum. "End date

move: '0101' to date_from+4(4),
          sy-datum(4) to date_from(4),
         '1231' to date_to+4(4),
          sy-datum(4) to date_to(4). 
* Now you got 2 dates, with the start and the end of the current year

*This select read all changes between the start and the end of the year.
Select objectclas from cdhdr into table itab where udate le date_to
                                                                          and udate ge date_from.

You can avoid the use of 'DATE_TO' since you got SY-DATUM that is today and SAP register modify until today and not for tomorrow

Edited by: Simone Milesi on Jul 21, 2009 9:51 AM

Read only

0 Likes
906

Hi

Why don't you try something like this:

range-sign = 'CP'.  
range-option =  'I'.
concatenate '++++' sy-datum+0(4) into string    
range-low = string.

The Patterned string could be based on your requirements. Check out the help for the keyword CP.

Hope this helps,

Wenonah