Search code examples
sortingdatemainframejcl

icetool read an input file with a date and overlay into another file


I have an input file (80 char) with a date in position 1 to 10, format YYYY-MM-DD. I will like to isolate that date and then write it to another existing file (use overlay maybe ??). In this existing file I want the date to be replacing the YYYY-MM-DD. this yyyy-mm-dd is located in position 59 in the output file.

I am not sure if we can perform this in one step only or we need two steps.

INPUT FILE (80 chars): 2018-06-28,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I will like to override the output file parameter YYYY-MM-DD. OUTPUT FILE (80 chars): FILE=/DATA/EXT/RECEPTION/TEST01_DTE/PASSING_DTE_PARAM_CTL.YYYY-MM-DD.QS

EXPECTED OUTPUT FILE RESULT: FILE=/DATA/EXT/RECEPTION/TEST01_DTE/PASSING_DTE_PARAM_CTL.2018-06-28.QS


Solution

  • here is how I solve the problem:

    //EXTRCT EXEC PGM=SORT                                            
    //SYSOUT DD SYSOUT=*                                              
    //SORTIN DD 
            DSN=INPUT.DATE.CTL.FILE,DISP=SHR 
    //SORTOUT DD 
            DSN=OUTPUT.FILE.TEST,    
    //      DISP=(,CATLG),UNIT=SYSDA,SPACE=(TRK,(10,10),RLSE)       
    //SYSIN DD *                                                      
     OPTION COPY                                                      
     OUTFIL REMOVECC,                                                      
     OUTREC FIELDS= 
          (C'FILE=/DATA/EXT/TEST01_DTE/PASSING_DTE_PARAM_CTL.',59:1,10,         
           C'.QS         ')
    /*                                                                
    //                                                                
    

    OUTPUT FILE Result will be:

    FILE=/DATA/EXT/TEST01_DTE/PASSING_DTE_PARAM_CTL.2019-02-20.QS

    I didn't want to use a join key.

    Thanks