Skip to content

Appendices

The CitSORT Examples

For more details about the function of these examples, refer to the appropriate section of the documentation.

EXPORT a VSAM indexed file to a SEQUENTIAL file

       >CITSORT COPY USE INDEXDFILE.DAT ORG IX RECORD F 85 KEY (1,5,P,10,3,A) 
       GIVE FLATFILE.DAT ORG SQ

IMPORT a SEQUENTIAL file to a VSAM indexed file

       >CITSORT COPY USE GIVE FLATFILE.DAT RECORD F 85 ORG SQ 
       GIVE INDEXDFILE.DAT ORG IX KEY (1,5,P,10,3,A)

Add an index to a VSAM indexed file

       >CITSORT COPY USE INDEXDFILE.DAT ORG IX RECORD F 85 KEY (1,5,P,10,3,A) 
       GIVE INDEXDFILE2.DAT ORG IX KEY (1,5,P,10,3,A, 20,7,AD)

SIGN-EBCDIC- Placement of the SIGN-EBCDIC clause

       >CITSORT SIGN-EBCIDIC USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

USE Statement, Fixed-Length RECORD clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

USE Statement, Variable-Length RECORD clause

       >CITSORT USE PRESIDENTS2.TXT RECORD V 12 24 ORG LS SORT FIELDS (1,2,NU,A) 
       GIVE PRES3.TXT ORG LS

USE Statement, ORGANIZATION Sequential File

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 ORG SQ SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

USE Statement, ORGANIZATION Relative File

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 ORG RL SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

USE Statement, No ORGANIZATION Clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

INREC Statement, Reduce the input record to 40 bytes

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (1,40) SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

SORT Fields, Sort on Descending, Ascending Order

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS
       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,A) 
       GIVE PRES2.TXT ORG LS

SORT Fields, Usage of the Format Clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,A) FORMAT=NU 
       GIVE PRES2.TXT ORG LS

SORT Fields, Sort on Multiple Keys

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (43,21,CH.A,1,2,CH,A) 
       GIVE PRES2.TXT ORG LS

SORT Fields, Usage of the Format Clause, Multiple Keys

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (43,21,A,3,22,A) FORMAT=CH
       GIVE PRES2.TXT ORG LS

SUM, Summing on a numeric field

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (43,21,41,2) 
       SORT FIELDS (1,21,CH,A) SUM FIELDS=(22,2,NU) 
       GIVE PRES2.TXT ORG LS

SUM, Eliminating records with a duplicate sort key

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (3,21,CH,A) 
       GIVE PRES2.TXT ORG LS SUM FIELDS=(NONE)

INCLUDE Statement, Character comparion

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       INCLUDE COND=(3,4,CH,EQ,'JOHN')
       GIVE PRES2.TXT ORG LS

INCLUDE Statement, Numeric comparison

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (1,40) 
       SORT FIELDS (1,2,NU,D) INCLUDE COND=(1,2,NU,EQ,10)
       GIVE PRES2.TXT ORG LS

INCLUDE Statement, Data expressed as hexadecimal

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (1,40) 
       SORT FIELDS (1,2,NU,D) INCLUDE COND=(1,2,NU,EQ,X3130)
       GIVE PRES2.TXT ORG LS

INCLUDE Statement, Use of Logical AND operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       INCLUDE COND=(1,2,NU,GT,01,AND,1,2,NU,LT,10) 
       GIVE PRES2.TXT ORG LS

INCLUDE Statement, Use of Logical OR operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       INCLUDE COND=(1,2,NU,EQ,01,OR,1,2,NU,EQ,10)
       GIVE PRES2.TXT ORG LS

INCLUDE Statement, Use of Substring operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       INCLUDE COND=(3,21,SS,EQ,JOHN)
       GIVE PRES2.TXT ORG LS

OMIT Statement, Character Comparison

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       OMIT COND=(3,4,CH,EQ,'JOHN')
       GIVE PRES2.TXT ORG LS

OMIT Statement, Numeric Comparison

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (1,40) 
       SORT FIELDS (1,2,NU,D) OMIT COND=(1,2,NU,EQ,10)
       GIVE PRES2.TXT ORG LS

OMIT Statement, Data expressed as hexadecimal

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 INREC FIELDS (1,40) 
       SORT FIELDS (1,2,NU,D) OMIT COND=(1,2,NU,EQ,X3130)
       GIVE PRES2.TXT ORG LS

OMIT Statement, Usage of Logical AND operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       OMIT COND=(1,2,NU,GT,01,AND,1,2,NU,LT,10)
       GIVE PRES2.TXT ORG LS

OMIT Statement, Usage of Logical OR operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       OMIT COND=(1,2,NU,EQ,01,OR,1,2,NU,EQ,10) 
       GIVE PRES2.TXT ORG LS

OMIT Statement, Use of Substring operator

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       OMIT COND=(3,21,SS,EQ,JOHN)
       GIVE PRES2.TXT ORG LS

GIVE Statement, Fixed-Length RECORD clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT RECORD F 85 ORG LS

GIVE Statement, Organization Line Sequential

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS

OUTFIL, Usage of the STARTREC Clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,D) 
       FORMAT=NU 
       GIVE PRES2.TXT ORG LS OUTFIL STARTREC 40

OUTFIL, Usage of the ENDREC Clause

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,D) 
       FORMAT=NU 
       GIVE PRES2.TXT ORG LS OUTFIL ENDREC 10

OUTFIL, Multiple output files, Multiple OUTRECs

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE OUT1.TXT OUTFIL OUTREC=(1,2,' ',3,22,' ',43,21) 
       GIVE OUT2.TXT ORG LS OUTFIL OUTREC=(3,21,' ',25,4,'-',33,4)
       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE OUT1.TXT ORG LS OUTFIL STARTREC=40 
       OUTREC=1,2, ,3,22, , 43,21) 
       GIVE OUT2.TXT ORG LS OUTFIL ENDREC=5 
       OUTREC=(3,21, , 25,4,-,33,4)

OUTREC Statement, Reformatting an output record

       > CITSORT USE PRESIDENTS.DAT ORG SQ RECORD F 85 
       SORT FIELDS (1,2,NU,D) 
       GIVE PRES3.TXT ORG LS OUTREC FIELDS=('PRESIDENT # ',1,2,' ',3,21)

OUTREC Statement, Reformatting output record, converting data with TO=

       > CITSORT USE PRESIDENTS.DAT ORG SQ RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES3.TXT ORG LS OUTREC FIELDS=(1,2,NU,TO=FS,' ',3,21)

OUTFIL, OUTREC using CHANGE/NOMATCH

       >CITSORT USE PRESIDENTS.DAT RECORD F 85 SORT FIELDS (1,2,NU,D) 
       GIVE PRES2.TXT ORG LS OUTFIL OUTREC=(1,2,3,1,CHANGE=(1,'B','W',NOMATCH=(3,1)),4,36)

CitSORT MERGE functionality

       >CITSORT MERGE USE PRESMERGE1.TXT RECORD F 85 ORG LS USE PRESMERGE2.TXT FIELDS=(1,2,NU,A) 
       GIVE ALLPRES.TXT ORG LS

CitSORT COPY functionality

       >CITSORT FIELDS=COPY USE PRESIDENTS.DAT RECORD F 85 GIVE TESTOUT.DAT

Or

       >CITSORT COPY USE PRESIDENTS.DAT RECORD F 85 GIVE TESTOUT.DAT

CitSORT TAKE [command-file]

       >CITSORT TAKE PRESIDENT-PARAMS.TXT
Back to top