IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFSORT - formatting and reporting the formatted records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Thu Mar 09, 2006 8:50 pm
Reply with quote

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? .
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 09, 2006 10:00 pm
Reply with quote

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.
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Fri Mar 10, 2006 5:39 pm
Reply with quote

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?

Your help is very much appreciated.
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Fri Mar 10, 2006 10:20 pm
Reply with quote

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)


//STEP020 EXEC PGM=SORT
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//REPORTF DD SYSOUT=*
//SORTIN DD DSN=TTFB.MARALA.LCOLOC30,DISP=SHR
//*EMPFILE DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(50,50))
//OUTVSAM DD DSN=TTFB.MARALA.LCOLOC30.TRFM,DISP=OLD
//SYSIN DD *
RECORD TYPE=V
OPTION COPY,VLSHRT,VSAMIO,RESET
OUTFIL FNAMES=REPORTF,CONVERT,
INCLUDE=(5,1,CH,EQ,C'D',AND,23,2,CH,EQ,C'22'),
OUTREC=(5,20)
OUTFIL FNAMES=OUTVSAM,
IFTHEN=(WHEN=(5,1,CH,EQ,C'D',AND,23,2,CH,EQ,C'22'),
OVERLAY=(23:C'24'))
/*

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.)
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 10, 2006 10:21 pm
Reply with quote

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.

To remove the indicator, use: (1,4,5:6)
Back to top
View user's profile Send private message
marpana

New User


Joined: 10 Jun 2005
Posts: 13
Location: London, UK

PostPosted: Fri Mar 10, 2006 11:33 pm
Reply with quote

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.

for reference tried as below
9 //STEP020 EXEC PGM=SORT
0 //SYSUDUMP DD SYSOUT=*
1 //SYSOUT DD SYSOUT=*
2 //SYSPRINT DD SYSOUT=*
3 //REPORTF DD SYSOUT=*
4 //SORTIN DD DSN=TTFB.MARALA.LCOLOC30,DISP=SHR
5 //OUTVSAM DD DSN=TTFB.MARALA.LCOLOC30.TRFM,DISP=OLD
6 //SYSIN DD *
7 RECORD TYPE=V
8 OPTION COPY,VLSHRT
9 INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5:C'0',6:5)),
0 IFTHEN=(WHEN=(6,1,CH,EQ,C'D',AND,24,2,CH,EQ,C'22'),
1 BUILD=(1,4,5:C'1',6:6,18,24:C'24',26:26))
2 OUTFIL FNAMES=REPORTF,CONVERT,
3 INCLUDE=(5,1,CH,EQ,C'1'),
4 OUTREC=(6,20)
5 OUTFIL FNAMES=OUTVSAM,OUTREC=(1,4,5:6)
6 /*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top