Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Date Validation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Raja12752

New User


Joined: 18 Jul 2006
Posts: 28

PostPosted: Wed Dec 05, 2007 11:21 am    Post subject: Date Validation
Reply with quote

Hi,

Thru Onlines i am receiving a date string of length 10 i.e. X(10). {In format DD/MM/YYYY}

In cobol program i need to validate whether the received/entered value is valid date or not?



Thanks,
Raja.
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Dec 05, 2007 12:05 pm    Post subject:
Reply with quote

Hi,

So are you facing some problem with your code or you need the pseudo code to start with?
Back to top
View user's profile Send private message
donevin

New User


Joined: 07 Jun 2005
Posts: 70
Location: South Africa

PostPosted: Wed Dec 05, 2007 12:09 pm    Post subject:
Reply with quote

How about, if the rundate is in the format ddmmccyyy then:

Code:
If Online-Date (1:2) not = Rundate (1:2) or
   Online-Date (4:2) not = Rundate (3:2) or
   Online-Date (7:4) not = Rundate (5:4)
      Display "Invalid date"
      Perform Abort
End-if.
Back to top
View user's profile Send private message
Raja12752

New User


Joined: 18 Jul 2006
Posts: 28

PostPosted: Wed Dec 05, 2007 2:31 pm    Post subject: Reply to: Date Validation
Reply with quote

I couldn't get the Rundate function.
Will it return the todays date?

Please explain me more details about Rundate function.

Thanks,
Pavan.
Back to top
View user's profile Send private message
neeraj_pathak26

New User


Joined: 02 Jun 2006
Posts: 7

PostPosted: Wed Dec 05, 2007 3:03 pm    Post subject: Reply to: Date Validation
Reply with quote

Hi,
I am not sure about the function RUNDATE. But I feel u can use FUNCTION CURRENT-DATE. It will give you the the current date and time in yyyymmddhhmmsshhxhhmm format. This you can mold to your validation date.
Hope it helps, and if any one knows about Function Rundate, Please discuss.
Back to top
View user's profile Send private message
Raja12752

New User


Joined: 18 Jul 2006
Posts: 28

PostPosted: Wed Dec 05, 2007 3:09 pm    Post subject:
Reply with quote

Thanks for your responses.

I am more concerned about the entered value is a Valid date or not in terms of normal year & Leap Year.

For that if any built in function available means, would like to know function name and arguments details.

If not any pre defined algorithm to include in my program.

Please share me incase anyone having solution.
Thanks,
Pavan.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Dec 05, 2007 4:16 pm    Post subject:
Reply with quote

Hi,

Quote:
I couldn't get the Rundate function.

donevin has given an example of reference modifiers, online-date/ run-date are COBOL variables & not some intrinsic functions.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Dec 05, 2007 9:30 pm    Post subject:
Reply with quote

Hello,

Quote:
In cobol program i need to validate whether the received/entered value is valid date or not?
Then you need to write code to accomplish the validation or use some alredy existing date-validation routine that is used on your system.

Many (most?) systems have a callable date-validation routine that is used for all date validation. This way the code is only written once and is consistent across all progams.

For the discussion about comparing the "online" date against the current/run date - i do not believe the requirement says anything about doing this, only to check if the input date is valid or not.
Back to top
View user's profile Send private message
Raja12752

New User


Joined: 18 Jul 2006
Posts: 28

PostPosted: Fri Dec 07, 2007 10:05 am    Post subject:
Reply with quote

FYI - Manually coded and got the result.

Coding is.....

