We needed to take the file into mainframe format and sort that accordingly removing all the QUOTES and PIPES from it. There were 32 input fields in the input layout.
The fields were having size in fixed format. "123"/"988" in the first record was of 10 bytes but the actual data was of 3 bytes such variations were there while data was punched.
So we needed to sort the quotes before "123"/"988" after the field and skip the pipe character and put the appropriate field as proper locations. And after this we needed to convert this data in to the mainframe file.
The data was as shown below.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
"123"¦"6218888"¦"FEeeee"¦"THiMAS"¦"H"¦""¦"MD, NTN"¦"FARMER SURVICAL APCD"
"988"¦"12120584"¦"TTRBER"¦"Kuehn"¦"H"¦""¦"DD, CLS"¦"Poultry ARTS"
********************************* Top of Data **********************************
"123"¦"6218888"¦"FEeeee"¦"THiMAS"¦"H"¦""¦"MD, NTN"¦"FARMER SURVICAL APCD"
"988"¦"12120584"¦"TTRBER"¦"Kuehn"¦"H"¦""¦"DD, CLS"¦"Poultry ARTS"
How we solved it:
We develpoed the following DFSORT card which can be explained as mentioned below.
//STEP01 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=INPUT FILE
//SORTOUT DD DSN=O/P FILE,DISP=OLD
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ENDBEFR=C'"',FIXLEN=1),
%02=(ENDBEFR=C'"¦"',FIXLEN=10),
%03=(ENDBEFR=C'"¦"',FIXLEN=09),
%04=(ENDBEFR=C'"¦"',FIXLEN=35),
%05=(ENDBEFR=C'"¦"',FIXLEN=20),
%06=(ENDBEFR=C'"¦"',FIXLEN=01),
.
.
.
%32=(ENDBEFR=C'"',FIXLEN=10)),
BUILD=(%02,%03,%04,%05,%06,...,%32)
/*
//SORTIN DD DISP=SHR,DSN=INPUT FILE
//SORTOUT DD DSN=O/P FILE,DISP=OLD
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ENDBEFR=C'"',FIXLEN=1),
%02=(ENDBEFR=C'"¦"',FIXLEN=10),
%03=(ENDBEFR=C'"¦"',FIXLEN=09),
%04=(ENDBEFR=C'"¦"',FIXLEN=35),
%05=(ENDBEFR=C'"¦"',FIXLEN=20),
%06=(ENDBEFR=C'"¦"',FIXLEN=01),
.
.
.
%32=(ENDBEFR=C'"',FIXLEN=10)),
BUILD=(%02,%03,%04,%05,%06,...,%32)
/*
~ PARSE operand can be used with INREC, OUTREC or OUTFIL to define rules that tell DFSORT how to extract the relevant data from each variable input field into a fixed parsed field
~ We define a parsed field for converting a variable field to a fixed parsed field using a %nn name where nn can be 00 to 99. Each %nn parsed field must be defined only once.
~ ENDBEFR=C'"' instructs DFSORT to extract data upto the byte before the next quote.
~ ENDBEFR=C'"|"' instructs DFSORT to extract data upto the byte before the next quote and PIPE character along with quote.
~ FIXLEN sets the length of the parsed field
~ BUILD operand is used to construct the output record.