IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Is it possible to get TIMESTAMP in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinod71082

New User


Joined: 05 Jul 2007
Posts: 10
Location: chennai

PostPosted: Fri Aug 24, 2007 4:50 pm
Reply with quote

Is it possible to get TIMESTAMP in cobol without using DB2.

Thanks & Regards
Vinod kumar
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 24, 2007 4:59 pm
Reply with quote

no
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Fri Aug 24, 2007 5:00 pm
Reply with quote

Hi,

If you wan to populate time stamp in a WS variable : look at this link
www.ibmmainframes.com/viewtopic.php?t=2402&highlight=currenttime
Back to top
View user's profile Send private message
vinod71082

New User


Joined: 05 Jul 2007
Posts: 10
Location: chennai

PostPosted: Fri Aug 24, 2007 5:06 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 24, 2007 9:06 pm
Reply with quote

Hello,

If you look in the COBOL manual linked to via this site you may find something useful.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/7.1.9?SHELF=&DT=20020920180651&CASE=
Back to top
View user's profile Send private message
lcmontanez

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Sat Aug 25, 2007 12:07 am
Reply with quote

FYI.... You need to be using Enterprise cobol for function to work.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Tue Sep 04, 2007 11:46 pm
Reply with quote

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
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Wed Sep 26, 2007 2:59 pm
Reply with quote

Hi TG Murphy, Could you plz Elaborate your answer, how actually This can be used in cobol program?


Thanks....
Vasanth...... icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 26, 2007 8:20 pm
Reply with quote

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
View user's profile Send private message
achittu

New User


Joined: 26 Feb 2007
Posts: 14
Location: chennai

PostPosted: Wed Nov 21, 2007 11:15 pm
Reply with quote

I have the same requirement now ... is it possible to do this without using ASSEMBLER ?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Nov 22, 2007 12:17 am
Reply with quote

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
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Nov 22, 2007 11:23 pm
Reply with quote

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
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu Nov 22, 2007 11:34 pm
Reply with quote

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
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Fri Nov 23, 2007 1:00 am
Reply with quote

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
View user's profile Send private message
dominickim

New User


Joined: 28 Feb 2007
Posts: 65
Location: NS, CA

PostPosted: Fri Nov 23, 2007 2:38 am
Reply with quote

CVT map
publib.boulder.ibm.com/infocenter/zos/v1r9/index.jsp?topic=/com.ibm.zos.r9.iead100/iea2d180569.htm
and example to access MVS Control Block
supportline.microfocus.com/documentation/books/mx25sp1/cocblk.htm
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Nov 23, 2007 7:36 am
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Nov 23, 2007 7:44 am
Reply with quote

Correction: Midnight may have occurred between the first two ACCEPTs, but certainly occurred between the two ACCEPT DATEs.
Back to top
View user's profile Send private message
joepie meloenie

New User


Joined: 28 Nov 2007
Posts: 4
Location: amstelveen

PostPosted: Thu Nov 29, 2007 2:36 am
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Nov 29, 2007 2:43 am
Reply with quote

But this won't work under COBOL's that do not have FUNCTION.
Back to top
View user's profile Send private message
joepie meloenie

New User


Joined: 28 Nov 2007
Posts: 4
Location: amstelveen

PostPosted: Thu Nov 29, 2007 4:33 am
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Nov 29, 2007 7:30 am
Reply with quote

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
View user's profile Send private message
joepie meloenie

New User


Joined: 28 Nov 2007
Posts: 4
Location: amstelveen

PostPosted: Thu Nov 29, 2007 11:43 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts To get the count of rows for every 1 ... DB2 3
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top