Booth Martin; Contract 
Programming, Inc.
28 Delmont Avenue
Barre, Vermont 05641
802-476-7942
boothm@ibm.net

A CL program to validate and/or convert date fields



To validate & convert date fields

   *************** Beginning of data ********************************
             PGM        PARM(&DATEIN &DATE68 &ERROR)              
  /*                                                               */
  /*         THIS PROGRAM swaps dates from 6 to 8, or 8 to 6.      */
  /*         parm &DATE if 68 = 6 to 8, or  86 = 8 to 6            */ 
             DCL        VAR(&DATEIN) TYPE(*CHAR) LEN(8)              
             DCL        VAR(&DATE6) TYPE(*CHAR) LEN(6)               
             DCL        VAR(&DATE68) TYPE(*CHAR) LEN(2)              
             DCL        VAR(&ERROR) TYPE(*CHAR) LEN(1)               
             CHGVAR     VAR(&ERROR) VALUE('0')                       
                                                                     
         /* If PARM is 86, then convert:                          */ 
             IF         COND(&DATE68 *EQ '86') THEN(DO)              
             CVTDAT     DATE(&DATEIN) TOVAR(&DATEIN) FROMFMT(*YYMD) +
                          TOFMT(*MDY) TOSEP(*NONE)                               
             MONMSG     MSGID(CPF0500) EXEC(CHGVAR VAR(&ERROR) +     
                          VALUE('1'))                                
             ENDDO                                                   
                                                                     
         /* If PARM &DATE is 68, then convert 6 digits to 8:        */          
             IF         COND(&DATE68 *EQ '68') THEN(DO)               
             CHGVAR     VAR(&DATE6) VALUE(%SST(&DATEIN 3 6))                     
             CVTDAT     DATE(&DATE6) TOVAR(&DATEIN) FROMFMT(*MDY) +   
                          TOFMT(*YYMD) TOSEP(*NONE)                               
             MONMSG     MSGID(CPF0500) EXEC(CHGVAR VAR(&ERROR) +      
                          VALUE('1'))                                 
             ENDDO                                                    
                                                                      
             ENDPGM                                                   



For comments or questions leave e-mail
A series of code for FTP of AS/400 files.
Review a sample of my coding work
Return to my home page
Top of page