|
View previous topic :: View next topic
|
| Author |
Message |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
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. |
|
| Back to top |
|
 |
Skolusu
Senior Member
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))
OUTFIL FNAMES=DD01,BUILD=(1,80),INCLUDE=(81,8,ZD,EQ,1)
OUTFIL FNAMES=DD02,BUILD=(1,80),
INCLUDE=(81,8,ZD,EQ,2,AND,89,8,ZD,EQ,1)
OUTFIL FNAMES=DD03,BUILD=(1,80),SAVE
//* |
|
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
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. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
norm.flynn,
I was under the assumption that the stop included the search string record,obviously it is not. We can fix that easily with 2 more IFTHEN statements.
Use the following control cards
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,END=(1,133,SS,EQ,C'CAMPUS MAIL'),
PUSH=(134:ID=8)),
IFTHEN=(WHEN=GROUP,END=(134,8,ZD,EQ,2,AND,1,133,SS,EQ,C'U.S. MAIL'),
PUSH=(142:ID=8)),
IFTHEN=(WHEN=(1,133,SS,EQ,C'CAMPUS MAIL',AND,134,8,ZD,EQ,1),
OVERLAY=(141:C'2')),
IFTHEN=(WHEN=(1,133,SS,EQ,C'U.S. MAIL',AND,142,8,ZD,EQ,1),
OVERLAY=(142:8X))
OUTFIL FNAMES=DD01,BUILD=(1,133),INCLUDE=(134,8,ZD,EQ,1)
OUTFIL FNAMES=DD02,BUILD=(1,133),
INCLUDE=(134,8,ZD,EQ,2,AND,142,8,ZD,EQ,1)
OUTFIL FNAMES=DD03,BUILD=(1,133),SAVE
//* |
|
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
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)
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.
Here is what I got in file2 output
| Code: |
W-2 FORMS FOR CAMPUS MAIL
-
-
-
-
-
-
-
-
0
W-2 FORMS FOR CAMPUS MAIL |
|
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
So I fiddled with the control card you gave me and I got it to work.
Here is the final control card for reference
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,END=(1,133,SS,EQ,C'CAMPUS MAIL'),
PUSH=(134:ID=8)),
IFTHEN=(WHEN=GROUP,END=(1,133,SS,EQ,C'U.S. MAIL'),
PUSH=(142:ID=8)),
IFTHEN=(WHEN=(1,133,SS,EQ,C'CAMPUS MAIL',AND,134,8,ZD,EQ,1),
OVERLAY=(141:C'2')),
IFTHEN=(WHEN=(1,133,SS,EQ,C'U.S. MAIL',AND,142,8,ZD,EQ,1),
OVERLAY=(142:8X))
OUTFIL FNAMES=DD01O,BUILD=(1,133),INCLUDE=(134,8,ZD,EQ,1)
OUTFIL FNAMES=DD02O,BUILD=(1,133),
INCLUDE=(142,8,ZD,EQ,1,AND,134,8,ZD,NE,1)
OUTFIL FNAMES=DD03O,BUILD=(1,133),SAVE |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
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)
|
give these control cards a shot.
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,133,SS,EQ,C'CAMPUS MAIL'),
END=(1,133,SS,EQ,C'U.S. MAIL'),PUSH=(134:ID=8)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,133,SS,EQ,C'U.S. MAIL'),PUSH=(142:ID=8)),
IFTHEN=(WHEN=(1,133,SS,EQ,C'U.S. MAIL'),OVERLAY=(134:8X))
OUTFIL FNAMES=DD01,BUILD=(1,133),INCLUDE=(134,16,CH,EQ,C' ')
OUTFIL FNAMES=DD02,BUILD=(1,133),INCLUDE=(134,8,CH,GT,C' ')
OUTFIL FNAMES=DD03,BUILD=(1,133),SAVE
//* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|