[USflag] The American Programmer [USflag]


Home
Books on Mainframe Programming
Mainframe Manuals and Tutorials
System Abend codes, Sqlcodes, VSAM/QSAM codes
Everything about the IBM AS/400 Midrange Computer
Everything about CICS
Everything about COBOL
Everything about DB2 and SQL
Everything about IMS
Everything about Java and JavaScript
Everything about JCL and JES
  Just Enough JCL. A bare-bones introduction
  Examples of JCL
  Examples of Idcams JCL
  Examples of JCL to run SYNCSORT
  Example of JCL to run ISPF in batch
  Example of JCL to run SQL in batch
  Example of JCL to run REXX in batch
  Books on JCL
  JCL Manuals
Everything about REXX
Everything about zOS, VSAM, Tivoli, Assembler
Everything about TSO, ISPF, Spufi
Site Map and Site Search

           Home   > JCL   > JCL Just Examples
JCL -Just Examples

JCL Examples of DD Statements for Existing data

Open for INPUT to READ. Open for OUTPUT to completely replace

VSAM
//ddname DD DSN=dataset-name,DISP=SHR

Example:
//INFILE DD DSN=MY.DATASET.DATA,DISP=SHR

“SEQUENTIAL”
File is not present.
//ddname  DD DUMMY,
//       DCB=(LRECL=rec-len,BLKSIZE=blk-size,RECFM=rec-format)

Example:
//INFILE  DD DUMMY,
//       DCB=(LRECL=80,BLKSIZE=800,RECFM=FB)


