View previous topic :: View next topic |
Author |
Message |
puttu Beginner
Joined: 29 Jul 2010 Posts: 41 Topics: 9
|
Posted: Tue Aug 10, 2010 10:55 am Post subject: absolute time to normal time |
|
|
Hi all,
I need a help...
I am having absolute time in input file.
I need to convert into normal time formal.
If any one knows, please send me the details.. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Tue Aug 10, 2010 11:20 am Post subject: |
|
|
puttu,
Is this absolute time field from CICS? if so you can use CICS to convert it into date and time.
Kolusu |
|
Back to top |
|
 |
puttu Beginner
Joined: 29 Jul 2010 Posts: 41 Topics: 9
|
Posted: Tue Aug 10, 2010 11:26 am Post subject: |
|
|
kolusu,
I heard, we can do in cobol program also....
please send me the details, if u know... |
|
Back to top |
|
 |
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Tue Aug 10, 2010 3:35 pm Post subject: |
|
|
I found this on another board - Credit goes to users Mushware and Bill O'Boyle. It's designed as a COBOL Main Module, but you should be able to easily convert it to be used as either a CALLed module or PERFORMed subroutine.
Code: | IDENTIFICATION DIVISION.
PROGRAM-ID. MSECSCVT.
*
* CONVERT A CICS 'ABSTIME' MILLISECOND TIME STAMP TO A FORMAT
* OF 'CCYYMMDD' AND 'HHMMSS', IN BATCH.
*
* THIS PROGRAM USES THE LE CALLABLE SERVICE ROUTINES 'CEEDAYS'
* AND 'CEEDATE'.
*
* THE FORMAT OF THE 'ACCEPT' CARD IS -
*
* POS 01-15 - MILLISECOND VALUE IN DISPLAY NUMERIC
* POS 16-16 - A SPACE
* POS 17-25 - WHAT THE 'CCYYMMDD' SHOULD BE
* POS 26-26 - A '/'
* POS 27-32 - WHAT THE 'HHMMSS' SHOULD BE
*
* EXAMPLE:
*
* 003345222551440 20060102/202911
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATA.
03 WS-ACCEPT-CARD.
05 WS-ACCEPT-MSECS PIC 9(015).
05 FILLER PIC X(001).
05 WS-ACCEPT-SHOULD-BE PIC X(015).
05 FILLER PIC X(049).
03 WS-WORK-LILIAN PIC 9(008) BINARY.
03 WS-ORIG-MSECS PIC 9(015) PACKED-DECIMAL.
03 WS-ORIG-MSECS-X REDEFINES WS-ORIG-MSECS
PIC X(008).
03 WS-DBLWORD PIC 9(015) PACKED-DECIMAL.
03 WS-CALC-SECS PIC 9(015) PACKED-DECIMAL.
03 WS-WORK-DISPLAY PIC 9(008).
03 WS-TIME-HHMMSS PIC 9(006).
03 FILLER REDEFINES WS-TIME-HHMMSS.
05 WS-TIME-HH PIC 9(002).
05 WS-TIME-MM PIC 9(002).
05 WS-TIME-SS PIC 9(002).
03 WS-DISPLAY-MSG PIC X(080).
03 WS-CEEDAYS PIC X(008).
03 WS-CEEDAYS-DATE PIC X(010).
03 WS-CEEDAYS-PICTURE PIC X(010).
03 WS-CEEDAYS-LILIAN PIC 9(008) BINARY.
03 WS-CEEDAYS-FEEDBACK PIC X(012).
03 WS-CEEDATE PIC X(008).
03 WS-CEEDATE-DATE PIC X(080).
03 WS-CEEDATE-PICTURE PIC X(010).
03 WS-CEEDATE-LILIAN PIC 9(008) BINARY.
03 WS-CEEDATE-FEEDBACK PIC X(012).
*
PROCEDURE DIVISION.
*
MOVE LOW-VALUES TO WS-DATA (1:256).
MOVE WS-DATA (1:) TO WS-DATA (257:).
*
ACCEPT WS-ACCEPT-CARD.
*
DISPLAY SPACE.
*
DISPLAY 'WS-ACCEPT-CARD ===> ', WS-ACCEPT-CARD.
*
DISPLAY SPACE.
*
MOVE WS-ACCEPT-MSECS TO WS-ORIG-MSECS.
DIVIDE WS-ORIG-MSECS BY 86400000
GIVING WS-WORK-DISPLAY.
MOVE WS-WORK-DISPLAY TO WS-WORK-LILIAN.
MOVE X'08' TO WS-CEEDAYS-DATE (02:01).
MOVE X'08' TO WS-CEEDAYS-PICTURE (02:01).
MOVE 'YYYYMMDD' TO WS-CEEDAYS-PICTURE (03:).
MOVE 'CEEDAYS ' TO WS-CEEDAYS.
MOVE '19000101' TO WS-CEEDAYS-DATE (03:).
*
CALL WS-CEEDAYS USING WS-CEEDAYS-DATE,
WS-CEEDAYS-PICTURE,
WS-CEEDAYS-LILIAN,
WS-CEEDAYS-FEEDBACK.
*
MULTIPLY WS-WORK-DISPLAY BY 86400000
GIVING WS-DBLWORD.
SUBTRACT WS-DBLWORD FROM WS-ORIG-MSECS
GIVING WS-CALC-SECS.
DIVIDE WS-CALC-SECS BY 1000
GIVING WS-CALC-SECS.
*
IF WS-ORIG-MSECS-X (7:1) GREATER THAN X'49'
ADD 1 TO WS-CALC-SECS
END-IF.
*
DIVIDE WS-CALC-SECS BY 3600
GIVING WS-TIME-HH.
MULTIPLY WS-TIME-HH BY 3600
GIVING WS-DBLWORD.
SUBTRACT WS-DBLWORD FROM WS-CALC-SECS.
DIVIDE WS-CALC-SECS BY 60
GIVING WS-TIME-MM.
MULTIPLY WS-TIME-MM BY 60
GIVING WS-DBLWORD.
SUBTRACT WS-DBLWORD FROM WS-CALC-SECS
GIVING WS-TIME-SS.
ADD WS-WORK-LILIAN TO WS-CEEDAYS-LILIAN
GIVING WS-CEEDATE-LILIAN.
MOVE WS-CEEDAYS-PICTURE TO WS-CEEDATE-PICTURE.
MOVE 'CEEDATE ' TO WS-CEEDATE.
*
CALL WS-CEEDATE USING WS-CEEDATE-LILIAN,
WS-CEEDATE-PICTURE,
WS-CEEDATE-DATE,
WS-CEEDATE-FEEDBACK.
*
MOVE 'DATE/TIME IS =====> /'
TO WS-DISPLAY-MSG.
MOVE WS-CEEDATE-DATE TO WS-DISPLAY-MSG (21:08).
MOVE WS-TIME-HHMMSS (01:) TO WS-DISPLAY-MSG (30:06).
*
DISPLAY WS-DISPLAY-MSG.
*
MOVE 'SHOULD BE ========> ' TO WS-DISPLAY-MSG (01:20).
MOVE WS-ACCEPT-SHOULD-BE TO WS-DISPLAY-MSG (21:15).
*
DISPLAY SPACE.
*
DISPLAY WS-DISPLAY-MSG.
*
DISPLAY SPACE.
*
GOBACK. |
_________________ A computer once beat me at chess, but it was no match for me at kick boxing. |
|
Back to top |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Tue Aug 10, 2010 3:55 pm Post subject: |
|
|
There was a reson to ask this multiple times?
Additional replies have been made to the "other" one. . .  _________________ All the best,
di |
|
Back to top |
|
 |
