I have a requirement like this. I need to extract 3 different records from an input file and I need to format each record in a different manner. and write the same to an outfile. I will explain bit clear way.
Records I need to INCLUDE from the input file:
1."START PPPP123 . CREATE/AUDIT PRIMARY CATEGORIZATION."
2."A SERIOUS PROBLEM HAS OCCURRED IN XXXX. AN XXX XXXX XXXXX ON THE SOLUTION TO XXX XXXX TABLE (XXXXXX) IS NOT ON THE XXXXX"
3."TABLE. THE XXX IN ERROR IS : XXXXXXXXXXXXX-X--X FOR FACILITY XX CONTACT APPLICATION SUPPORT ANALYST."
After the extraction I need to format them as follows on each.
From record 1 I need to write "PPPP123"
From record 2 I need to write "AN XXX XXXX XXXXX ON THE SOLUTION TO XXX XXXX TABLE (XXXXXX) IS NOT ON THE XXXXX"
From record 3 I need to write "TABLE. THE XXX IN ERROR IS : XXXXXXXXXXXXX-X--X FOR FACILITY XX "
All the above should be written to a single file.
I am able to extract the records by simply writing the include in the control statement.
But I am failing to format them(In writing INREC or OUTREC) in the way I specified above.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You can't use multiple OUTFIL statements with the same data set name the way you're trying to do.
If you want all of the records in one output file, then you should be using a DFSORT job like this with one output DD, and IFTHEN clauses rather than OUTFIL statements.
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
V S Amarendra Reddy wrote:
So the middle one is missing but the sort sysout is showing as 3 records out to dataset.
Since the displayed displacement for the third is wrong but works, could the displayed displacement for the second be wrong also?
Code:
OUTFIL FILES=1,OUTREC=(1:8,7,153X),
INCLUDE=(2,6,CH,EQ,C'START ')
1."START PPPP123 . CREATE/AUDIT PRIMARY CATEGORIZATION.
...0.....0
...2.....8
OUTFIL FILES=2,OUTREC=(1:42,80,80X),
INCLUDE=(4,7,CH,EQ,C'SERIOUS')
2."A SERIOUS PROBLEM HAS OCCURRED IN XXXX. AN XXX XXXX
.....0.....................................4
.....4.....................................2
OUTFIL FILES=3,OUTREC=(1:2,64,96X),
INCLUDE=(10,21,CH,EQ,C'THE XXX IN ERROR IS :')
3."TABLE. THE XXX IN ERROR IS : XXXXXXXXXXXXX-X--X FOR
...0......01
...2......90
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Little correction i would suggest in the subject of this thread..
Quote:
Need help to format(INREC) records after the extraction
INREC is used before SORTing the records. Perhaps, TS wanted to say OUTREC.
I removed "after the extraction" from the Subject. Since it's a COPY, INREC is fine.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Since the displayed displacement for the third is wrong but works, could the displayed displacement for the second be wrong also?
Well, I'm not sure if the starting positions were a problem or not, but trying to use three OUTFILs to the same data set is definitely a problem.
I got the missing record when I tried this even with the correct positions for the INCLUDEs. IFTHEN should be used for this kind of thing, not OUTFIL.
Thank you very much for all to think on this . Especially to Frank.
Frank,
But here I got a problem while executing the code. I wanted to extract those 3 records only which we are formatting. But with this code it is formatting the 3 records in the way we wanted and along wiht them it is copying rest of all the records.
So I just added an INCLUDE condition before the INREC statement which will include those 3 alone and the rest is same as given by you.