Submitted Questions

  • how do you split a file data into multiple files?

    explain with example?

    Star Read Best Answer

    Editorial / Best Answer

    jjtharappel  

    • Member Since Nov-2011 | Nov 24th, 2011


    Run a JCL with the below sort step

    Code
    1. //STEP1    EXEC PGM=SORT                            
    2. //SORTIN   DD DSN=input-file-name,DISP=SHR          
    3. //SORTOF01 DD DSN=output-file-name-1,          
    4. //            DISP=(NEW,CATLG,DELETE),              
    5. //            SPACE=...
    6. //            LRECL=...,RECFM=FB    
    7. //SORTOF02 DD DSN=output-file-name-2,          
    8. //            DISP=(NEW,CATLG,DELETE),              
    9. //            SPACE=...
    10. //            LRECL=...,RECFM=FB                    
    11. //SORTOF03 DD DSN=output-file-name-3,          
    12. //            DISP=(NEW,CATLG,DELETE),              
    13. //            SPACE=...
    14. //            LRECL=...,RECFM=FB                        
    15. //SYSOUT   DD SYSOUT=*                              
    16. //SYSIN    DD *                                      
    17.   SORT FIELDS=COPY                                        
    18.   OUTFIL FNAMES=SORTOF01,                                
    19.    INCLUDE=(cond for file 1)  
    20.   OUTFIL FNAMES=SORTOF02,                                
    21.    INCLUDE=(cond for file 2)  
    22.   OUTFIL FNAMES=SORTOF03,                                
    23.    INCLUDE=(cond for file 3)
    24. /*
    25. //*
    26.  

    Haribabu

    • Oct 15th, 2019

    SORT FIELDS=COPY
    OUTFIL FILES=OUT1,ENDREC=10000
    OUTFIL FILES=02,STARTREC=10001,ENDREC=20000 OUTFIL FILES=03,STARTREC=20001,ENDREC=30000

    also possible for OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLIT=10000

    Rishu

    • Jul 31st, 2014

    In addition to the above solution, we can use SPLIT BY in SORT. But it will depend on condition of split.