SORT Card to Convert FB to VB and VB to FB

Converting VB file to FB or FB file to VB format is a common requirement. JCL SORT utility has the FTOV & VTOF options to convert the datasets as reuired.

Converting from FB to VB

//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MHY.TEST.SORTIN,DISP=SHR
//SORTOT DD DSN=MHY.TEST.VB.OUT,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(10,5),RLSE)

Notes:

  • No need to give any LRECL parameter for the VB out record, it takes the
    details from input file. Here it adds additional 4 bytes for RDW. So
    the length of output VB file will be 4 bytes more than input.
  • Output file DD Name can be any userdefined name.

VLTRIM Option:
This is used to create each VB record with a different length by trimming the trailing characters.

=COLS> ----+----1----+----2
000001 0001 MAHENER REDDY
000002 0002 ARJUN
000003 0003 SHRYU

From the above input file, without a VLTRIM option the converted output
file creates 3 VB records each with a length of 24 filled with trailing spaces.
But f the trailing spaces are not required and each VB record is to have a different length then VLTRIM is useful.

//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOT,FTOV,VLTRIM=C''
/*
//

VLTRIM can be used trim any other charector like ‘*’ or . etc

Options like BUILD, PARSE, OUTREC, FINDREP, OVERLAY can be used along with the FTOV on OUTFIL.

Converting from VB to FB

Option is VTOF. Here an OUTREC needs to be used as first 4 bytes for a VB file is reserved for RDW and needs to be excluded while copying.

//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTFB,VTOF,OUTREC=(5,20)
/*

OVERLAY & FINDREP can not be used with VTOF.

VLFILL Option:

VB file contains records with different record lengths, so VLFILL option is to fill the empty space with either spaces or with any other character.

Add a Comment

Your email address will not be published. Required fields are marked *