Working Storage Section onwards......
000500 000500 01 WS-INPUT-DATA.
000600 000600 02 WS-INPUT-DATE PIC X(10).
000700 000700 02 WS-RESULT PIC 9(01).
000800 000800 01 WS-TEMP-DATE PIC X(10).
000900 000900 01 WS-DATE REDEFINES WS-TEMP-DATE.
001000 001000 02 WS-DAY PIC 9(02).
001100 001100 88 DAY-31 VALUE 1 THRU 31.
001200 001200 88 DAY-30 VALUE 1 THRU 30.
001300 001300 88 DAY-29 VALUE 1 THRU 29.
001400 001400 88 DAY-28 VALUE 1 THRU 28.
001500 001500 02 FILLER PIC X.
001600 001600 02 WS-VALID-MONTH PIC 9(02).
001700 001700 88 JAN VALUE 01.
001800 001800 88 FEB VALUE 02.
001900 001900 88 MAR VALUE 03.
002000 002000 88 APR VALUE 04.
002100 002100 88 MAY VALUE 05.
002200 002200 88 JUN VALUE 06.
002300 002300 88 JUL VALUE 07.
002400 002400 88 AUG VALUE 08.
002500 002500 88 SEP VALUE 09.
002600 002600 88 OCT VALUE 10.
002700 002700 88 NOV VALUE 11.
002800 002800 88 DEC VALUE 12.
002900 002900 88 VALID-MONTH VALUE 01 THRU 12.
003000 003000 88 NOT-VALID-MONTH VALUE 13 THRU 99.
003100 003100 02 FILLER PIC X.
003200 003200 02 WS-YEAR PIC 9(04).
003300 003300 88 WS-YEAR-VALID VALUE 1950 THRU 2050.
003400 003400 01 WS-QUOTIENT PIC 9(04).
003500 003500 01 WS-REMAINDER PIC 9(02).
003600 003600 88 ZERO-YES VALUE 0.
003700 003700 88 ZERO-NO VALUE 1 THRU 10.
003800 003800 01 WS-LEAP PIC 9(01).
003900 003900 88 LEAP-YEAR VALUE 0.
004000 004000 88 NON-LEAP-YEAR VALUE 1.
004100 004100 LINKAGE SECTION.
004200 004200 01 LK-COMM.
004300 004300 02 LK-DATE PIC X(10).
004400 004400 02 LK-RESULT PIC 9(01).
004500 004500 PROCEDURE DIVISION USING LK-COMM.
004600 004600 MOVE LK-COMM TO WS-INPUT-DATA.
004700 004700 MOVE WS-INPUT-DATE TO WS-TEMP-DATE.
004800 004800 IF WS-YEAR NOT = ZERO AND WS-YEAR-VALID
004900 004900 COMPUTE WS-REMAINDER =
005000 005000 FUNCTION MOD ( WS-YEAR , 4 )
005200 005200 IF ZERO-YES
005300 005300 SET LEAP-YEAR TO TRUE
005400 005400 ELSE
005500 005500 SET NON-LEAP-YEAR TO TRUE
005600 005600 END-IF
007100 007100 IF VALID-MONTH
007200 007200 IF ( JAN AND DAY-31 ) OR
007300 007300 ( FEB AND LEAP-YEAR AND DAY-29 ) OR
007400 007400 ( FEB AND NON-LEAP-YEAR AND DAY-28 ) OR
007500 007500 ( MAR AND DAY-31 ) OR
007600 007600 ( APR AND DAY-30 ) OR
007700 007700 ( MAY AND DAY-31 ) OR
007800 007800 ( JUN AND DAY-30 ) OR
007900 007900 ( JUL AND DAY-31 ) OR
008000 008000 ( AUG AND DAY-31 ) OR
008100 008100 ( SEP AND DAY-30 ) OR
008200 008200 ( OCT AND DAY-31 ) OR
008300 008300 ( NOV AND DAY-30 ) OR
008400 008400 ( DEC AND DAY-31 )
008500 008500 MOVE 0 TO WS-RESULT
008700 008700 ELSE
008800 008800 MOVE 1 TO WS-RESULT
009000 009000 END-IF
009100 009100 ELSE
009200 009200 MOVE 1 TO WS-RESULT
009400 009400 END-IF
009500 009500 ELSE
009600 009600 MOVE 1 TO WS-RESULT
009700 009700 END-IF.
009900 009900 MOVE WS-RESULT TO LK-RESULT.
010000 010000 EXIT PROGRAM.
****** **************************** Bottom of Data
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate the Date girishb2 DFSORT/ICETOOL 8 Tue Sep 19, 2017 1:12 am
No new posts Julian Date to CICS ABSTTIME blayek CICS 3 Wed Aug 30, 2017 11:15 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us