In-stream data. 80 characters, fixed format
//ddname DD *
data goes here
/*

Example:
//INFILE DD *
Linda
Ellen
/*


Disk or Tape non-gdg, non-pds member.
//ddname DD DSN=dataset-name,DISP=SHR

Example:
//INFILE DD DSN=MY.DATASET.DATA,DISP=SHR


Disk or tape, gdg.
//ddname DD DSN=dataset-name(0),DISP=SHR

Example:
//INFILE DD DSN=MY.DATASET.DATA(0),DISP=SHR


Disk, existing PDS member.
//ddname DD DSN=dataset-name(member-name),DISP=SHR

Example:
//INFILE DD DSN=MY.DATASET.DATA(M1),DISP=SHR


Temporary disk. Previously Passed
//ddname DD DSN=&&dataset-name,DISP=(OLD,DELETE)   or OLD,PASS

Example:
//INFILE DD DSN=&&TEMP,DISP=(OLD,DELETE)

 Sample DD Statements for Creating data

Open for OUTPUT only

VSAM
//ddname DD DSN=dataset-name,DISP=SHR

Example:
//INFILE DD DSN=MY.DATASET.DATA,DISP=SHR

“SEQUENTIAL”

Throw away the file.
//ddname  DD DUMMY,
//       DCB=(LRECL=rec-len,BLKSIZE=blk-size,RECFM=rec-format)

Example:
//INFILE  DD DUMMY,
//       DCB=(LRECL=80,BLKSIZE=800,RECFM=FB)


Spooled to printer
//ddname dd SYSOUT=printer-class

Example:
//OUTFILE DD SYSOUT=*


Disk, non-gdg, non-pds member. 
//ddname DD DSN=dataset-name,DISP=(NEW,CATLG,DELETE),
//        UNIT=diskunit,SPACE=(TRK,1)

Example:
//OUTFILE DD DSN=MY.DATASET.DATA,DISP=(NEW,CATLG,DELETE),
//        UNIT=SYSDA,SPACE=(TRK,1)
	

Tape, non-gdg.
//ddname DD DSN=dataset-name,DISP=(NEW,CATLG,DELETE),
//        UNIT=tapeunit
//* other parameters may be required by your company

Example:
//ddname DD DSN=MY.DATASET.DATA,DISP=(NEW,CATLG,DELETE),
//        UNIT=TAPE
//* other parameters may be required by your company


Disk, sequential gdg.
//ddname DD DSN=dataset-name(+1),DISP=(NEW,CATLG,DELETE),
//        UNIT=diskunit,SPACE=(TRK,1),
//        DCB=model-dscb   optional at some companies

Example:
//OUTFILE DD DSN=MY.DATASET.DATA(+1),DISP=(NEW,CATLG,DELETE),
//        UNIT=SYSDA,SPACE=(TRK,1),
//        DCB=MODEL.DSCB   optional at some companies. find its name 
Disk, new or existing PDS member. Existing member will be overwritten
//ddname DD DSN=dataset-name(member-name),DISP=SHR

Example:
//OUTFILE DD DSN=MY.DATASET.DATA(M1),DISP=SHR


Temporary disk..
//ddname DD DSN=&&dataset-name,DISP=(NEW,PASS,DELETE),
//        UNIT=diskunit,SPACE=(TRK,1)

Example:
//OUTFILE DD DSN=&&TEMP,DISP=(NEW,PASS,DELETE),
//        UNIT=SYSDA,SPACE=(TRK,1)


Temporary disk. Not used again in same job. A work file.
//ddname DD UNIT=diskunit,SPACE=(TRK,1)

Example:
//OUTFILE DD  UNIT=SYSDA,SPACE=(TRK,1)

Tape, gdg.
//ddname DD DSN=dataset-name(+1),DISP=(NEW,CATLG,DELETE),
//        UNIT=tapeunit,
//        DCB=model-dscb   optional at some companies

Example:
//OUTFILE DD DSN=MY.DATASET.DATA(+1),DISP=(NEW,CATLG,DELETE),
//        UNIT=TAPE,
//        DCB=MODEL.DSCB   optional at some companies. find out it


 Examples of GDG’s 

//* GDG1DEF DEFINE A GENERATION DATA GROUP
//GDG1DEF  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
 DEFINE GDG (NAME(userid.SAMPLE.GDG.BASE) -
 LIMIT(10) NOEMPTY SCRATCH)
/*


//*GDG2MAKE ACTUALLY CREATE A NEW G. D. SET
//STEP1     EXEC PGM=IEBGENER
//SYSPRINT  DD SYSOUT=*
//SYSIN     DD DUMMY
//SYSUT1    DD *
LINDA
ELENA
/*
//SYSUT2    DD DSN=userid.SAMPLE.GDG.BASE(+1),DISP=(NEW,CATLG),
//       SPACE=(TRK,1),                                 
//       DCB=model-dscb   optional at some companies


//* GDG3ALT CHANGE A GENERATION DATA GROUP'S DEFINITION
//GDG3ALT  EXEC PGM=IDCAMS             
//SYSPRINT DD SYSOUT=*                
//SYSIN    DD *                       
 ALTER        userid.SAMPLE.GDG.BASE -
 LIMIT(15)                            
/*                                    


//* GDG4DEL THIS WILL DELETE ALL THE MEMBERS OF THE GROUP
//ADIOS    EXEC PGM=IEFBR14
//BYEBYE   DD   DSN=userid.SAMPLE.GDG.BASE,DISP=(OLD,DELETE)


//* GDG5DEL THIS WILL REMOVE THE GD GROUP FROM THE CATALOG
//* BE SURE TO DO GDG4DEL FIRST
//GDG5DEL  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
 DELETE  userid.SAMPLE.GDG.BASE  GDG
/*

//*  Defining VSAM
//*      DEFINE A VSAM KSDS
//DEFKSDS  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
  /* the trailing - is for continuation */
  /* if delete fails there will be an error message which you can ignore */ 
  DELETE (userid.VSAM.KSDS) CLUSTER

  DEFINE CLUSTER -
	NAME(userid.VSAM.KSDS) -
	CYLINDERS(1,1)                       -
	KEYS(10,0) /* length displacement */ -
	RECORDSIZE(80,80) /* avg max */      -
	INDEXED) /* ksds */ 
