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 

Yesterday's date in VS Cobol - II

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


Joined: 15 Jun 2005
Posts: 12
Topics: 7

PostPosted: Thu Jan 12, 2006 5:23 am    Post subject: Yesterday's date in VS Cobol - II Reply with quote

Hi,

I want to process the data from a file based on DATE Validation. The DATE inside the file if equal to yesterdays date then i have to process.

Can some one tell me how to find yesterdays date in the cobolII

The date format in the input file is YYYYMMDD.

Thanks
Bobi
Back to top
View user's profile Send private message
bobi
Beginner


Joined: 15 Jun 2005
Posts: 12
Topics: 7

PostPosted: Thu Jan 12, 2006 5:50 am    Post subject: Reply with quote

Hi ,

I'm using VS COBOL II, forgot to mention it.

Thanks
bobi
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: Thu Jan 12, 2006 9:19 am    Post subject: Reply with quote

Bobi,

Try this code.

Code:

WORKING-STORAGE SECTION.                               
                                                       
01 WS-CURR-DATE.                                       
   05 WS-CURR-CC            PIC 9(02) VALUE 20.       
   05 WS-CURR-YYMMDD.                                 
      10 WS-CURR-YY         PIC 9(02).                 
      10 WS-CURR-MM         PIC 9(02).                 
      10 WS-CURR-DD         PIC 9(02).                 
                                                       
01 WS-PREV-DATE.                                       
   05 WS-PREV-CC            PIC 9(02) VALUE 20.       
   05 WS-PREV-YYMMDD.                                 
      10 WS-PREV-YY         PIC 9(02).                 
      10 WS-PREV-MM         PIC 9(02).                 
      10 WS-PREV-DD         PIC 9(02).                 
                                                       
01 WS-GREG-CCYY.                                       
   05 WS-GREG-CC            PIC 9(02) VALUE 20.       
   05 WS-GREG-YY            PIC 9(02).                 
                                                       
01 WS-CURR-YEAR REDEFINES WS-GREG-CCYY PIC 9(04).     
                                                       
01  WS-LEAP-YR-SWITCH       PIC X.                     
    88 ITS-A-LEAP-YR        VALUE 'Y'.                 
    88 ITS-NOT-A-LEAP-YR    VALUE 'N'.                 
                                                       
01 WS-MONTH-END-DD          PIC X(24) VALUE           
                            '312831303130313130313031'.
01 WS-TBL-MONTH-END REDEFINES WS-MONTH-END-DD.         
    05 TBL-MONTH-END-DAY    PIC 9(02) OCCURS 12 TIMES.
                                                       

01 WS-REMAINDERS.                             
   05 WS-QUOT               PIC 9(01).         
   05 WS-4-REM              PIC S9(01) COMP.   
      88 DIVISIBLE-BY-4     VALUE +0.         
   05 WS-100-REM            PIC S9(02) COMP.   
      88 DIVISIBLE-BY-100   VALUE +0.         
   05 WS-400-REM            PIC S9(03) COMP.   
      88 DIVISIBLE-BY-400   VALUE +0.         

PROCEDURE DIVISION.                                       
                                                           
    ACCEPT WS-CURR-YYMMDD FROM DATE                       
    COMPUTE WS-PREV-DD = WS-CURR-DD - 1                   
    MOVE WS-CURR-YY  TO WS-GREG-YY WS-PREV-YY             
                                                           
    IF WS-PREV-DD = 0                                     
       EVALUATE WS-CURR-MM                                 
           WHEN 1                                         
                COMPUTE WS-PREV-YY = WS-CURR-YY - 1       
                MOVE 12  TO WS-PREV-MM                     
           WHEN 3                                         
                COMPUTE WS-PREV-MM = WS-CURR-MM - 1       
                PERFORM 1000-LEAP-YEAR-CHECK               
           WHEN OTHER                                     
                COMPUTE WS-PREV-MM = WS-CURR-MM - 1       
       END-EVALUATE                                       
                                                           
       IF ITS-A-LEAP-YR                                   
          MOVE 29   TO WS-PREV-DD                         
       ELSE                                               
          MOVE TBL-MONTH-END-DAY(WS-PREV-MM) TO WS-PREV-DD
       END-IF                                             
    ELSE                                                   
       MOVE WS-CURR-MM  TO WS-PREV-MM                     
    END-IF                                                 
                                                           
    DISPLAY 'THE CURRENT DATE IS : ' WS-CURR-DATE         
    DISPLAY 'THE PREVIOUS DATE IS: ' WS-PREV-DATE         
    GOBACK                                                 
    .                                                     
                                                           