puttu Beginner
Joined: 29 Jul 2010 Posts: 41 Topics: 9
|
Posted: Tue Aug 10, 2010 10:01 pm Post subject: |
|
|
Hi,
First of all i need to tell excellent code.
Coming to point above code is working fine.
But when i'm running a time missmatch i found.
ex: this format i need to get : 20060102/202911
but i'm getting : 20060102 850904
Please suggest me .... wt to do..? |
|
Back to top |
|
 |
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Wed Aug 11, 2010 6:51 am Post subject: |
|
|
1. Did you run the program as a "main" program? If so, please show the ENTIRE output - which will show both the input and output values. From your posting, it would appear that your INPUT was not EXACTLY the same as provided in the example embedded within the program code provided.
2. Is your "problem" in the FORMAT or the CONTENT of the result? I.E. are you concerned because the date and time are separated by a space instead of a slash? _________________ A computer once beat me at chess, but it was no match for me at kick boxing. |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Wed Aug 11, 2010 10:03 am Post subject: |
|
|
Running the program as-is I got...
Code: | WS-ACCEPT-CARD ===> 003345222551440 20060102/202911
DATE/TIME IS =====> 20060102 202911
SHOULD BE ========> 20060102/202911 |
so the only difference from expected output is that the program split date and time by a space whereas the 'SHOULD BE' line indicates that the split character should be '/' so I guess the moving of '/' to the appropriate place in the output line was not done. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Wed Aug 11, 2010 10:38 am Post subject: |
|
|
@all
The code I posted was cut/aligned/pasted from another board and was NOT posted there enclosed with nice code tags - so multiple spaces appeared in the post as only one space - hence the unfortunate mis-alignment for one of the DISPLAYed messages.
The lines
Code: |
MOVE 'DATE/TIME IS =====> /'
TO WS-DISPLAY-MSG. |
should more properly be
Code: | MOVE 'DATE/TIME IS =====> /'
TO WS-DISPLAY-MSG. |
namely, 8 additional spaces between the > and /
Sorry about that. _________________ A computer once beat me at chess, but it was no match for me at kick boxing. |
|
Back to top |
|
 |
