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

modifying group header based on group detail records


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

New User


Joined: 18 Jul 2009
Posts: 2
Location: Bangalore

PostPosted: Fri Jul 24, 2009 1:39 am
Reply with quote

Hi,

I have a requirement to modify the group header record depending on the contents of the detail records in the group.

The input file contains the following kinds of records:

File Header (pos 1 = FLEHD)
File Trailer (pos 1 = FLETR)
Group Header (pos 1 = GRPHD)
Group Detail (pos 1 = GRPDT) edited for typo
Group Trailer (pos 1 = GRPTR)

The file header and trailer occur only once: at the beinning and end of the file respectively.

There can be any number of group header, details and trailer records. The group header and trailer occur before and after the detail records in a group respectively.

The header needs to be modified as follows:
If byte 37 of the group header is set to 'N', then check byte 26 of all the detail records in the group. If byte 26 in any one of the detail records is set to '0', then set the byte 37 in the group header to 'Y'.

An example:

Input File (FB, LRECL=108)
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+---
FLEHD........
GRPHD...............................Y..........
GRPDT....................1.....
GRPDT....................2.....
GRPDT....................1.....
GRPTR..........
GRPHD...............................N..........
GRPDT....................1.....
GRPDT....................0.....
GRPDT....................2.....
GRPDT....................0.....
GRPDT....................0.....
GRPDT....................0.....
GRPTR..........
GRPHD...............................N..........
GRPDT....................1.....
GRPDT....................3.....
GRPDT....................2.....
GRPDT....................8.....
GRPTR..........
FLETR.....


After changes

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+---
FLEHD........
GRPHD...............................Y..........
GRPDT....................1.....
GRPDT....................2.....
GRPDT....................1.....
GRPTR..........
GRPHD...............................Y..........
GRPDT....................1.....
GRPDT....................0.....
GRPDT....................2.....
GRPDT....................0.....
GRPDT....................0.....
GRPDT....................0.....
GRPTR..........
GRPHD...............................N..........
GRPDT....................1.....
GRPDT....................3.....
GRPDT....................2.....
GRPDT....................8.....
GRPTR..........
FLETR.....


Here the first group is not checked as the byte 37 is Y.
In the second group byte 37 should be changed to Y as byte 26 is set to 0 in at least one of the details records (i.e. detail records 2,4,5 and 6)
The third group header is not altered as none of the detail records have byte 26 set to 0.

Really not sure if this can be done using ICETOOL
Any help on this highly appreciated.

Cheers!!
sjs
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 24, 2009 3:20 am
Reply with quote

shettjs,

Is it ok to sort the detail records within each group? The idea is to get the 0 detail record next to the grphd record. If it is ok then use the following 1 pass DFSORT solution which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=your input FB 108 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(125:26,1)),             
  IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'GRPHD'),           
  PUSH=(109:ID=8,SEQ=8)),                                   
  IFTHEN=(WHEN=(1,5,CH,EQ,C'FLEHD'),OVERLAY=(109:17C'0')), 
  IFTHEN=(WHEN=(1,5,CH,EQ,C'FLETR'),OVERLAY=(109:17C'9')), 
  IFTHEN=(WHEN=(1,5,CH,EQ,C'GRPTR'),OVERLAY=(117:09C'9'))   
 
  SORT FIELDS=(109,8,CH,A,125,1,CH,A)                       
 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'GRPHD'),     
  PUSH=(126:1,108),RECORDS=2),                             
  IFTHEN=(WHEN=(125,1,ZD,EQ,0),OVERLAY=(162:C'Y'))         
                                                           
  OUTFIL IFOUTLEN=108,OMIT=(1,5,CH,EQ,C'GRPHD'),           
  IFTHEN=(WHEN=(126,1,CH,GT,C' '),BUILD=(126,108,/,1,108)) 
//*
Back to top
View user's profile Send private message
shettjs

New User


Joined: 18 Jul 2009
Posts: 2
Location: Bangalore

PostPosted: Fri Jul 24, 2009 3:42 am
Reply with quote

Kolusu,

Thnks a tonne for the quick response.

Unfortunately we need to have the GRPDT records in the same sequence. Does that mean that we need to include a new sequence number field and then sort it based on that field in a second sort run?

Regards,
sjs
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 24, 2009 5:21 am
Reply with quote

shettjs,

Here is a 2 pass solution which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your input FB 108 file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//HDR      DD DSN=&&H1,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)   
//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'GRPHD'),       
  PUSH=(109:ID=8,SEQ=8))                                     
  SORT FIELDS=COPY                                           
  OUTFIL FNAMES=HDR,REMOVECC,NODETAIL,                       
  INCLUDE=(1,5,CH,EQ,C'GRPDT',AND,26,1,ZD,EQ,0),             
  SECTIONS=(109,8,TRAILER3=(C'GRPHD',37:'Y',109:109,8,8C'0'))
//*                                                         
//STEP0200 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=&&T1,DISP=SHR                             
//         DD DSN=&&H1,DISP=SHR                             
//SORTOUT  DD SYSOUT=*                                       
  SORT FIELDS=(109,16,CH,A),EQUALS                           
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'GRPHD',AND,   
  117,8,ZD,EQ,0),PUSH=(37:37,1),RECORDS=2)                   
  OUTFIL BUILD=(1,108),                                     
  OMIT=(1,5,CH,EQ,C'GRPHD',AND,117,8,ZD,EQ,0)               
//*
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 2
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