MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Time Stamp

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Wed Jul 12, 2006 3:17 pm    Post subject: Time Stamp Reply with quote

Hi All,

In my program, after accepting the TIME into the working storage (HH:MM:SS) i have to increment the seconds part by 1 in each execution of the loop and have to store in the database as the time stamp (6 Char) is the part of the key.

If the seconds part is 60th second, it should increment minutes part by 1 and should set the seconds to 01 and similary for minutes part with hours part.

Do we have any function or method by which i can add 1 to the time stamp (With HH:MM:SS) and gets the time incremented as required with out writing the whole logic as i mentinoed above.

for Eg: if the time is : 120259

Add 1 to 120259 to get 120300
or
ADD 1 to 125959 to get 130000

Please clarify
_________________
Tx
Digger
Back to top
View user's profile Send private message  
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Jul 13, 2006 1:19 am    Post subject: Reply with quote

MFdigger,

I am basically trying to insert into a column of DB2 table with Time in HHMMSS in character format.If you can modify as per your needs , i hope it might help you.Make a simple query after you run the Program
Code:
 
SELECT * FROM TIMETABLE;

Code:

       WORKING-STORAGE SECTION.                                         
       01 WS-CNT           PIC S9(04) COMP VALUE 1.                     
       01 WS-TIME          PIC X(06)  VALUE SPACES.                     
       01 WS-TEMP.                                                     
          02 WS-HH         PIC 9(02)  VALUE ZEROES.                     
          02 WS-MM         PIC 9(02)  VALUE ZEROES.                     
          02 WS-SS         PIC 9(02)  VALUE ZEROES.                     
      ******************************************************************
      *                   DB2 DECLARATIONS                             *
      ******************************************************************
       01 FILLER              PIC X(25) VALUE                           
           'SQL COMMUNICATIONS AREA'.                                   
                                                                       
           EXEC SQL                                                     
                INCLUDE SQLCA                                           
           END-EXEC.                                                   
      ******************************************************************
      * COBOL DECLARATION FOR TABLE TIMETABLE                    *
      ******************************************************************
       01  DCLTIMETABLE.                                               
           10 WSTIME               PIC X(06).                           
      ******************************************************************
      * THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 1       *
      ******************************************************************
                                                                       
       PROCEDURE DIVISION.                                             
      ******************************************************************
      *                PROCEDURE DIVISION                              *
      ******************************************************************
      D    DISPLAY 'ENTRY INTO SHEKARPGM'.                               
                                                                       
           ACCEPT WS-TIME FROM TIME.                                   
           MOVE WS-TIME   TO WSTIME.                                   
           EXEC SQL                                                     
                    INSERT INTO TIMETABLE VALUES (:WSTIME)       
           END-EXEC.                                                   
                                                                       
           PERFORM UNTIL WS-CNT > 9                                     
              ACCEPT WS-TIME FROM TIME                                 
              MOVE   WS-TIME TO   WSTIME                               
                                                                       
              EVALUATE TRUE                                             
                 WHEN WSTIME(5:2) = '59' AND WSTIME(3:2) = '59'         
                      MOVE WSTIME(1:2) TO WS-HH                         
                      ADD  +1 TO WS-HH                                 
                      MOVE WS-HH TO WSTIME(1:2)                         
                      MOVE '00' TO WSTIME(3:2)                         
                      MOVE '00' TO WSTIME(5:2)                         
                 WHEN WSTIME(5:2) = '59'                               
                      MOVE WSTIME(3:2) TO WS-MM                         
                      ADD  +1 TO WS-MM                                 
                      MOVE WS-MM TO WSTIME(3:2)                         
                      MOVE '00' TO WSTIME(5:2)                         
                 WHEN WSTIME(3:2) = '59'                               
                      MOVE WSTIME(1:2) TO WS-HH                         
                      ADD  +1 TO WS-HH                                 
                      MOVE WS-HH TO WSTIME(1:2)                         
                      MOVE '00' TO WSTIME(3:2)                         
              END-EVALUATE                                             
                                                                       
              EXEC SQL                                                 
                   INSERT INTO TIMETABLE VALUES (:WSTIME)         
              END-EXEC                                                 
              ADD +1 TO WS-CNT                                         
              INITIALIZE WS-TEMP                                       
              END-PERFORM.                                             
                                                                       
      D    DISPLAY 'EXIT FROM SHEKARPGM'.                                 
           STOP RUN.                                           

