Based on your sample input data, here is a SyncSort for z/OS 1.2 job that will produce your requested output:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=YOUR.VB.INPUT
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INCLUDE COND=(5,3,SS,EQ,C'HDR,TRL')
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,C'1',5,11)),
IFTHEN=(WHEN=(6,3,CH,EQ,C'HDR'),BUILD=(1,4,5,1,9,8,6Z)),
IFTHEN=(WHEN=(6,3,CH,EQ,C'TRL'),BUILD=(1,4,5,1,8Z,9,6))
SORT FIELDS=(5,1,CH,A)
SUM FIELDS=(6,4,BI,10,4,BI,14,4,BI,18,2,BI)
OUTREC FIELDS=(1,4,6)
//*