I have to replace a fileaid step with sort. The input file is a 133 fba report file. The fileaid control card is below
Code:
$$DD01 COPY STOP=(1,0,C'CAMPUS MAIL')
$$DD02 SPACE STOP=(1,0,C'CAMPUS MAIL')
$$DD02 COPY STOP=(1,0,C'U.S. MAIL')
$$DD03 SPACE STOP=(1,0,C'U.S. MAIL')
$$DD03 COPY
This fileaid has the same input in dd01, dd02 and dd03, it is taking the first part of the file until it hits 'campus mail' and puts it to the first output, then from there until it hits 'u.s. mail' it puts to the 2nd output and finally the remainder of the file is put to the third output. The first record of the file has spaces where the 'campus mail' eventually appears later in the file.
Even though the fileaid does not have columns the literals being checked above are in column 20 consistantly.
I know this can be done by a group function but i'm having trouble getting it to work. Any suggestions.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
norm.flynn,
I am a bit rusty with FILE-AID cards but If I remember correctly, the following DFSORT JCL should give you the desired results. I assumed your input has RECFM=FB and LRECL=80.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC << DD01 RECORD
DEF << DD01 RECORD
EFG << DD01 RECORD
CAMPUS MAIL << DD01 RECORD
EEEE << DD02 RECORD
GGGG << DD02 RECORD
HHHH << DD02 RECORD
U.S. MAIL << DD02 RECORD
IIIII << DD03 RECORD
JJJJ << DD03 RECORD
KKKKKKKKK << DD03 RECORD
CAMPUS MAIL2 << DD03 RECORD
ABC4 << DD03 RECORD
DEF4 << DD03 RECORD
EFG4 << DD03 RECORD
U.S. MAIL2 << DD03 RECORD
//DD01 DD SYSOUT=*
//DD02 DD SYSOUT=*
//DD03 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,END=(1,80,SS,EQ,C'CAMPUS MAIL'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=GROUP,END=(81,8,ZD,EQ,2,AND,1,80,SS,EQ,C'U.S. MAIL'),
PUSH=(89:ID=8))
That didn't work properly, The first file was almost created properly, but it had what should have been the first record in the 2nd file and the last record for the first file. Maybe if I explain exactly what the fileaid commands are doing and the structure of the input.
Btw, the dataset is fba 133.
The input file has 3 blocks of data in it.
The first block is first record of the file thru the first occurance of campus mail (but not including that record)
The second block is from the first occurance of campus mail until the first occurance of u.s mail (but not including that record),
The last block goes from the first occurance of u.s mail until the end of the fil.
The first one writes out file 1 until it encounters the literal 'campus mail'
The second command space stop positions at the first 'campus mail', the next command copies from that point until it hits the literal 'u.s. mail'. The dd03 space stop positions at the next record with 'u.s. mail' in it, then writes the rest of the file to file 3.
What happened with the code you gave me was the first file was correct but had 'campus mail' as the last record, (this should have been the first record in the second file). The second file went until it found found another 'campus mail' and then stopped, and the final file basically had a combination of what should have been file2 and file3.
On the file2 output I am just getting the records from the first ocurrance of literal campus mail to the second literal of campus mail, I need the 2nd file to go from the first occurance of campus mail to the first occurance of u.s mail (but not including the first occurance of u.s mail)
I think once the 2nd file is good, then the third file should be fine as it is just the remainder, currently the 3rd file has the most of the data that should be in the 2nd file and the data which should be in the third file.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
norm.flynn wrote:
Thanks, that did fix the file1 output.
On the file2 output I am just getting the records from the first ocurrance of literal campus mail to the second literal of campus mail, I need the 2nd file to go from the first occurance of campus mail to the first occurance of u.s mail (but not including the first occurance of u.s mail)