OUTPUT when i ran for SS = 59 , see first insert was 113659 and from the second insert it has changed to 113700.
Code:

SELECT * FROM TIMETABLE;
---------+---------+----
WSTIME                 
---------+---------+----
113659                 
113700                 
113700                 
113700                 
113700                 
113700                 
113700                 
113700                 
113700                 
113700                 

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message  
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 13, 2006 6:56 am    Post subject: Reply with quote

MFdigger,

How about this simple SQL ?

Code:

INSERT INTO TABLE
  VALUES(CHAR(REPLACE(CHAR(CURRENT TIME + 1 SECOND),'.',''),6)
;                                                     


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website  
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Jul 13, 2006 8:08 am    Post subject: Reply with quote

Kolusu,

I had got syntax error when i had run the query ,actually i had to remove one extra '('
Code:

INSERT INTO TABLE
  VALUES CHAR(REPLACE(CHAR(CURRENT TIME + 1 SECOND),'.',''),6);

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message  
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Thu Jul 13, 2006 11:12 am    Post subject: Reply with quote

Hi Shekar, Kolusu

Thank you very much for your time responding to my question. I'm sorry that i didnt mentioned about the database which I'm using in my program.

I'm using the IMS database in my program. could you please help me out in this case.

Thank you in advance
_________________
Tx
Digger
Back to top
View user's profile Send private message  
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Jul 13, 2006 11:26 am    Post subject: Reply with quote

MFdigger,

If you are using IMS,please mention how are you going to insert the values in the db , the exact Segment name and defination and location in the database and some details like : Function code ,PCB Mask Name , any SSA 's being used so that the CALL to IMS can be descriptive ?
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message  
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Thu Jul 13, 2006 1:29 pm    Post subject: Reply with quote

Hi Shekar

The database has only one segment (parent segment - XY0K11GG) and the key starts in 5th byte with 38 bytes length with the split as shown below:
Code:

05 S-KEY
   10 L-TYPE   PIX X
   10 U-TYPE   PIX X(8)
   10 T-TYPE   PIX X(8)
   10 S-TYPE   PIC X(8)
   10 DT-STAMP   
      15 DT-JUL
         20 DT-JUL-CEN    PIC X(2)
         20 DT-JUL-DAT    PIC X(5)
      15 TS-CUR-TIME     PIC X(6).



TS-CUR-TIME is the field where i have to store the time stamp (HHMMSS). i'm trying to insert the value as shown below in the database.

Code:

CALL 'CBLTDLI' USING ISRT             
                                 PCB1-XY0K11GG       
                                 XY1GGCPY             
                                 SSA-XY1GGCPY-UNQUAL. 

Please let me know if you need any more info.

P.S: Can we increment the date value by 1 using some method or fucntion in cobol and move the value in to the database filed?
_________________
Tx
Digger
Back to top
View user's profile Send private message  
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Jul 13, 2006 11:32 pm    Post subject: Reply with quote

MFdigger,

I have done some slight modifications to the code and i am assuminmg the IO-AREA is bulit as per the Segment Defination and i am trying to insert 10 occurances of the segment but i have not tested it.Hope this helps.
Code:

       WORKING-STORAGE SECTION.                                         
       01 WS-CNT           PIC S9(04) COMP VALUE 1.                     
       01 WS-TIME          PIC X(06)  VALUE SPACES.
       01 WS-TEMP.                                                     
          02 WS-HH         PIC 9(02)  VALUE ZEROES.                     
          02 WS-MM         PIC 9(02)  VALUE ZEROES.                     
          02 WS-SS         PIC 9(02)  VALUE ZEROES.                       
       COPY XY1GGCPY.       
                                                                     
       PROCEDURE DIVISION.                                             
      ******************************************************************
      *                PROCEDURE DIVISION                              *
      ******************************************************************
      D    DISPLAY 'ENTRY INTO SHEKARPGM'.                               
                                                                       
           ACCEPT WS-TIME FROM TIME.                                   
           MOVE   WS-TIME TO   TS-CUR-TIME OF XY1GGCPY.                               
           CALL 'CBLTDLI' USING ISRT             
                                PCB1-XY0K11GG       
                                XY1GGCPY                         
                                SSA-XY1GGCPY-UNQUAL.

           PERFORM UNTIL WS-CNT > 9
              ACCEPT WS-TIME FROM TIME                                 

              EVALUATE TRUE                                             
                 WHEN WS-TIME(5:2) = '59' AND WS-TIME(3:2) = '59'         
                      MOVE WS-TIME(1:2) TO WS-HH                         
                      ADD  +1 TO WS-HH                                 
                      MOVE WS-HH TO WS-TIME(1:2)                         
                      MOVE '00' TO WS-TIME(3:2)                         
                      MOVE '00' TO WS-TIME(5:2)                         
                 WHEN WS-TIME(5:2) = '59'                               
                      MOVE WS-TIME(3:2) TO WS-MM                         
                      ADD  +1 TO WS-MM                                 
                      MOVE WS-MM TO WS-TIME(3:2)                         
                      MOVE '00' TO WS-TIME(5:2)                         
                 WHEN WS-TIME(3:2) = '59'                               
                      MOVE WS-TIME(1:2) TO WS-HH                         
                      ADD  +1 TO WS-HH                                 
                      MOVE WS-HH TO WS-TIME(1:2)                         
                      MOVE '00' TO WS-TIME(3:2)                         
              END-EVALUATE                                             

             MOVE   WS-TIME TO   TS-CUR-TIME OF XY1GGCPY                               
             CALL 'CBLTDLI' USING  ISRT             
                                   PCB1-XY0K11GG       
                                   XY1GGCPY             
                                   SSA-XY1GGCPY-UNQUAL                                                                         
              ADD +1 TO WS-CNT                                         
              INITIALIZE WS-TEMP                                       
              END-PERFORM.                                             
                                                                       
      D    DISPLAY 'EXIT FROM SHEKARPGM'.                                 
           STOP RUN.   

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message  
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Fri Jul 14, 2006 10:27 am    Post subject: Reply with quote

Hi Shekar,

Thank you very much for your time and the logic.

Do we have any fucntion or method by which we can eliminate the logic in Evaluate and End-Evaluate and obtain the result by just adding 1 to the time or may be in 2 or 3 steps.

Just Curious.
_________________
Tx
Digger
Back to top
View user's profile Send private message  
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Jul 14, 2006 11:00 am    Post subject: Reply with quote

Quote:

Do we have any fucntion or method by which we can eliminate the logic in Evaluate and End-Evaluate and obtain the result by just adding 1 to the time or may be in 2 or 3 steps.


Look at the language environment calls 'ceesecs' and 'ceedatm'

The link for the manual is

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3010/CCONTENTS

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website  
MFdigger
Beginner


Joined: 09 Sep 2005
Posts: 124
Topics: 52
Location: Chicago

PostPosted: Sat Jul 15, 2006 6:50 pm    Post subject: Reply with quote

Thank you Kolusu

8)
_________________
Tx
Digger
Back to top
View user's profile Send private message  
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Sun Jul 16, 2006 1:00 pm    Post subject: Reply with quote

Kolusu,

The link provided by you does not open up.Please help me out:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3010/CCONTENTS
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message  
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sun Jul 16, 2006 1:02 pm    Post subject: Reply with quote

shekar123 wrote:
Kolusu,

The link provided by you does not open up.Please help me out:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3010/CCONTENTS


Shekhar,

The link works fine for me. Do you have a POP-up Blocker? When you click on the link it opens the page in a new browser window.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website  
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group