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

abap webdynpro date compare

Former Member
0 Likes
857

hi guys ,

i am trying to get the sy-datum stored in oracle database and compare it with current date and set a flag .

i am trying to do some thing like this and it does not work. please help.

systemdate type sy-datum,

currenttime type sy-datum.

systemdate = geting from select * table ..

currentdate = sy-datum.

if systemdate = currrentdate.

enable = 'y'.

endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

Hi ,

i am storing sy-datum in database table along with bunch of other fields.

for one day the row should inserted only once. so i bring the date from datebase and compare it with currentdate if it is equal to i set the flag in context. based on the flag y or n i set the ui element to visible insivible as if a row instered for a particular day the ui element should not display.

thanks ,

chandra.

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
816

The system date will always be the same as current date, will it not?

Why are you trying to get the system date from a table?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
816

hi,

Check the date that you are getting from table in debug mode.

and then compare it,

it must work.

regards,

Manohar

Read only

Former Member
0 Likes
817

Hi ,

i am storing sy-datum in database table along with bunch of other fields.

for one day the row should inserted only once. so i bring the date from datebase and compare it with currentdate if it is equal to i set the flag in context. based on the flag y or n i set the ui element to visible insivible as if a row instered for a particular day the ui element should not display.

thanks ,

chandra.

Read only

0 Likes
816

Well then you code is ok. It should work. But you might want to get the db table with the current date. If it gets a hit, then SY-SUBRC = 0 and you should set the flag.

data: xztab type ztab.

clear xztab.
select Single * from ztab into xztab
           where datum = sy-datum.
if sy-subrc  = 0.
flat = 'Y'.
endif.

Regards,

Rich Heilman

Read only

0 Likes
816

Hi,

If you check the date values in debug mode. It will always be in the form of yyyymmdd.

So there is no point of different in both values.

You can compare the values as you want.

Thanks,

G.S.K

Read only

Former Member
0 Likes
816

HI ,

When i display the date it is displayed as 20060706.

when i do this

DIFF = CURRENTDATE - SYSTEMDATE . i always get diff as 7 even if i do 20060706 - 20060706.

can any one try this ?

thanks,

chandra.

Read only

0 Likes
816

Make sure that DIFF is defined as type I.

data: diff type i,
      curdt type sy-datum,
      sysdt type sy-datum.

curdt = sy-datum.
sysdt = sy-datum.

diff = sysdt  - curdt.

write:/ diff.

Regards

Rich Heilman

Read only

Former Member
0 Likes
816

hi Rich Heilman,

your solution worked. let me know if you have not received the points.

thanks ,

chandra.