View previous topic :: View next topic |
Author |
Message |
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Wed Jul 12, 2006 3:17 pm Post subject: Time Stamp |
|
|
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 |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Jul 13, 2006 1:19 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Jul 13, 2006 6:56 am Post subject: |
|
|
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 |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Jul 13, 2006 8:08 am Post subject: |
|
|
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 |
|
|
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Thu Jul 13, 2006 11:12 am Post subject: |
|
|
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 |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Jul 13, 2006 11:26 am Post subject: |
|
|
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 |
|
|
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Thu Jul 13, 2006 1:29 pm Post subject: |
|
|
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 |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Jul 13, 2006 11:32 pm Post subject: |
|
|
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 |
|
|
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Fri Jul 14, 2006 10:27 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
MFdigger Beginner
Joined: 09 Sep 2005 Posts: 124 Topics: 52 Location: Chicago
|
Posted: Sat Jul 15, 2006 6:50 pm Post subject: |
|
|
Thank you Kolusu
8) _________________ Tx
Digger |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Jul 16, 2006 1:02 pm Post subject: |
|
|
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 |
|
|
|
|