/*

Some options for defining VSAM

RECOVERY		allow a restart of a load	
SPEED			opposite of recovery

UNIQUE		the cluster will not be part of a dataspace containing other clusters
SUBALLOCATE		opposite of unique

REPLICATE		copy each index record on the track as many times as it will fit
NOREPLICATE		opposite of unique

REUSE			if there is data in the cluster, a repro or load will clobber the existing data
NOREUSE		can do only one repro or load on this cluster

SHAREOPTIONS	region    system

region means roughly “this CICS” (an MVS can have more than one CICS running)
1	many jobs can read at same time
2	many jobs can read, only one can write
3	many jobs can read, many jobs can update, you’re on your own regarding data integrity
4	many jobs can read, many jobs can update

system means roughly “this MVS”
3	many jobs can read, many jobs can update, you’re on your own regarding data integrity
4	many jobs can read, many jobs can update

//*   DEFINE A VSAM ESDS
//DEFESDS  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
  DELETE (userid.VSAM.ESDS) CLUSTER

  DEFINE CLUSTER +
	NAME(userid.VSAM.ESDS) -
	CYLINDERS(1,1)         -
	RECORDSIZE(80,80)      -
	NONINDEXED)
//*    DEFINE A VSAM RRDS
//DEFRRDS  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
  DELETE (userid.VSAM.RRDS) CLUSTER

  DEFINE CLUSTER              -
	NAME(userid.VSAM.RRDS) -
	CYLINDERS(1,1)         -
	RECORDSIZE(80,80)      -
	NUMBERED)
/*


//*  LOAD A VSAM DATASET (KSDS, ESDS, RRDS) THEN PRINT IT
//LOADVSAM  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
  REPRO INFILE(INDD) OUTDATASET(userid.VSAM.xxxx) 

  PRINT INDATASET(userid.VSAM.xxxx) CHARACTER

/*
//INDD  DD *     for KSDS, records must be in order
ELENA
LINDA
NADIA
SUSAN
/*


 Examples of IDCAMS to Print


General JCL to print a file (sequential, VSAM, PDS member)

//STEP1  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE     DD DSN=name of file to be printed,DISP=SHR
//SYSIN   DD *
    PRINT INFILE(INFILE) CHARACTER
/*

Example of JCL to print the file ABCCO.TEST.DATA (could be sequential, VSAM, PDS member)

//STEP1  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE     DD DSN=ABCCO.TEST.DATA,DISP=SHR
//SYSIN  DD *
    PRINT INFILE(INFILE) CHARACTER
/*

Notes:	Change CHARACTER to DUMP in order to print in both character and hex
	Change CHARACTER to HEX in order to print in hex
Examples of IDCAMS to copy


General JCL to copy a file (sequential, VSAM, PDS member)
to an existing file (sequential, VSAM, PDS member)

//STEP1  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE     DD DSN=name of file to be copied,DISP=SHR
//SYSIN DD *
    REPRO INFILE(INFILE) OUTFILE(OUTFILE)
/*
//OUTFILE     DD DSN=name of file to be replaced,DISP=SHR


Example of JCL to copy the file ABCCO.TEST.DATA  (could be sequential, VSAM, PDS member)
to the existing file ABCCO.SAMPLE.DATA

//STEP1  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE     DD DSN=ABCCO.TEST.DATA,DISP=SHR
//SYSIN DD *
    REPRO INFILE(INFILE) OUTFILE(OUTFILE)
/*
//OUTFILE     DD DSN=ABCCO.SAMPLE.DATA,DISP=SHR

Notes:
	IDCAMS will copy any of the following types:
		Sequential
		PDS member
		VSAM
		ISAM
	to any of the following:
		Sequential
		PDS member
		VSAM
		ISAM
	This JCL will clobber any data that already exists in the output file. 	
	However, if the output file is VSAM and you want to clobber it,
	you must add the keyword REUSE, for example: 
		    REPRO INFILE(INFILE) OUTFILE(OUTFILE) REUSE
	and you must have defined the VSAM cluster with REUSE.


Using IDCAMS to delete a file. If the file is not found,
there will be an error message and high return code.

//* delete with idcams
//DELETE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
 DELETE            dataset-name	
 


Using IDCAMS to shorten a file by copying it with the skip or count parameter.


//* shorten a file
//SHORT01  EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
 REPRO INFILE(INDD) OUTFILE(OUTDD) SKIP(0001000) COUNT(0001000)
/*
//INDD   DD  DSN=input-file,DISP=OLD
//OUTDD  DD  DSN=output-file,
//        DISP=(NEW,CATLG,DELETE),
//        SPACE=(TRK,(5,2),RLSE),
//        DCB=(RECFM=FB,LRECL=xx)
//*
 Examples of Running TSO in batch, running REXX.

You can execute TSO commands, CLISTS, REXX programs.

//* Run TSO in batch
//TSOBATCH EXEC PGM=IKJEFT1A,DYNAMNBR=200
//SYSPROC  DD   DSN=your-id.clist,DISP=SHR optional
//SYSPRINT DD   SYSOUT=*
//SYSTSPRT DD   SYSOUT=*
//SYSTSIN  DD *
PROFILE PREFIX(your-id)
LISTCAT LEVEL(your-id)
/*



Using TSO in batch to delete a file. Probably higher overhead than
other ways.

//* Run TSO in batch
//* also IKEFFT01, IKJEFT1B
//TSOBATCH EXEC PGM=IKJEFT1A,DYNAMNBR=200
//SYSPRINT DD   SYSOUT=*
//SYSTSPRT DD   SYSOUT=*
//SYSTSIN  DD *
PROFILE PREFIX(your-id)
DELETE 'dataset-name'

Running a REXX program in batch
Obtain the name of your REXX library and fill it in.
If your REXX program reads a file, you can put in a DD for 
the file and avoid having to do an ALLOC in the program.

//RUNREXX  EXEC PGM=IKJEFT1A,DYNAMNBR=200                  
//SYSEXEC  DD   DSN=dsn-of-rexx-library,DISP=SHR           
//INFILE   DD   DISP=SHR,DSN=dsn-of-input-file             
//SYSPRINT DD   SYSOUT=*                                   
//SYSTSPRT DD   SYSOUT=*                                   
//*                                                        
//SYSTSIN  DD *                                            
PROFILE PREFIX(your-id)                                       
%MYREXX



 Examples of ISPF Compare in batch.

Lower overhead, won’t tie up your terminal during compare.

//*SPF compare in batch
//SUPER1  EXEC PGM=ISRSUPC,
//       PARM=(DELTAL,LINECMP,'','')
//OLDDD  DD DSN=old-dataset,
//       DISP=SHR
//NEWDD  DD DSN=new-dataset,
//       DISP=SHR
//OUTDD  DD SYSOUT=*
//*


The ISPF Search. Lower overhead, won’t tie up your terminal during search.

//* spf search option 3.14
//SEARCH  EXEC PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC')
//NEWDD  DD DSN=library-to-be-searched,
//          DISP=SHR
//OUTDD  DD SYSOUT=*
//SYSIN  DD *
SRCHFOR  'character-string-to-be-searched-for'
SELECT MEMBER1,MEMBER2   optional select. restricts search to these members
SELECT MEMBER3,MEMBER4
/*

 Example of a Safe Compress

The world’s safest compress for PDS’s. Can’t destroy your library. Creates a backup first. 
If the compress works, it deletes the backup.
If the compress fails, it keeps the backup.

//* the ultimate batch compress
//* creates a backup library first. 
//* then deletes the backup last, if all worked 
//ERASE    EXEC PGM=IEFBR14
//OUTPDS    DD DSN=your-id.name-of-backup-lib,DISP=(MOD,DELETE),
//       UNIT=SYSDA,SPACE=(TRK,0)
//*
//COPY     EXEC PGM=IEBCOPY
//SYSPRINT  DD  SYSOUT=*
//SYSIN     DD  *
 COPY INDD=INPDS,OUTDD=OUTPDS
/*
//INPDS     DD DSN=library-to-be-compressed,DISP=SHR
//OUTPDS    DD DSN=your-id.name-of-backup-lib,REFDD=*.INPDS,
//       UNIT=SYSDA,  or your disk unit,
//       DISP=(NEW,CATLG,DELETE),
//       SPACE=(TRK,(100,10,50),RLSE)
//*
//* produce jcl error if the previous step failed
//JCLOUT   EXEC PGM=IEFBR14,COND=(0,EQ,COPY)
//DD1      DD   DSN=NOT.THERE,DISP=SHR
//*
//* this will do the compress
//COMPRESS EXEC PGM=IEBCOPY
//SYSPRINT  DD  SYSOUT=*
//SYSIN     DD  *
 COPY INDD=INPDS,OUTDD=INPDS
/*
//INPDS     DD DSN=library-to-be-compressed,DISP=SHR
//*
//* if compress fails, send tso message 
//         IF (RC GT 0) THEN
//TSOBATCH EXEC PGM=IKJEFT1A,DYNAMNBR=200,COND=(0,LT)
//SYSPRINT DD   SYSOUT=*
//SYSTSPRT DD   SYSOUT=*
//SYSTSIN  DD *
PROFILE PREFIX(your-id)
SEND 'COMPRESS FAILED library-to-be-compressed' USER(your-id) LOGON WAIT
//      ELSE
//ERASE    EXEC PGM=IEFBR14,COND=(0,LE)
//OUTPDS   DD  DSN=your-id.name-of-backup-lib,DISP=(MOD,DELETE),
//      UNIT=SYSDA,SPACE=(TRK,0)
//      ENDIF

 Example of Copying a PDS


//* COPY ONE PDS TO ANOTHER DO NOT REPLACE LIKE-NAMED MEMBERS
//LIBCOPY EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSUT2   DD UNIT=SYSDA,SPACE=(CYL,(3,3))
//SYSUT3   DD UNIT=SYSDA,SPACE=(CYL,(3,3))
//SYSUT4   DD UNIT=SYSDA,SPACE=(CYL,(3,3))
//INLIB    DD DSN=library-containing-members,DISP=SHR
//OUTLIB   DD DSN=library-to-put-members-in,DISP=SHR
//SYSIN    DD *
 COPY INDD=INLIB,OUTDD=OUTLIB
/*
//* OPTIONAL THINGS:
//*
//* TO COPY BUT EXCLUDE TWO MEMBERS:
//* COPY INDD=INLIB,OUTDD=OUTLIB
//* EXCLUDE MEMBER=(m1,m2)
//*
//* TO COPY AND REPLACE:
//* COPY INDD=((INLIB,R)),OUTDD=OUTLIB

//*iebcopy to copy a pds
//*in:  pds
//*out: pds
//*copy only members named MEM1 and MEM2
//*do not replace those members if they exist in the output pds
//IEBCOPY   EXEC PGM=IEBCOPY
//SYSPRINT  DD   SYSOUT=*
//SYSIN     DD   *
 COPY INDD=(INPDS),OUTDD=OUTPDS
 SELECT MEMBER=MEM1
 SELECT MEMBER=MEM2
/*
//*
//*
//*
//*iebcopy to copy a pds
//*in:  pds
//*out: pds
//*copy only members named MEM1 and MEM2
//*replace those members if they exist in the output pds
//IEBCOPY   EXEC PGM=IEBCOPY
//SYSPRINT  DD   SYSOUT=*
//SYSIN     DD   *
 COPY INDD=((INPDS,R)),OUTDD=OUTPDS
 SELECT MEMBER=MEM1
 SELECT MEMBER=MEM2
/*

 IEFBR14


Using IEFBR14 to delete a file. If the file is not found,
there will be no error message and no high return code. 

//ERASE    EXEC PGM=IEFBR14
//OUTPDS    DD DSN=your-id.name-of-backup-lib,DISP=(MOD,DELETE),
//          UNIT=SYSDA,SPACE=(TRK,0)
//*

Using IEFBR14 to avoid deleting and reallocating a file.
If you run a job frequently, and it needs the same
output dataset each time, you can use this JCL.

It finds the dataset, if it already exists. 
Then it clobbers it, avoiding the overhead of reallocating.
Note that the disposition on the step that actually uses
the file, later in the job, must be (OLD,CATLG)

If the dataset doesn't exist, it is created.

//FINDPASS EXEC PGM=IEFBR14                                
//DD1      DD   DSN=dsn-to-be-used-later-in-job,           
//      UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(MOD,PASS),   
//      LRECL=133,RECFM=FB,BLKSIZE=27930                
//*                                                        

AMBLIST - Show Load Module Attributes



//* SHOW LOAD MODULE ATTRIBUTES
//AMBLIST  EXEC PGM=AMBLIST
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD *
 LISTIDR  DDN=SYSLMOD,MEMBER=program-name GIVES ATTRIBUTES

 LISTLOAD DDN=SYSLMOD,MEMBER=program-name GIVES ATTRIBUTES AND CONTENTS
/*
//SYSLMOD  DD DSN=library-the-program-is-in,DISP=SHR


 SORT Examples


//*  to sort
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
* sort by name 
 SORT FIELDS=(10,9,CH,A),DYNALLOC=(SYSDA,6),FILSZ=E2000
/*
//* END OF JOB
 
  //* sort and do totals
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
* sort by state
* sum phone number
 SORT FIELDS=(19,2,CH,A),DYNALLOC=(SYSDA,6),FILSZ=E2000
 SUM FIELDS=(1,7,ZD)
* ZD is zoned decimal. signed or unsigned
* PD packed decimal.  BI Binary
/*
//* END OF JOB
 

//*  to sort and shift fields
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD * number in column 1, name in 10, state in 19
* sort by name (name is now in 1)
 SORT  FIELDS=(01,09,CH,A),DYNALLOC=(SYSDA,6),FILSZ=E2000
 INREC FIELDS=(01:10,09,   move name from 10 to 1
               10:01,07)   move number from 1 to 10
* inrec moves data before sorting starts
/*
//* END OF JOB


 //*  to sort and shift fields
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD *   number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
* sort by name 
 SORT   FIELDS=(10,09,CH,A),DYNALLOC=(SYSDA,6),FILSZ=E2000
 OUTREC FIELDS=(01:10,09,   move name from 10 to 1
               10:01,07)   move number from 1 to 10
* outrec moves data after sorting ends
/*
//* END OF JOB
 

//*  PLAIN COPY
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY
/*
//* END OF JOB
//*    COPY BUT SKIP 3 RECORDS
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY,SKIPREC=3
/*



//*    COPY. START WITH 4TH RECORD. STOP AFTER PRINTING 2 RECORDS
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY,SKIPREC=3,STOPAFT=2  STOP AFTER PRINTING 2
/*


//* COPY BUT ONLY IF LITERAL CT IS IN COLUMN 19 OF DATA
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY                 COPY BUT
 INCLUDE COND=(19,2,CH,EQ,C'CT')  ONLY IF CT IN COL 19
/*


//*    COPY BUT NOT IF LITERAL CT IS IN COLUMN 19 OF INPUT
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY                 COPY BUT
 OMIT    COND=(19,2,CH,EQ,C'CT')  NOT  IF CT IN COL 19
/*



//* COPY. INCLUDE RECORDS WITH LITERAL CT IN COLUMN 19,
//*       OR LITERAL J IN COLUMN 10
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
 SORT FIELDS=COPY                 USING AN OR
*                                 COPY IF CT IN COL 19
*                                 OR J IN COL 10
 INCLUDE COND=(19,2,CH,EQ,C'CT',OR,10,1,CH,EQ,C'J')
* AND WORKS TOO. ALSO X'C1' FOR A
/*


//* COPY INPUT FILE TO OUTPUT FILE BUT MOVE AS FOLLOWS
//* PUT THIS IN OUTPUT COLUMN 20:  9 CHARACTERS STARTING IN COLUMN 1
//*                    COLUMN 40: 16 CHARACTERS STARTING IN COLUMN 10
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
* COPY INPUT FILE TO OUTPUT FILE BUT MOVE AS FOLLOWS
* PUT THIS IN OUTPUT COLUMN 20:  9 CHARACTERS STARTING IN COLUMN 1
*                    COLUMN 40: 16 CHARACTERS STARTING IN COLUMN 10
 SORT FIELDS=COPY
 INREC FIELDS=(20:1,09,40:10,16)
/*

//* COPY INPUT FILE TO OUTPUT FILE BUT MOVE AS FOLLOWS
//* PUT THIS IN OUTPUT COLUMN 20:  9 CHARACTERS STARTING IN COLUMN 1
//*                    COLUMN 40: 16 CHARACTERS STARTING IN COLUMN 10
//* include only records from CT
//SORTIT EXEC PGM=SORT,PARM=’ABEND’
//SYSOUT DD SYSOUT=*
//SORTIN DD * number in column 1, name in 10, state in 19
9283873  JOAN     CT
7023232  JANE     CN
8432343  MARIO    MA
5549023  JILL     CT
6998781  JENNIFER VT
8432343  MURIEL   RI
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
* COPY INPUT FILE TO OUTPUT FILE BUT MOVE AS FOLLOWS
* PUT THIS IN OUTPUT COLUMN 20:  9 CHARACTERS STARTING IN COLUMN 1
*                    COLUMN 40: 16 CHARACTERS STARTING IN COLUMN 10
 SORT FIELDS=COPY
 INREC FIELDS=(20:1,09,40:10,16)
 INCLUDE COND=(19,2,CH,EQ,C'CT') only if CT in column 19
* include condition looks at input columns before INREC or OUTREC work
/*


//*
//*syncsort to eliminate duplicates
//* in:  seq
//* out: seq
//SYNCSORT  EXEC PGM=SYNCSORT
//SYSOUT    DD   SYSOUT=*
//SORTIN   DD   DISP=SHR,    <-the input
//         DSN=the.input.dsn
//SORTOUT  DD   DISP=(NEW,CATLG), <-the output
//      UNIT=SYSDA,LIKE=the.input.dsn,
//      SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *
 SORT FIELDS=(1,80,CH,A)
 SUM FIELDS=NONE
/*
//*
//*
//*
//*syncsort to include records on a condition
//*uses OUTREC to construct the output record
//*from fields on the input record
//* in:  seq
//* out: seq
//SYNCSORT  EXEC PGM=SYNCSORT
//SYSOUT    DD   SYSOUT=*
//SORTIN   DD   DISP=SHR,    <-the input
//         DSN=the.input.dsn
//SORTOUT  DD   DISP=(NEW,CATLG), <-the output
//         UNIT=SYSDA,LIKE=the.input.dsn,
//         SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *
 SORT FIELDS=(1,80,CH,A)
 INCLUDE COND=((51,7,CH,EQ,C'STRING1'),OR,
               (51,7,CH,EQ,C'STRING2'))
 OUTREC FIELDS=(01:11,08,
                20:51,19)
* a literal may be used in the outrec:
* OUTREC FIELDS=(C'!',
*        20:C'ABCD')
 SUM FIELDS=NONE
/*
//*
//*

Top of Page




















































































List of books on JCL and other mainframe topics

[Books Computer]

Home Books for Computer Professionals Privacy Terms |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |