Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
You can use the DFSORT OUTREC statement to do what you want.
Code:
OUTREC FIELDS=(5,length)
The above says to create the output record starting in byte 5 of the input/sort data for the number of bytes specified. If your records are 100 bytes long, this value will be 96 (i.e. 4 less than the record length).
The below is the JCL I already have. And the file gets created PV9793A.OUTPUT.FILE. Now should I add the Outrec along with the SORT card. I.E should the sort card be :-
Code:
SORT FIELDS=(1,2,CH,A)
INCLUDE COND=(6,2,CH,EQ,C'EN')
OUTREC FIELDS=(5,length)
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Yes, if you add the OUTREC statement after the INCLUDE you should be ok as far as reformatting the unwanted characters out of the output file.
I'm not sure why MOD is specified on the SORTIN DD - my preference would be OLD,DELETE. You also don't need the DCB info on SORTIN. It will automatically be detected up from the &&T1 input file.
From the data you posted, it appears that all of the records have the same value in pos 1&2 - sorting on those positions alone may not give the results you want. I'd recommend your sort fields be (at least) 1,13 depending on what other data mioght be in the records. It also looks like the INCLUDE is one position off - the EN appears to begin in pos 5 not 6.
DISP=SHR should not be used for output files. Is there some reason that the SORTOUT is not being created as a new file?
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
You're welcome.
A bit of understanding appears to be missing. A job CANNOT be writing that file while another is trying to access it!
Even if it would run somehow, imagine the situation if 2 jobs were writing and one job was reading the file at the same time. None of the results would be usable.
Specifying OLD will prevent this from happening. The first job running will hold the file until it completes then the next job may allocate the dataset. Also, if the volume may change, overwriting the file will not work well for you. It should be deleted and re-allocated each job. You could add an IEFBR14 at the start of the job to MOD,DELETE that dataset, then use NEW,CATLG in the SORTOUT.