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 

Is there any utility available to add time in cobol?

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


Joined: 10 Aug 2005
Posts: 11
Topics: 7

PostPosted: Mon Sep 26, 2005 5:49 am    Post subject: Is there any utility available to add time in cobol? Reply with quote

hi,
I want to add a constant parameter i.e. some hours, in the input date and time to get a new date and time in a batch program. Is there any utility available to achieve the same which can be used in a cobol program? [/quote]
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Mon Sep 26, 2005 6:15 am    Post subject: Reply with quote

First of all let us know about the RECFM and LRECL of your file and the hours format, number of digits, position from which you want to add etc.

I assume that your file is of length 80 and format is FB. The number of digits of hours which you want to add is 2 and the position is from 9 and the hours you want to add is 24.

The below sort card will add the characters 24 from 9th position(9th and 10th positions will be occupied).
Rest of the data will be copied as it is.

//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1:1,8,9:C'24',11:11,80)
/*
Back to top
View user's profile Send private message Send e-mail
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Sep 26, 2005 6:39 am    Post subject: Reply with quote

vkphani,

What I understand from DHL_MF_INFY's note is: he wants add some value 'x' to the date & time field.

for example, if my input file contains the following "09-26-2005-23.55.00.000000" then If I add 10 minutes to this, the new date-time value will be "09-27-2006-00.05.00.000000". But your code will concatenate '24' to the field thereby increasing the length.

DHL_MF_INFY, Let me know if I am wrong. If this is the case, why don't you code the logic to add the hours/minutes in the COBOL program directly. If you are going to add just the hours, then it will become a bit easy.

I am not sure if Language environment has an option to add date & time. I will have to find out.

Thanks,
Phantom
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Mon Sep 26, 2005 6:42 am    Post subject: Reply with quote

Hi Phantom,

You are correct. But the full info about the requirement is not given.
Back to top
View user's profile Send private message Send e-mail
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Sep 26, 2005 6:53 am    Post subject: Reply with quote

I agree with vkphani.

DHL_MF_INFY,

When you post a question, please make sure you provide the following information, so that we can get back with the accruate solutions on time.

1. RECFM
2. LRECL
3. Sample input
4. Sample output.

And above all, please utilize the search facility provided to you to see if similar questions are already posted. Most of them might have already been answered. This will cut down your turn-around time.

Thanks,
Phantom
Back to top
View user's profile Send private message
DHL_MF_INFY
Beginner


Joined: 10 Aug 2005
Posts: 11
Topics: 7

PostPosted: Mon Sep 26, 2005 6:54 am    Post subject: Reply with quote

Hi Phantom,
You got the point right. If at all I decide to code the same then I need to take care of things like Leap year and some other things into consideration like month change, year change etc. So just wanted to avoid cumbersome coding Smile

Thanks and Regards
DHL_MF_INFY
Back to top
View user's profile Send private message
DHL_MF_INFY
Beginner


Joined: 10 Aug 2005
Posts: 11
Topics: 7

PostPosted: Mon Sep 26, 2005 7:07 am    Post subject: Reply with quote

Well an apology for not giving the complete information.

The needed information is as below.

RECFM = FB
LRECL = 500
DSORG = PS
Input Date and Time format is CCYYMMDD and HHMM

Hope this is sufficient.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Sep 26, 2005 8:01 am    Post subject: Reply with quote

DHL_MF_INFY,

You can use the language environment calls "ceesecs" and "ceedatm" to acheive the desired results. You first need to convert the date-time to seconds and then add hours in seconds ex: 1 HOUR =(60 * 60 = 3600 SECONDS) . Now use CEEDATM to convert the second back to the normal character date-time format.

Try this code.

Code:

01 WS-SECONDS            COMP-2.                 
01 WS-OLD-TIMESTAMP      PIC X(16).             
01 WS-PICSTR.                                   
   02 WS-LEN             PIC S9(04) COMP.       
   02 WS-OUT-TEXT.                               
      03 WS-OUT-STR      PIC X                   
                         OCCURS 0 TO 256 TIMES   
                         DEPENDING ON WS-LEN.   
                                                 
01 WS-NEW-TIMESTAMP      PIC X(80).             
01 WS-FORMAT             PIC X(16).             
                                                 
01  WS-FC-CODE.                                 
    05 FC-SEVERITY              PIC S9(4) COMP. 
    05 FC-MESSAGE               PIC S9(4) COMP. 
    05 FILLER                   PIC X(08).       
                                                 
PROCEDURE DIVISION.                                         
                                                             
     MOVE '2005-09-26-23.35' TO WS-OLD-TIMESTAMP         
     MOVE 'YYYY-MM-DD-HH.MI' TO WS-FORMAT                 
                                                             
     CALL 'CEESECS' USING WS-OLD-TIMESTAMP,                 
                          WS-FORMAT,                         
                          WS-SECONDS,                       
                          WS-FC-CODE                         

     IF FC-SEVERITY = 00                                     
        DISPLAY 'THE DATE IN SECONDS IS : ' WS-SECONDS
        ADD +3600 TO WS-SECONDS                                 
        MOVE +16 TO WS-LEN                                     
        MOVE 'YYYY-MM-DD-HH.MI' TO WS-OUT-TEXT               
                                                             
        CALL 'CEEDATM' USING WS-SECONDS,                       
                             WS-PICSTR,                         
                             WS-NEW-TIMESTAMP,                 
                             WS-FC-CODE                         
                                                             
        IF FC-SEVERITY = 00                                     
           DISPLAY 'THE NEW TIMESTAMP IS : ' WS-NEW-TIMESTAMP   
        ELSE                                                   
           DISPLAY 'THE CEEDATM CALL FAILED WITH : ' FC-SEVERITY
        END-IF
     ELSE   
        DISPLAY 'THE CEESECS CALL FAILED WITH : ' FC-SEVERITY
     END-IF


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
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Sep 26, 2005 8:15 am    Post subject: Reply with quote

I don't know how I missed this.....We have already discussed this in the "Mainframe Challenge" Thread. I vaguely remembered that it is possible with LE, but didn't try to search here. Evil or Very Mad

http://www.mvsforums.com/helpboards/viewtopic.php?t=2261

Thanks,
Phantom
Back to top
View user's profile Send private message
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