|
Hello, Please find the requested document as attachment. I have sent the Zip version also for your convenience. Regards, -----Original Message----- From: cobol400-l-bounces@xxxxxxxxxxxx [mailto:cobol400-l-bounces@xxxxxxxxxxxx] Sent: Wednesday, April 13, 2005 12:38 PM To: COBOL Programming on the iSeries/AS400 Subject: RE: [COBOL400-L] how to validate date in cobol400 Hi!!! can re-send the attached word document, i haven't received it, iam using microsoft outlook, and they restrict incoming *.exe files, i dont know if *.doc is also restricted. please send it in *.txt, which is allowed or just paste it in the message box. WILSON MANY THANKS!!! GODBLESS!!! -----Original Message----- From: cobol400-l@xxxxxxxxxxxx [mailto:cobol400-l@xxxxxxxxxxxx] Sent: Friday, April 08, 2005 7:42 PM To: COBOL Programming on the iSeries/AS400 Subject: RE: [COBOL400-L] how to validate date in cobol400 Importance: High Hello Wilson, Please find a procedure in the attached word document. We use this common procedure to validate any type of dates in our application. All we do is move the screen filed/database file field (namely,date field) to a temporary variable WS-T-VALIDATION DATE (of type and length 8S0). This variable WS-T-VALIDATION-DATE should be sent in the format DDMMYYYY. (Hint: Use some temporary numeric data structures and pass the date to be validated in DDMMYYYY format.) The rest of the processing will be taken care of by the procedure. Take care to declare the following variables in the working storage section: 01 WS-T-VALIDATE-DATE. 05 WS-T-VALIDATE-YEAR PIC 9(4). 05 WS-T-VALIDATE-MONTH PIC 9(2). 05 WS-T-VALIDATE-DAY PIC 9(2). 01 WS-T-VALIDATE-DATE-II. 05 WS-T-VALIDATE-DAY-II PIC 9(2). 05 WS-T-VALIDATE-MONTH-II PIC 9(2). 05 WS-T-VALIDATE-YEAR-II PIC 9(4). 01 WS-T-VALIDATION-YEAR. 05 WS-T-VALID-MONTH-DAY PIC 9(6). 05 WS-T-VALID-SHRT-YER PIC 9(2). 05 WS-T-VALID-SHRT-YER PIC 9(2). 01 WS-T-VALID-CENT. 05 WS-T-VALID-CENT-MTH-DAY PIC 9(4). 05 WS-T-VALID-CENT-CENT PIC 9(2). 05 WS-T-VALID-CENT-YEAR PIC 9(2). 01 WS-T-SYSTEM-DATE PIC 9(6). 01 WS-T-VALIDATION-DATE PIC 9(8). 01 WS-T-QUOTIENT PIC 9(3) COMP-3. 01 WS-T-REMAINDER PIC 9(1) COMP-3. We have a flag WS-T-VALIDATION-ERROR-FLAG to track any errors down the line. Initialize this flag to blanks. Invoke the routine in the attachment. If there is error, WS-T-VALIDATION-ERROR-FLAG will be set on. Hope this helps you... Regards, -----Original Message----- From: cobol400-l-bounces@xxxxxxxxxxxx [mailto:cobol400-l-bounces@xxxxxxxxxxxx] Sent: Friday, April 08, 2005 4:37 PM To: Cobol400-L@Midrange. Com (E-mail) Subject: [COBOL400-L] how to validate date in cobol400 hi all!! how do we validate differents formats of dates, especially iso format(yyyy/mm/dd). TIA!!! GODBLESS!!! Wilson _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l. ************************************************************************** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ************************************************************************** _______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l. ************************************************************************** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. **************************************************************************
/ ******************************************************************** * SUBROUTINE IDENTIFICATION * * * * SUBROUTINE NAME: VALIDATE-DATE SUBROUTINE NUMBER: 6000 * * * * Subroutine Description: * * * * THIS ROUTINE VALIDATES THE DATE. THE DATE IS EXPECTED * * IN WS-T-VALIDATE-DATE. IT IS CHECKED FOR SIX OR EIGHT CHATACTERS * * AND THE CENTURY IS ADDED IF SIX. THEN THE YEAR, MONTH, AND DAY * * ARE CHECKED FOR FEASABILITY. IT SETS THE WS-VALIDATION-ERROR-FLAG* ******************************************************************** 6000-VALIDATE-DATE. MOVE WS-C-FLAG-OFF TO WS-T-VALIDATION-ERROR-FLAG. * * Century * --------------- IF WS-T-VALIDATION-DATE < 1000000 MOVE WS-T-VALIDATION-DATE TO WS-T-VALIDATION-YEAR IF WS-T-VALID-SHRT-YER < 50 MOVE 20 TO WS-T-VALID-CENT-CENT ELSE MOVE 19 TO WS-T-VALID-CENT-CENT END-IF MOVE WS-T-VALID-MONTH-DAY TO WS-T-VALID-CENT-MTH-DAY MOVE WS-T-VALID-SHRT-YER TO WS-T-VALID-CENT-YEAR ELSE MOVE WS-T-VALIDATION-DATE TO WS-T-VALID-CENT. MOVE WS-T-VALID-CENT TO WS-T-VALIDATE-DATE-II. * * Year * --------------------------------------------- IF (WS-T-VALIDATE-YEAR-II < 1910) OR (WS-T-VALIDATE-YEAR-II > 2100) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG. * * Month * --------------------------------------- IF WS-T-VALIDATION-ERROR-FLAG = WS-C-FLAG-OFF IF (WS-T-VALIDATE-MONTH-II < 1) OR (WS-T-VALIDATE-MONTH-II > 12) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG. * * Days * --------------------------------------------------------------- IF WS-T-VALIDATION-ERROR-FLAG = WS-C-FLAG-OFF IF (WS-T-VALIDATE-MONTH-II = 1) OR (WS-T-VALIDATE-MONTH-II = 3) OR (WS-T-VALIDATE-MONTH-II = 5) OR (WS-T-VALIDATE-MONTH-II = 7) OR (WS-T-VALIDATE-MONTH-II = 8) OR (WS-T-VALIDATE-MONTH-II = 10) OR (WS-T-VALIDATE-MONTH-II = 12) IF (WS-T-VALIDATE-DAY-II < 1) OR (WS-T-VALIDATE-DAY-II > 31) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG. * Days * ------------------------------------------------------ IF WS-T-VALIDATION-ERROR-FLAG = WS-C-FLAG-OFF IF (WS-T-VALIDATE-MONTH-II = 4) OR (WS-T-VALIDATE-MONTH-II = 6) OR (WS-T-VALIDATE-MONTH-II = 9) OR (WS-T-VALIDATE-MONTH-II = 11) IF (WS-T-VALIDATE-DAY-II < 1) OR (WS-T-VALIDATE-DAY-II > 30) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG. * Leap year * ----------------------------------------------------------------- IF WS-T-VALIDATION-ERROR-FLAG = WS-C-FLAG-OFF Y2K IF (WS-T-VALID-CENT-YEAR NOT = 0) AND Y2K (WS-T-VALID-CENT-CENT NOT = 20) IF (WS-T-VALID-CENT-YEAR = 0) AND (WS-T-VALIDATE-MONTH-II = 2) * MOVE ZEROS TO WS-T-QUOTIENT * MOVE ZEROS TO WS-T-REMAINDER DIVIDE WS-T-VALID-CENT-CENT BY 4 GIVING WS-T-QUOTIENT REMAINDER WS-T-REMAINDER IF WS-T-REMAINDER = 0 IF (WS-T-VALIDATE-DAY-II < 1) OR (WS-T-VALIDATE-DAY-II > 28) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG END-IF END-IF Y2K END-IF END-IF END-IF. * *February leap year * --------------------------------------------------------------- IF WS-T-VALIDATION-ERROR-FLAG = WS-C-FLAG-OFF IF (WS-T-VALIDATE-MONTH-II = 2) * MOVE ZEROS TO WS-T-QUOTIENT * MOVE ZEROS TO WS-T-REMAINDER DIVIDE WS-T-VALIDATE-YEAR-II BY 4 GIVING WS-T-QUOTIENT REMAINDER WS-T-REMAINDER IF WS-T-REMAINDER = 0 IF (WS-T-VALIDATE-DAY-II < 1) OR (WS-T-VALIDATE-DAY-II > 29) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG END-IF ELSE * * February non-leap-year * ------------------------------------------------------------------- IF (WS-T-VALIDATE-DAY-II < 1) OR (WS-T-VALIDATE-DAY-II > 28) MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG. MOVE WS-T-VALIDATE-YEAR-II TO WS-T-VALIDATE-YEAR. MOVE WS-T-VALIDATE-MONTH-II TO WS-T-VALIDATE-MONTH. MOVE WS-T-VALIDATE-DAY-II TO WS-T-VALIDATE-DAY. MOVE WS-T-VALIDATE-DATE TO WS-T-VALIDATION-DATE. IF WS-T-VALIDATION-DATE GREATER THAN WS-C-MAX-SIZE-DATE MOVE WS-C-FLAG-ON TO WS-T-VALIDATION-ERROR-FLAG END-IF. 6099-VALIDATE-DATE-EXIT. EXIT.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.