SORT:

VB to FB format
OPTION COPY
OUTFIL FNAMES=SORTOUT,VTOF,OUTREC=(1,80)

SORT FIELDS=COPY

SORT FIELDS=(20,01,A,21,03,A),FORMAT=CH
SORT FIELDS=(1,2,BI,A,3,2,BI,A,5,3,CH,A,8,10,CH,A,37,8,PD,D)
INCLUDE COND=(10,2,BI,EQ,X'0004',AND,10,2,BI,EQ,X'0006',AND,
             (24,3,CH,EQ,C'610',OR,24,3,CH,NE,C'291'))
SUM FIELDS=(22,8,PD,32,5,PD,47,9,ZD,56,9,ZD,79,2,BI)
SUM FIELDS=(35,2,BI)
OMIT  COND=(81,5,CH,EQ,C'RRQPT',OR,
            81,5,CH,EQ,C'RRPPA')
OUTREC FIELDS=(1,21,C'RRORK',27,19)
OUTREC FIELDS=(1,23,32,8,PD,EDIT=(SIIIIIIIIIIIIT.TTS),SIGNS=(,(,,)))
OUTREC FIELDS=(1,63,64:C'Z',65,86)

//SYSIN DD *
  OPTION SIZE=E250000000,DSPSIZE=0,CINV,
  NOEQUALS,NOVERIFY,NOWRKSEC,
  EFS=NONE,MAINSIZE=128M,DYNALLOC=(SYSDA,64)
/*

SORT FIELDS=(116,15,A,011,09,A,61,07,A),FORMAT=CH
INCLUDE COND=(068,08,PD,GT,0)
FIELDS=(68,08,PD,76,08,PD,84,08,PD)
OUTREC FIELDS=(116,15,C' ',011,09,C' ',061,07,C' ',068,8,PD,
       EDIT=(SIIIIIIIIIIIIT.TTS),SIGNS=(,(,,)))
END

INREC IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE1’),
       BUILD=(1,40,C’**’,+1,TO=PD)),
IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE2’),
       BUILD=(1,40,+2,TO=PD,X’FFFF’)),
IFTHEN=(WHEN=(NONE),OVERLAY=(45:C’NONE’))

Overlay
//SORTIN  DD DISP=SHR,DSN=INPUT.FILE
//SORTOUT DD DSN=OUTPUT.FILE,DISP=.....
//SYSOUT  DD SYSOUT=*
//SYSIN   DD *
  INREC  IFTHEN=(WHEN=(102,2,CH,EQ,C'PD'),
              OVERLAY=(102:C'RV'))
  SORT  FIELDS=COPY
/*

//STEP01 EXEC PGM=SORT,DYNAMNBR=20,COND=(0,NE)
//SYSIN DD *
  OUTFIL FILES=01,INCLUDE=(1,2,CH,EQ,C'PP')
  SORT  FIELDS=(1,9,CH,A,10,3,CH,A,13,4,CH,A,17,10,CH,A,27,2,CH,A)
  SUM   FIELDS=(29,07,PD,36,07,PD,43,07,PD)
  OUTFIL FILES=02,INCLUDE=(1,2,CH,NE,C'PP')
/*
//

JOIN
//SORTJNF1 DD DISP=SHR,DSN=FILE1
//SORTJNF2 DD DISP=SHR,DSN=FILE2
//POSCDQ   DD DSN=OUTFILE1,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(10,10),RLSE),
//            UNIT=SYSDA,
//            DCB=(LRECL=0200,RECFM=FB,BLKSIZE=0)
//DRRECS  DD  DSN=OUTFILE2,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(10,10),RLSE),
//            UNIT=SYSDA,
//            DCB=(LRECL=0200,RECFM=FB,BLKSIZE=0)
//SYSIN   DD  *
  JOINKEYS FILE=F1,FIELDS=(738,12,A,442,10,A)
  JOINKEYS FILE=F2,FIELDS=(142,12,A,101,10,A)
  REFORMAT FIELDS=(F1:1,2851,F2:1,200)
  OUTFIL FNAMES=POSCDQ,BUILD=(1:1,2851)
  OUTFIL FNAMES=DRRECS,BUILD=(1:2852,200)
  SORT FIELDS=COPY
/*
//SYSOUT   DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
SORTWK01  DD  UNIT=WORK,SPACE=(CYL,1275)
SORTWK02  DD  UNIT=WORK,SPACE=(CYL,1275)
SORTWK03  DD  UNIT=WORK,SPACE=(CYL,1275)
SORTWK04  DD  UNIT=WORK,SPACE=(CYL,1275)

     JOIN UNPAIRED,F1,ONLY