I'm trying to define time.

gerie

Member
I'm trying to get a grip on the dates and times.
When I make a procedure stating:

FOR FIRST c_DWHdate.
UPDATE c_DWHdate.time-lc = TIME.
END.

My time field is updated, so that's good :-)

When I try to make some variables, TIME is a problem. Why is that and what do I use in stead of TIME?

DEF VAR my-datetime as CHAR no-undo.
DEF VAR v-filename AS CHAR no-undo.
DEF VAR v-location AS CHAR no-undo.
DEF VAR v-fullpath AS CHAR no-undo.
DEF VAR lastdate AS DATE no-undo.
DEF VAR CURRENTDATE AS DATE no-undo.
DEF VAR lasttime AS TIME no-undo.
DEF VAR currenttime AS TIME no-undo.

Could not find source class file TIME.cls. (12625)
Invalid datatype specified: TIME. Specify a datatype such as 'character' or the name of a class. (5638)
** Could not understand line 7. (196)
 
TIME is an integer value of miliseconds since midnight so you'd need to put it into an integer variable. To see that actual time use STRING(currenttime)
 
I changed my procedure to:

DEF VAR my-datetime as CHAR no-undo.
DEF VAR v-filename AS CHAR no-undo.
DEF VAR v-location AS CHAR no-undo.
DEF VAR v-fullpath AS CHAR no-undo.
DEF VAR last_date AS DATE no-undo.
DEF VAR currentdate AS DATE no-undo.
DEF VAR last_time AS INTEGER no-undo.
DEF VAR current_time AS INTEGER no-undo.
FIND FIRST c_DWHdate.
last_date = c_DWHdate.DATE.
last_time = c_DWHdate.time-lc.
currentdate = TODAY.
current_time = TIME.

And this seems to work very well. So thanx for the help on that one.

Now I would like to know the values of my variables. So I tried to log them, but somehow my log stays empty. Can anyone tell me how to get my values in a log?
 
OUTPUT TO /tmp/my_log. // Unix-style but will work similar for Windows
MESSAGE "is logging working?". // Test to make sure it's working
MESSAGE myvar. // This should work regardless of data type

You should see at least the first line, if not, you have some problem such as the file not being writeable (path invalid, no permission etc.) or someone else is stomping on it.
 
Code:
DEF VAR my-datetime     AS CHAR     no-undo.
DEF VAR v-filename      AS CHAR     no-undo.
DEF VAR v-location      AS CHAR     no-undo.
DEF VAR v-fullpath      AS CHAR     no-undo.
DEF VAR last_date       AS DATE     no-undo.
DEF VAR currentdate     AS DATE     no-undo.
DEF VAR last_time       AS INTEGER  no-undo.
DEF VAR current_time    AS INTEGER  no-undo.

FIND FIRST c_DWHdate NO-LOCK NO-ERROR.
IF AVAIL c_DWHdate THEN
    ASSIGN
    last_date    = c_DWHdate.DATE 
    last_time    = c_DWHdate.time-lc .

ASSIGN 
    currentdate  = TODAY
    current_time = TIME
    v-filename   = "MyLog.txt"
    v-fullpath   = "C:\Temp\" + v-filename.
 

OUTPUT TO VALUE(v-fullpath).
PUT UNFORMATTED 
       "Last Date : " last_date    SKIP 
       "Last Time : " last_time    SKIP
       "Curr Date : " currentdate  SKIP
       "Curr Time : " current_time SKIP.
OUTPUT CLOSE.
 
Back
Top