@Rahul : mlp
needs the time upto micro second and not upto milli second.
COBOL has a Intrinsic funtion to get the current date like below:
Quote:
Probably the most useful intrinsic function is CURRENT-DATE which is a replacement for ACCEPT DATE and ACCEPT TIME. CURRENT-DATE is Y2K-compliant, having a 4-digit year. This function returns a 20-character alphanumeric field which is laid out as follows:
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
The value returned from FUNCTION CURRENT-DATE, is 21-bytes, with a format of -
01-08 - Date "CCYYMMDD"
09-16 - Time "HHMMSSTH" (The "TH" is tenths/hundreths)
17-07 - GMT Offset sign ("-" or "+")
18-21 - GMT Offset "HHMM" to Local
Under the covers, FUNCTION CURRENT-DATE uses LE Callable routines CEELOCT (for bytes 01-16) and CEEGMTO (for bytes 17-21).
However, the normal timestamp portion returned as part of CEELOCT is "HHMMSSTHM" with the low-order "M" representing milliseconds. But, the timestamp returned as part of FUNCTION CURRENT-DATE truncates this "M". Perhaps the "TH" returned with FUNCTION CURRENT-DATE is the actual CEELOCT "THM" rounded to "TH"? I'm unsure about this.
Although a called Assembler sub-program (as previously suggested), using a STCK instruction and STCKCONV Macro would work, this resolved value is most likely going to be GMT. So instead, another small Assembler sub-program, which issues the TIME Macro (LINKAGE=SYSTEM and ZONE=LT), will return the current local timestamp as "HHMMSSTHMIJU", with "MIJU" representing Milliseconds, Ten-Thousandths, Hundred-Thousandths and Microseconds, respectively.
This can be used in CICS (verify this with your CICS SYSPROG, they can be a little "touchy"), providing you pass the caller's storage to the sub-program for its own reentrant usage, obtained by the caller via a CICS GETMAIN CICSDATAKEY (Key 8) and the PPT entry for the sub-program must be defined as EXECKEY(CICS) in RDO.
TIME (LINKAGE=SYSTEM) uses cross-memory facilities (no interrupt, uses PC/PT instructions), whereas LINKAGE=SVC (the default) uses an SVC 11, which causes is an interrupt. Besides, the timestamp value returned in an SVC 11 (in R0), is X"HHMMSSTH", so its the same as FUNCTION CURRENT-DATE as far as granularity and the date returned is in R1 as X'0CYYDDDF' (packed-decimal), so in order to make this Y2K compliant, you would have to add X'1F000000' to R1, resulting in a valid century.
mlp,
nice of you to finally mention the word "CICS"...
Apparently if you have to call a routine you might as well use your own routine and get that CURRENT TIMESTAMP from DB2.
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
Quote:
Now question is, which is best suited for the CICS env. I dont know for sure, but Can TSO commands be invoked from CICS env?
None of them is best suited for CICS -- TSO commands cannot be executed from CICS. If you had mentioned CICS from the start, we could have pointed you to EXEC CICS ASKTIME and EXEC CICS FORMATTIME, both of which are explained in the CICS Language Reference manual (link at the top of the page). The CICS commands return the time in milliseconds, rounded to the nearest hundredth of a second -- and that almost always is good enough for CICS transactions.
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
FWIW, in CICS/TS 4.1, the ASKTIME ABSTIME returned value will contain (most of the time) a non-X'0' millisecond digit, in the high-order nibble of the last (sign) byte. In other words, not rounded as in previous version/releases.
Got lot of information regarding the time, date and timestamp.
Thanks Everybody !!
And as far as my issue is concerned I still require the microseconds and moreover in CICS env. But I think after all of this discussion it is now safe to conlude that I can get it (time in mircosencods) from DB2 only (with the current timestamp). Please correct me if I am wrong.
If you had told us why you need such a thing, we could have given many more good ideas.
For example, maybe 100th of second is enough for your need.
Once I used the time (up to 100th of second) and added a counter instead of the millisec (can't remember exactly the precision used, but that's the general idea).
And again, if you had said "CICS" from the beginning, some suggestions would never have been made.
Bottom line, some people just lost their time with you