Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
modifying group header based on group detail records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: modifying group header based on group detail records
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    Post subject: Reply to: modifying group header based on group detail recor
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm
No new posts Matching and unmatched records!! Vignesh Sid SYNCSORT 3 Thu Nov 09, 2017 11:22 am
No new posts Formatting multiple records to a sing... Vignesh Sid SYNCSORT 3 Tue Nov 07, 2017 12:22 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us