|
September 2005 Technical Tip - SyncSort: Reformatting variable length records
Last month I showed you how variable length records are stored on the mainframe. This month's scenario is as follows: you need to reformat a file with variable length records, dropping a part of the fixed portion of the record and keeping the entire variable portion. SyncSort can do this, and this article will show you how.
We will use our file from last month. Recall the file contains credit card information for four individuals. That data is shown here for convenience:
File Edit Edit_Settings Menu Utilities Compilers Test Help
_______________________________________________________________________________
EDIT U0290.CREDIT.CARDS Columns 00001 00061
Command ===> Scroll ===> HALF
****** ***************************** Top of Data ******************************
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6-
000001 987BILL QUALLS 035555VISA10002345MAST05001234DISC0100
000002 123RUBECCA ALINIAZEE 011010VISA0000
000003 786ERIC ALBERT 022323MAST01003434DISC9999
000004 432JASON ROGERS 017777DISC0750
****** **************************** Bottom of Data ****************************
|
Note that record descriptor word (RDW) does not show while in edit: column positions do not include the RDW. But SyncSort requires the RDW be referenced, so we must add four (4) to the column positions.
The fixed portion of the record is in positions 1-25, the variable portion is in positions 26 and beyond. We want to pull the data in positions 1-3 and 24-25, and the entire variable portion (987, 03 and 035555VISA10002345MAST05001234DISC0100 in the first record, respectively.) The following JCL demonstrates the technique:
File Edit Edit_Settings Menu Utilities Compilers Test Help
_______________________________________________________________________________
EDIT U0290.ISPF.CNTL(VB2VB) - 01.00 Columns 00001 00072
Command ===> Scroll ===> HALF
****** ***************************** Top of Data ******************************
000001 //U0290V2V JOB (PRM,0,T),'BILL QUALLS',
000002 // CLASS=A,MSGCLASS=T,TIME=(0,59),NOTIFY=U0290
000003 //******************************************************
000004 //* PERMISSIVE DELETE OF PRE-EXISTING DATASET IF ANY *
000005 //******************************************************
000006 //STEP010 EXEC PGM=IEFBR14
000007 //DEL1 DD DSN=U0290.CREDIT.CARDS.NONAME,DISP=(MOD,DELETE),
000008 // UNIT=SYSDA,SPACE=(TRK,0)
000009 //******************************************************
000010 //* USE SORT TO REFORMAT FILE. VB INPUT, VB OUTPUT *
000011 //******************************************************
000012 //STEP020 EXEC PGM=SORT
000013 //SORTIN DD DSN=U0290.CREDIT.CARDS,DISP=SHR
000014 //SORTOUT DD DSN=U0290.CREDIT.CARDS.NONAME,DISP=(NEW,CATLG,DELETE),
000015 // UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
000016 //SYSOUT DD SYSOUT=*
000017 //SYSIN DD *
000018 SORT FIELDS=(5,3,CH,A)
000019 OUTREC FIELDS=(1:1,4, RDW (SORT WILL ADJUST IT)
000020 5:5,3, I WANT TO KEEP ACCT NBR AND
000021 8:28,2, NBR OF OCCURANCES (FROM FIXED PART)
000022 10:30) KEEP THE ENTIRE VARIABLE PART
000023 //******************************************************
000024 //* DUMP VB OUTPUT *
000025 //******************************************************
000026 //STEP030 EXEC PGM=IDCAMS
000027 //MYINPUT DD DSN=U0290.CREDIT.CARDS.NONAME,DISP=SHR
000028 //SYSPRINT DD SYSOUT=*
000029 //SYSIN DD *
000030 PRINT INFILE(MYINPUT) DUMP
****** **************************** Bottom of Data ****************************
|
Download file here.
Comments:
- SyncSort requires that the RDW be referenced in the OUTREC statement, but SyncSort will automatically adjust the RDW for each record to reflect the proper length.
- Just as SyncSort can determine the change in the length of each record, it will automatically determine the appropriate LRECL, so the DCB need not be specified on the output DD statement.
- When referencing the variable portion of the record, indicate its position, but no length.
The dump of the output file is as follows. You can see that the records are, in fact, the proper length.
LISTING OF DATA SET -U0290.CREDIT.CARDS.NONAME
RECORD SEQUENCE NUMBER - 1
000000 F1F2F3F0 F1F1F0F1 F0E5C9E2 C1F0F0F0 F0 *123011010VISA0000 *
RECORD SEQUENCE NUMBER - 2
000000 F4F3F2F0 F1F7F7F7 F7C4C9E2 C3F0F7F5 F0 *432017777DISC0750 *
RECORD SEQUENCE NUMBER - 3
000000 F7F8F6F0 F2F2F3F2 F3D4C1E2 E3F0F1F0 F0F3F4F3 F4C4C9E2 C3F9F9F9 F9 *786022323MAST01003434DISC9999 *
RECORD SEQUENCE NUMBER - 4
000000 F9F8F7F0 F3F5F5F5 F5E5C9E2 C1F1F0F0 F0F2F3F4 F5D4C1E2 E3F0F5F0 F0F1F2F3 *987035555VISA10002345MAST0500123*
000020 F4C4C9E2 C3F0F1F0 F0 *4DISC0100 *
|
We can also view the file with ISPF panel 2: it's a little easier to read.
File Edit Edit_Settings Menu Utilities Compilers Test Help
_______________________________________________________________________________
EDIT U0290.CREDIT.CARDS.NONAME Columns 00001 00041
Command ===> Scroll ===> HALF
****** ***************************** Top of Data ******************************
000001 123011010VISA0000
000002 432017777DISC0750
000003 786022323MAST01003434DISC9999
000004 987035555VISA10002345MAST05001234DISC0100
****** **************************** Bottom of Data ****************************
|
Want to know more about SyncSort? Give us a call! You can always count on Caliber Data Training for top quality education.
Go to the articles index.
Written by Bill Qualls. Copyright © 2005 by Caliber Data Training 800.938.1222
|