puttu Beginner
Joined: 29 Jul 2010 Posts: 41 Topics: 9
|
Posted: Wed Aug 11, 2010 11:52 am Post subject: |
|
|
Hi RonB,
Thanks a lot.....
Code worked fine.....
Excellent!!!!
Rgds,
Puttu |
|
Back to top |
|
 |
puttu Beginner
Joined: 29 Jul 2010 Posts: 41 Topics: 9
|
Posted: Thu Aug 12, 2010 1:49 am Post subject: |
|
|
Hi RonB,
I have a small doubt.
The code which you have given we are getting in the format YYYYMMDDHHMMSS.
If i need to get milli seconds also.... what i need to do..?
Please suggest me...
Rgds,
Puttu |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Aug 12, 2010 2:29 am Post subject: |
|
|
Convert your answer back to milliseconds, subtract from the original input (which is milliseconds) and the difference should be the number of milliseconds rounded off. take this difference and tack it on to the end of your initial answer. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Thu Aug 12, 2010 7:57 am Post subject: |
|
|
Well, first you need to understand that the routine, as coded, will ROUND the answer to the nearest SECOND - so if you want milliseconds you will have to NOT do the rounding, else you will end up with the wrong result. Therefore, change this:
Code: | MULTIPLY WS-WORK-DISPLAY BY 86400000
GIVING WS-DBLWORD.
SUBTRACT WS-DBLWORD FROM WS-ORIG-MSECS
GIVING WS-CALC-SECS.
DIVIDE WS-CALC-SECS BY 1000
GIVING WS-CALC-SECS.
*
IF WS-ORIG-MSECS-X (7:1) GREATER THAN X'49'
ADD 1 TO WS-CALC-SECS
END-IF. |
to this:
Code: | MULTIPLY WS-WORK-DISPLAY BY 86400000
GIVING WS-DBLWORD.
SUBTRACT WS-DBLWORD FROM WS-ORIG-MSECS.
DIVIDE WS-ORIG-MSECS BY 1000
GIVING WS-CALC-SECS
REMAINDER WS-ORIG-MSECS. |
After this change, the result will NOT be rounded to the nearest SECOND, and the number of excess milliseconds will be in the field named WS-ORIG-MSECS. _________________ A computer once beat me at chess, but it was no match for me at kick boxing. |
|
Back to top |
|
 |
|
|