OUTFIL Converting VB to FB Example


Scenario - Create FB file from VB file.

Input File - MATEPK.SORT.INPUT02 - VB file of 100 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
00001     student1           dept1          560
00003     student3           dept2          520
00004     student4           dept1          540
00005     student5           dept2          500
00002     student2           dept3          510
00006     student6           dept3          550
00008     student8           dept1          530
00007     student7           dept3          510
00009     student9           dept2          520
00010     student10          dept2          505

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//MATEPKD  JOB (123),'MTH',NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=SORT
//SORTIN   DD DSN=MATEPK.SORT.INPUT02,DISP=SHR
//FBOUTP   DD DSN=MATEPK.SORT.OUTPT02,
//             SPACE=(CYL,(1,1),RLSE),
//             DISP=(NEW,CATLG,DELETE)
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
     OPTION COPY
     OUTFIL FNAMES=FBOUTP,VTOF,OUTREC=(5,80)
/*

Output File - MATEPK.SORT.OUTPT02 - FB file of length 80

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
00001     student1           dept1          560
00003     student3           dept2          520
00004     student4           dept1          540
00005     student5           dept2          500
00002     student2           dept3          510
00006     student6           dept3          550
00008     student8           dept1          530
00007     student7           dept3          510
00009     student9           dept2          520
00010     student10          dept2          505

Explaining Example -

  1. OUTFIL FNAMES=FBOUTP,.. - Specifies the output is Fixed block file.
  2. OUTFIL FNAMES=..,VTOF,.. - Specifies the conversion is Variable to Fixed.
  3. OUTFIL FNAMES=..,OUTREC=(5,80) - Copies from 5th to 80th byte of the input file to output file.