Now my main problem is,, if you look in to the above file,, the Header and Trailer records contains in First 3 positions as 111 ,,, whereas the Data records(meaning 2 record till the record before the Trailer has the same 111 value in positions 4 to 6. Now I need to copy this PS file into another PS file without the loss of data and format just replacing 111 with 222.Also I would like to confirm one more thing here that the value 111 is not present at any other positions other than explained here. Can this be done in a single SORT Step? If so, can someone help provide the answer for this please. This is a quiet an urgent for me.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what I think you want. OUT will contain the records with 111 changed to 222. If 111 is not present at another position, ERR will be empty. If 111 is present at another position, ERR will have the record(s) in which 111 is at another position.
The only variation it won't catch is when a '111CR' or 'CR111' record is out of order (e.g. the third record is a 111CR record or the last record is a CR111 record). Do you need that variation caught as well?
I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Note that you'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) to use DFSORT's new IFTHEN and OVERLAY functions. If you have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it. If you don't have DFSORT, you can't use the IFTHEN or OVERLAY funcitons (other sort products don't have them).
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//OUT DD DSN=... output file (FB/80)
//ERR DD DSN=... error file (FB/80)
//SYSIN DD *
OPTION COPY
* Change '111' to '222' as needed.
INREC IFTHEN=(WHEN=(1,5,CH,EQ,C'111CR',AND,6,1,CH,NE,C' '),
OVERLAY=(1:C'222')),
IFTHEN=(WHEN=(1,6,CH,EQ,C'CR111'),OVERLAY=(3:C'222'))
* OUT -> Records with '111' changed to '222'.
OUTFIL FNAMES=OUT
* ERR -> EMPTY if '111' not found out of position.
* -> NOT EMPTY if '111' found out of position.
OUTFIL FNAMES=ERR,INCLUDE=(1,80,SS,EQ,C'111')
/*
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Som,
Yes, I changed the names in the job to make them more meaningful but forgot to change the explanation. I've edited my post to fix it. Thanks for pointing it out.