1000-LEAP-YEAR-CHECK.                               
                                                   
    SET ITS-NOT-A-LEAP-YR TO TRUE                   
                                                   
    DIVIDE WS-CURR-YEAR BY  +4   GIVING  WS-QUOT   
           REMAINDER WS-4-REM                       
                                                   
    DIVIDE WS-CURR-YEAR BY  +100 GIVING  WS-QUOT   
           REMAINDER WS-100-REM                     
                                                   
    DIVIDE WS-CURR-YEAR BY  +400 GIVING  WS-QUOT   
           REMAINDER WS-400-REM                     
                                                   
    IF DIVISIBLE-BY-400 OR                         
      (DIVISIBLE-BY-4 AND NOT DIVISIBLE-BY-100)     
         SET ITS-A-LEAP-YR  TO TRUE                 
    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
German Castillo
Beginner


Joined: 23 Dec 2005
Posts: 83
Topics: 2
Location: Caracas, Venezuela

PostPosted: Thu Jan 12, 2006 10:07 am    Post subject: Reply with quote

adding on to Kolusus' post, and as an Alternative, LE can be called to do so
like :

Code:

          CALL "CEEDAYS" using WS-TODAY, MY-PICTURE,
                WS-LILIAN, WS-FC

          SUBTRACT 1 FROM WS-LILIAN


          CALL "CEEDATE" using WS-LILIAN, MY-PICTURE,
               WS-YESTERDAY, WS-FC



Use the date picture you want to, Like MM/DD/YYYY (as a char string), WS_LILIAN should be a S9(9) Binary, and if you really do not want to check the callable services RC, Define WS-FC a bit large, else COPY the area CEEIGZCT and append to it around 30 bytes. For the proper format of the comunication area look under LE Programming Reference manual. I you are using Current date as your input, you shouldn't have any big problem.
_________________
Best wishes,

German Castillo
Back to top
View user's profile Send private message
bobi
Beginner


Joined: 15 Jun 2005
Posts: 12
Topics: 7

PostPosted: Fri Jan 13, 2006 1:56 am    Post subject: Reply with quote

Hi Kolusu,
Thanks for the code.

Hi Castillo,

I have tried with your code but the out put WS-LILIAN is displaying as zero.
i have declared WS-LILIAN S9(9) BINARY.

Can you please help me on this.

Thanks
bobi
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: Fri Jan 13, 2006 5:21 am    Post subject: Reply with quote

bobi,

The LE callable service CEEDAYS--Convert date to Lilian format is explained in detail here with examples.


http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3130/3.5.24?SHELF=&DT=20020625092930&CASE=

The LE callable service CEEDATE--Convert Lilian date to character format is explained in detail here with examples.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3130/3.5.22?SHELF=&DT=20020625092930&CASE=

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
German Castillo
Beginner


Joined: 23 Dec 2005
Posts: 83
Topics: 2
Location: Caracas, Venezuela

PostPosted: Fri Jan 13, 2006 12:33 pm    Post subject: Reply with quote

Hello bobi,

All the variable length fields have to be prefixed with its lengh as a half-word. That is, pictures, and date themselves, this is sorta standard in variable length field usage, at least for a vast deal of common utilities. You need to do something like:

Code:

          01 MY-PICTURE.
               05 MY-PICTURE-LENGHT       PIC S9(04) COMP.
               05 MY-PICTURE-DATA           PIC X(80).
          01 WS-TODAY.
               05 WS-TODAY-LENGTH          PIC S9(04) COMP.
               05 WS-TODAY-DATA             PIC X(80).


Likewaise for ws-yesterday, just be sure to populate both Data and lengths. or follow the Above links for good samples.
_________________
Best wishes,

German Castillo
Back to top
View user's profile Send private message
haatvedt
Beginner


Joined: 14 Nov 2003
Posts: 66
Topics: 0
Location: St Cloud, Minnesota USA

PostPosted: Sun Jan 15, 2006 2:38 am    Post subject: Reply with quote

Bobi,

I would suggest that you first check to see if your shop has a "inhouse date routine". Every shop that I have worked for has had one. Our standard date routine has the ability to check the JCL for a certain DDNAME and accept an override for the current date if it is present.

The problem with using the System Intrinsic is that if you have to rerun the job for some reason later (on a different day), it is very difficult to modify the system date.

Chuck H.
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
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