Converting FB to VB
You can convert an FB data set to a VB data set with OUTFIL's FTOV parameter. Each VB output record has a 4-byte RDW followed by the corresponding data from the FB input record, and the length in the RDW is the length of the FB record plus 4.
//FBVB JOB A92,PROGRAMMER
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=A123456.SORT.SAMPIN,DISP=SHR
//VBOUT DD DSN=A123456.SORT.VSAMP,DISP=(NEW,CATLG,DELETE),
// UNIT=3390,SPACE=(CYL,(5,5))
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=VBOUT,FTOV
/*
Because the LRECL of SORT.SAMPIN is 173 bytes, each VB record in SORT.VSAMP is 177 bytes (the FB record length of 173 plus 4 for the RDW) and SORT.VSAMP is given an LRECL of 177.
You can also use PARSE, BUILD, OUTREC, OVERLAY, FINDREP, or IFTHEN parameters with FTOV on the OUTFIL statement. All of the reformatting features are available (input fields, strings, editing, and so on). With FTOV, you specify the input positions, and output columns as you would for an FB record (without the RDW). DFSORT adds the RDW after the FB record is reformatted.
OUTFIL FTOV,BUILD=(1:120,25,32:C'in ',110,5)
Positions 1-2: Length (in RDW) = hex 002B = 43
Positions 3-4: Zeros (in RDW) = hex 0000 = 0
Positions 5-29: Input positions 120-144
Positions 30-35: Blanks
Positions 36-38: 'in '
Positions 39-43: Input positions 110-114
Each VB output record is 43 bytes long and the output data set is given an LRECL of 43.
ABC
ABCDEF
AC
ABCDEFGHI
OPTION COPY
OUTFIL FTOV
Length X'0000' Data
---------------------------------------------
1 2 3 4 5 24
---------------------------------------------
24 0 ABC
24 0 ABCDEF
24 0 AC
24 0 ABCDEFGHI
---------------------------------------------
OUTFIL FTOV,VLTRIM=C' '
Length X'0000' Data
---------------------------------------------
1 2 3 4 5 24
---------------------------------------------
7 0 ABC
10 0 ABCDEF
6 0 AC
13 0 ABCDEFGHI
---------------------------------------------
You can use any character or hexadecimal byte value for VLTRIM. For example, VLTRIM=C'*' removes trailing asterisks, and VLTRIM=X'00' removes trailing binary zeros.