RAMESH KRISHNA REDDY mainframe discussion forum - cobol, db2,cics,jcl,file-aid,changeman,... interview questions, quizs
Online Tutorials   | PREV  | TOP  | NEXT(First Chapter)



DRONA SERIES
SORT OUTREC TUTORIAL


CHAPTER - 3


BUILD in Sort



   
 
 
Using BUILD in SORT
 
 

Build parameter is used to reformat records. Build give complete control over 
output file format.  BUILD parameter can be used on INREC and OUTREC statements 
in SORT card. BUILD parameter is an alias of the FIELDS parameter. Build parameter 
can be used in OUTFIL statement also.  


Basic Syntax's of Build Parameter

Syntax 1 - 

  BUILD=(c:p,m...)

  c:p,m ->  
  c: -> position in output file.
  p -> starting position of the input field 
  m -> length of the input field 

Syntax 2 - BUILD=(p,m,HEX.... ) p,m,HEX -> p -> starting position of the input field m -> length of the input field HEX -> Hexadecimal representation of input value will appear in the outputfile. Syntax 3 - BUILD=(p,m,TRAN=.... ) p,m,TRAN= -> p -> starting position of the input field m -> length of the input field TRAN=LTOU (or) TRAN=UTOL -> Will convert the input date from lower to upper case (LTOU) or) upper to lower case (UTOL) Inputfile 10 suresh 20000 01 20 NARENDRA 40000 06 30 jacob A 25000 07 40 RAMESH 34000 03 50 Kishore 50000 02 Build Sort Card //SYSIN DD * SORT FIELDS=COPY OUTREC BUILD=(1,21,TRAN=LTOU) /* Explanation - This sort card will copy first 21 bytes from inputfile & convert all letter to upper case letters. In the input data first record has lower case letters (suresh). this data will get converted to uppercase. Same rule applies to all the records. find the output file data after executing this SORT card. Outputfile 10 SURESH 20000 01 20 NARENDRA 40000 06 30 JACOB A 25000 07 40 RAMESH 34000 03 50 KISHORE 50000 02 Syntax 4 - BUILD=(p,m,lookup.....) p,m,lookup -> p -> starting position of the input field m -> length of the input field lookup -> CHANGE parameter to be used here to list down the table of entries to be compared. Example for lookup Input Data for Sort 10 suresh 20000 01 JAN 20 NARENDRA 40000 06 JUN 30 jacob A 25000 07 JUL 40 RAMESH 34000 03 MAR 50 Kishore 50000 02 FEB //SYSIN DD * SORT FIELDS=COPY OUTREC BUILD=(1,21,TRAN=LTOU,22,3, - CHANGE=(9, - C'JAN',C'JANUARY', - C'FEB',C'FEBRUARY', - C'MAR',C'MARCH', - C'APR',C'APRIL', - C'MAY',C'MAY', - C'JUN',C'JUNE', - C'JUL',C'JULY', - C'AUG',C'AUGUST', - C'SEP',C'SEPTEMBER', - C'OCT',C'OCTOBER', - C'NOV',C'NOVEMBER', - C'DEC',C'DECEMBER'), - NOMATCH=(22,3)) /* Explanation - This sort card will copy first 21 bytes from inputfile & convert all letter to upper case letters. In addition to this, It will replace 3 letter month name with month's full name at 22nd position. ( ex. JAN with JANUARY...). Data at 22nd position of the inputfile (3 bytes) will be compared with the data provided in CHANGE list. if any match found in the list corresponding data will be moved to outputfile (ex. if input data is matched with 'SEP' string SEPTEMBER will be moved to outputfile. if there is not match found (NOMATCH)... data at 22nd position from input file will be moved to output file (22,3). Data in Outputfile 10 SURESH 20000 01 JANUARY ............................ 20 NARENDRA 40000 06 JUNE ............................ 30 JACOB A 25000 07 JULY ............................ 40 RAMESH 34000 03 MARCH ............................ 50 KISHORE 50000 02 FEBRUARY ............................ ******************************** Bottom of Data **********
    

NEXT CHAPTER TOPIC : SORT Overview (First Chapter)


                                   




Home | Donations | Online Tutorials | Books | Entertainment | Contactme | privacy |  sql tutorial | jcl interview questions | JCL Tutorial | JCL Tutorial - chapter1 | JCL Tutorial - chapter2 | JCL Tutorial - chapter3 | JCL Tutorial - chapter4 | JCL Tutorial - chapter5 | JCL Tutorial - chapter6 | JCL Tutorial - chapter7 | JCL Tutorial - chapter8 | JCL Tutorial - chapter9 | JCL Tutorial - chapter10 | JCL Tutorial - chapter11