Joined: 10 Jun 2005 Posts: 13 Location: London, UK
Hello,
I have a requirement to reformat records in a file based on a criteria and also will need to list all the formatted records in a report for audit purposes. How to write a record to a report file alongwith reformatting it to the output file?
e.g Requirement is in the given input VSAM file
Change position 10-11 to value '24' if position 5 is 'o'.
This can be achieved using IFTHEN Overlay or with CHANGE option of OUTREC. But all the records being changed this way have to be sent to a report file which would list the records changed and trailer with the count of records modified. Can it be achieved using OUTFIL or do i have to create a report first using a separate step identifying records satisfying the criteria and then perform the update in another step? .
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
With DFSORT, you can set an indicator after the end of the record that will allow you to do what you want. Use IFTHEN WHEN=INIT to initialize the indicator to '0' in all of the records. In your IFTHEN WHEN=cond clause, set the indicator to '1' to indicate the record was changed. Then you can use the indicator to include only the records with '1' using OUTFIL INCLUDE. You can remove the indicator with OUTFIL as well.
Joined: 10 Jun 2005 Posts: 13 Location: London, UK
Thank you very much for your help Frank. I tried to implement your suggestion as below. It works with one problem. The input file is KSDS VSAM and is variable length( average record size 62, max recsz=1220).
The end result expected is to update this file to change certain fields for recrods satisfying the criteria.
Code:
//sort EXEC PGM=ICETOOL
//REPORTF DD SYSOUT=*
//INVSAM DD DSN=TTFB.MARALA.LCOLOC30,DISP=SHR
//TEMPFILE DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(50,50))
//OUTVSAM DD DSN=TTFB.MARALA.LCOLOC30,DISP=OLD
//TOOLIN DD *
COPY FROM(INVSAM) TO(TEMPFILE) USING(CNT1)
COPY FROM(TEMPFILE) USING(CNT2)
/*
//CNT1CNTL DD *
OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'D',AND,19,2,CH,EQ,C'22'),
OVERLAY=(19:C'24',1221:C'1',1222:1,18,1240:19,2)),
IFTHEN=(WHEN=NONE,OVERLAY=(1221:C'0',20X))
/*
//CNT2CNTL DD *
OUTFIL FNAMES=OUTVSAM,OUTREC=(1,1220)
OUTFIL FNAMES=REPORTF,
INCLUDE=(1221,1,CH,EQ,C'1'),OUTREC=(1221,21)
*further report details such as header and trailer etc. to be coded.
/*
I am trying to add the indicator byte at postion 1221( after the max recsz length) and some data which will help display old and new values for the changed fields in report file.
The problem is, sort treats the input VSAM file as record type F and after execution of above step I see the records are being padded with x'00' to make all equal to length 1220.
my question is how do I add the indicator flag to variable length VSAM file and get an updated VSAM file without affecting the length of records?
Joined: 10 Jun 2005 Posts: 13 Location: London, UK
Here is another way I could get the expected result but with one drawback.I need to repeat the conditions in two places.
( Would be adding 64 more conditions and overlays)
is there a way to do this without repeating the same condition in two places? .
( I realized I could not make use of VSAMIO and RESET options to do in-place because I am performing a copy option. Hence needed to use a different o/p dataset than sortin. adds another step to load it back.)
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Specify:
Code:
RECORD TYPE=V
That tells DFSORT to treat the VSAM records as variable so it will append an RDW in positions 1-4. Put your indicator in position 5 and shift the rest of your records over 1 position to the right, e.g.
Code:
IFTHEN=(WHEN=INIT,BUILD=(1,4,5:C'0',6:5)),
...
Now you can use position 5 for the indicator, but remember to use p+1 instead of p for the other fields.
Joined: 10 Jun 2005 Posts: 13 Location: London, UK
That works perfect. Thank you Frank. Also i think if i insert the 'modify tag' in 'When=NONE' then I can use original positions P instead of P+1 when checking for the conditions.