View previous topic :: View next topic
|
Author |
Message |
vinod71082
New User
Joined: 05 Jul 2007 Posts: 10 Location: chennai
|
|
|
|
Is it possible to get TIMESTAMP in cobol without using DB2.
Thanks & Regards
Vinod kumar |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
no |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
Back to top |
|
|
vinod71082
New User
Joined: 05 Jul 2007 Posts: 10 Location: chennai
|
|
|
|
hi,
shreevamsi ,i think u didn't understand my question.
timestamp consist of date-time with nano sec . tell me how to get the nano sec using cobol without using DB2. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
Back to top |
|
|
lcmontanez
New User
Joined: 19 Jun 2007 Posts: 50 Location: Chicago
|
|
|
|
FYI.... You need to be using Enterprise cobol for function to work. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
The following Assembler macro can be used to generate a DB2-format timestamp.
TIME DEC,RATICKWA,LINKAGE=SYSTEM,
MF=(E,LIST1MAC),DATETYPE=YYYYMMDD
We call Assembler routines (one for batch, one for CICS) that issue this macro and return the DB2 style timestamp. |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi TG Murphy, Could you plz Elaborate your answer, how actually This can be used in cobol program?
Thanks....
Vasanth...... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
An assembler subroutine is called from the COBOL program. The subroutine returns the date in db2 format.
The assembler routine is the macro definition TG posted plus the standard linkage - talk with someone in your organization with basic assembler skills to get the module(s) assembled. |
|
Back to top |
|
|
achittu
New User
Joined: 26 Feb 2007 Posts: 14 Location: chennai
|
|
|
|
I have the same requirement now ... is it possible to do this without using ASSEMBLER ? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
achittu wrote: |
I have the same requirement now ... is it possible to do this without using ASSEMBLER ? |
The response you received at the other site uses a LE callable routine, isn't that good enought? |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
Craq,
Please tell me about the LE callable routine. What is the "other" site you are referring to?
If this LE routine lets us avoid the assembler then bonus... |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
Vasanth,
Do you have someone in your organization that knows Assembler? There are very few of these people left.
I can send you the source code but you'll need someone who knows what to do with it...
Send me a PM to let me know... |
|
Back to top |
|
|
dominickim
New User
Joined: 28 Feb 2007 Posts: 65 Location: NS, CA
|
|
|
|
Cobol source from gsf-soft.com/Freeware/
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. MVSCB.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CURR-JDATE PIC 9(7) COMP-3.
01 FOUR-BYTES.
05 FULL-WORD PIC S9(8) COMP.
05 PTR4 REDEFINES FULL-WORD POINTER.
05 PL4 REDEFINES FULL-WORD PIC 9(7) COMP-3.
LINKAGE SECTION.
01 CB1. 05 PTR1 POINTER OCCURS 512.
01 CVT. 05 CVT1 POINTER OCCURS 512.
PROCEDURE DIVISION.
SET ADDRESS OF CVT TO PTR1(5)
SET ADDRESS OF CB1 TO CVT1(50)
MOVE CB1(29:4) TO FOUR-BYTES
COMPUTE CURR-JDATE = PL4 + 1900000
DISPLAY 'CURRENT DATE=' CURR-JDATE
STOP RUN.
|
Output - I could not find time in MCB yet.
Code: |
COMMAND INPUT ===> SCROLL ===> CSR
CURRENT DATE=2007326
******************************** BOTTOM OF DATA ******************************** |
|
|
Back to top |
|
|
dominickim
New User
Joined: 28 Feb 2007 Posts: 65 Location: NS, CA
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
If you just want the date/time, with the time resolution as precise as the ACCEPT TIME verb:
ACCEPT DATE
ACCEPT TIME
ACCEPT DATE again into a different variable
If both dates are =, then you've got it.
Otherwise, ACCEPT TIME again, as midnight occurred between the first two ACCEPTs.
Rudimentary, but is this OK? |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Correction: Midnight may have occurred between the first two ACCEPTs, but certainly occurred between the two ACCEPT DATEs. |
|
Back to top |
|
|
joepie meloenie
New User
Joined: 28 Nov 2007 Posts: 4 Location: amstelveen
|
|
|
|
far too difficult....
Here an example to build a db2-look alike timestamp without using sql:
Code: |
WORKING-STORAGE SECTION.
* T I M E S T A M P D B 2 X(26) EEEE-MM-DD-UU.MM.SS.HH0000
01 DB2-TIMESTAMP PIC 9999.99.99.99.99.99.990000.
01 FILLER REDEFINES DB2-TIMESTAMP.
06 FILLER PIC X(004). EEEE
06 DB2-STREEP-1 PIC X. -
06 FILLER PIC X(002). MM
06 DB2-STREEP-2 PIC X. -
06 FILLER PIC X(002). DD
06 DB2-STREEP-3 PIC X. -
06 FILLER PIC X(016). USH0
PROCEDURE DIVISION.
MAIN SECTION.
MAIN-000.
MOVE FUNCTION CURRENT-DATE (1:16) TO DB2-TIMESTAMP
MOVE '-' TO DB2-STREEP-1 DB2-STREEP-2 DB2-STREEP-3
DISPLAY 'DB2-TIMESTAMP = ' DB2-TIMESTAMP
.
|
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
But this won't work under COBOL's that do not have FUNCTION. |
|
Back to top |
|
|
joepie meloenie
New User
Joined: 28 Nov 2007 Posts: 4 Location: amstelveen
|
|
|
|
so I guess you don't work on the mainframe.....
Also all modern cobol's do have that.....
but.. if you don't have it, of course you can work with accept.... but take care about the ghosthour trouble.... so.... be sure that the date does not change between the moment you accept the date, after that the time and after that verify that the date has not changed.....
http://www.ghost-transaction.com/ |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
That is in fact exactly what my earlier code (with subsequent correction) does. Did you read it?
That some users of this website in fact are using COBOL II makes my suggested code, and later comment, relevant to this group of users.
Certainly the FUNCTION approach is preferred if you have it.
BTW - I have been using IBM 360 etc. series since 1966.
I don't claim to have the answer, but am willing to look for it and assume another person's approach is a good one in certain circumstances. |
|
Back to top |
|
|
joepie meloenie
New User
Joined: 28 Nov 2007 Posts: 4 Location: amstelveen
|
|
|
|
Congratulations. You are a Dino..... :-)
Perhaps you should point the cobol-2 users to Gilbert Saint-flour sources with for example cob2job that also provides micro-seconds. |
|
Back to top |
|
|
|