|
View previous topic :: View next topic
|
| Author |
Message |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi,
I have an input file of LRECL=80.
My requirement is as below:
IF (1,4,CH,EQ,C'AAAA')
THEN - CHECK FOR IMMEDIATE NEXT RECORD IF IT'S (1,4,CH,EQ,C'BBBB'). Then, write those two records to output file.
there are chances in the input file that, the immediate next records first 4 bytes have characters other than 'BBBB' in which case we dont want to write to output file.
Eg INPUT FILE :
| Code: |
QQQQ RECORD1
WWWW RECORD2
AAAA RECORD3
EEEE RECORD4
XXXX RECORD5
BBBB RECORD6
TTTT RECORD7
YYYY RECORD8
AAAA RECORD9
BBBB RECORD10
HHHH RECORD11
LLLL RECORD12
AAAA RECORD13
RRRR RECORD14
BBBB RECORD15
PPPP RECORD16
AAAA RECORD17
BBBB RECORD18
IIII RECORD19
FFFF RECORD20
|
And the output file must be
| Code: |
AAAA RECORD9
BBBB RECORD10
AAAA RECORD17
BBBB RECORD18
|
Thanks in advance. |
|
| Back to top |
|
 |
girishbs13
New User
Joined: 11 Nov 2011 Posts: 24 Location: India
|
|
|
|
Hi Aslam,
Here is the DFSORT step which will do what you asked for. I have assumed LRECL=80, RECFM=FB for your output file.
| Code: |
//STEP0010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
QQQQ RECORD1
WWWW RECORD2
AAAA RECORD3
EEEE RECORD4
XXXX RECORD5
BBBB RECORD6
TTTT RECORD7
YYYY RECORD8
AAAA RECORD9
BBBB RECORD10
HHHH RECORD11
LLLL RECORD12
AAAA RECORD13
RRRR RECORD14
BBBB RECORD15
PPPP RECORD16
AAAA RECORD17
BBBB RECORD18
IIII RECORD19
FFFF RECORD20
/*
//SORTOUT DD DSN=O/p file
//SYSIN DD *
OPTION COPY
INREC IFTHEN(WHEN=GROUP,BEGIN(1,4,CH,EQ,C'AAAA'),
END(1,4,CH,EQ,C'BBBB'),
PUSH(15:SEQ=1,16:1,15))
OUTFIL INCLUDE=(1,4,CH,EQ,C'BBBB',AND,15,1,CH,EQ,C'2'),
BUILD=(16,13,/,1,13,67X)
/* |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And if the input is like this?
| Code: |
AAAA RECORD9
AAAB RECORD11
BBBB RECORD10
AAAA RECORD17
BBBB RECORD18
|
I'm assuming the keys are representative, rather than actual.
| Code: |
AAAA
XXXX
AAAA
MMMM
XXXX |
Can this type of combination logically exist, and what do you want to do when it does. Here XXXX is the "important" thing. |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
I tried the above code, and it wrked fine. Awesome.
But at the same time when I give the input through a file, then the output file comes empty. Why is it doing so... May be i am missing something out of my ignorance. |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hello Bill Woodger,
The input file will be the same way as I have given. |
|
| Back to top |
|
 |
girishbs13
New User
Joined: 11 Nov 2011 Posts: 24 Location: India
|
|
|
|
Hi Aslam,
It should work fine with a file input.
Can you post your step here? |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hello Girish, My code is below
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=TEST.INPUT.FILE,DISP=SHR
//SORTOUT DD DSN=TEST.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE)
//SYSIN DD *
OPTION COPY
INREC IFTHEN(WHEN=GROUP,BEGIN(1,4,CH,EQ,C'AAAA'),
END(1,4,CH,EQ,C'BBBB'),
PUSH(15:SEQ=1,16:1,15))
OUTFIL INCLUDE=(1,4,CH,EQ,C'BBBB',AND,15,1,CH,EQ,C'2'),
BUILD=(16,13,/,1,13,67X)
/*
|
The TEST.INPUT.FILE has the same records as I have mentioned in my first post. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Aslam,
When you give it a dataset, is the dataset fixed-length or variable-length records? If variable, (in the RECFM) then you'd need to adjust for the RDW by adding four bytes to all the start positions.
If BBBB represents the lowest logical key possibe after the AAAA key, then you should be OK with the above code. |
|
| Back to top |
|
 |
girishbs13
New User
Joined: 11 Nov 2011 Posts: 24 Location: India
|
|
|
|
Hi Aslam,
Please create your output file with LRECL,
If you want a file with record length lower than 80, accordingly change the 67X in the build statement. |
|
| Back to top |
|
 |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hello girish,
I have included DCB=(LRECL=80,RECFM=FB) for the sortout file, but still, the output files comes empty.... |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Again then, what is the RECFM of your input dataset?
If it contains the same data, and you have the same sort cards, then, assuming you are not getting NOT CATLG's messages for the output, the RECFM must not include F. If it does, then you don't have the same data or you don't have the same sort cards. Or magic has happened. Magic isn't real. Check your input RECFM, contents of dataset and sort cards.
If still mystificed, post the lot, in the Code tags. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| You also need to give the output file some space and a place to stay. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|