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

Update count of group records into the Trailer


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Apr 23, 2014 8:29 am
Reply with quote

I would like to seek help for how to update count of group records into the trailer.

LRECL of my input file is 512, FB.

Here's my input looks like:
Code:

@xxxxxxxxx
Axxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
#yyyyyyyyy


I would like to add the counts of B or C or D or E “3” into the trailer. They have the same count.
Code:

@xxxxxxxxx
Axxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
Bxxxxxxxxx
Cxxxxxxxxx
Dxxxxxxxxx
Exxxxxxxxx
#yyyyyyyyy00000003


I know we can use the IFTRAIL statement to count all detail records and update to the trailer, if use this, i will have 13 in the trailer.
Code:

IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'#'),
       TRLUPD=(13:COUNT=(M11,LENGTH=8)))


Anyone can help? Much appreciated~
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 23, 2014 12:24 pm
Reply with quote

If you want a count of groups, and groups start with a B, identify the group in the usual way (BEGIN looks for B) and PUSH ID. ID is a sequence number at group level. First group is one, second is two, third is... you get the picture already.

Then you have something for your IFTRAIL (or a simple IFTHEN) to identify the trailer record, put in the extended ID and it should be about there. Cut the record back down to size, dropping off the now unwanted extra bytes.
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Apr 23, 2014 2:56 pm
Reply with quote

Bill Woodger wrote:
If you want a count of groups, and groups start with a B, identify the group in the usual way (BEGIN looks for B) and PUSH ID. ID is a sequence number at group level. First group is one, second is two, third is... you get the picture already.

Then you have something for your IFTRAIL (or a simple IFTHEN) to identify the trailer record, put in the extended ID and it should be about there. Cut the record back down to size, dropping off the now unwanted extra bytes.

Hi Bill,

Yes, I know the WHEN=GROUP and PUSH function, how to put the extended ID into the IFTRAIL to only display the count of groups?

I tried with the below code, it returns the count 12 which is all records of BCDE.

Code:

  OPTION COPY                                     
  INREC IFTHEN=(WHEN=GROUP,                       
       BEGIN=(1,1,CH,EQ,C'B'),PUSH=(513:ID=8))     
  OUTFIL BUILD=(1,512),                           
       IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'#'),     
            TRLUPD=(13:COUNT-1=(M11,LENGTH=8)))   
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 23, 2014 5:29 pm
Reply with quote

OK, it is a little clearer. You mentioned the other record-tyes and TRLUPD, so I thought there may be a need already to use it.

If all you want on the trailer is a count of the groups, this is a count of the B records.

You can use the GROUP, ID and a simple IFTHEN to identify your trailer, and re-arrange the ID to where you want it.

Or you can extend a single-byte field, which is zero for non-B records (including header) and one for B records, then use TOTAL/TOT on TRLUPD.
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Sun May 04, 2014 3:26 pm
Reply with quote

Bill Woodger wrote:
OK, it is a little clearer. You mentioned the other record-tyes and TRLUPD, so I thought there may be a need already to use it.

If all you want on the trailer is a count of the groups, this is a count of the B records.

You can use the GROUP, ID and a simple IFTHEN to identify your trailer, and re-arrange the ID to where you want it.

Or you can extend a single-byte field, which is zero for non-B records (including header) and one for B records, then use TOTAL/TOT on TRLUPD.


Hi Bill,

May I know how to re-arrange the ID? I used the below code and received syntax error.
Code:

  OPTION COPY                                               
  INREC IFTHEN=(WHEN=GROUP,                                 
                BEGIN=(1,1,CH,EQ,C'B'),END=(1,1,CH,EQ,C'D'),
                PUSH=(513:ID=8)),                           
        IFTHEN=(WHEN=(1,1,CH,EQ,C'#'),OVERLAY=(13:ID))       
  OUTFIL BUILD=(1,512)                                       
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun May 04, 2014 4:14 pm
Reply with quote

Code:
  OPTION COPY                                               
  INREC IFOUTLEN=512,
        IFTHEN=(WHEN=GROUP,                                 
                BEGIN=(1,1,CH,EQ,C'B'),END=(1,1,CH,EQ,C'D'),
                PUSH=(513:ID=8)),                           
        IFTHEN=(WHEN=(1,1,CH,EQ,C'#'),
               OVERLAY=(13:513:8))
 


The ID is only valid on the PUSH. After the PUSH, the ID is in the position it has been PUSHed to.

Since the OUTFIL is not used for anything else, I've used IFOUTLEN to set the length of the record., so the BUILD is not needed to do that. Not tested, but should be close.
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Mon May 05, 2014 7:43 am
Reply with quote

Bill Woodger wrote:
Code:
  OPTION COPY                                               
  INREC IFOUTLEN=512,
        IFTHEN=(WHEN=GROUP,                                 
                BEGIN=(1,1,CH,EQ,C'B'),END=(1,1,CH,EQ,C'D'),
                PUSH=(513:ID=8)),                           
        IFTHEN=(WHEN=(1,1,CH,EQ,C'#'),
               OVERLAY=(13:513:8))
 


The ID is only valid on the PUSH. After the PUSH, the ID is in the position it has been PUSHed to.

Since the OUTFIL is not used for anything else, I've used IFOUTLEN to set the length of the record., so the BUILD is not needed to do that. Not tested, but should be close.


Hi Bill,

Here's the code works, within group only need to specify the B record otherwise no ID will be pushed in the trailer line. And you have a typo in the overlay statement, it's (13:513,8) instead of (13:513:8)

Many thanks for your help!

Code:

  OPTION COPY                                               
  INREC IFOUTLEN=512,                                       
        IFTHEN=(WHEN=GROUP,                                 
                BEGIN=(1,1,CH,EQ,C'B'),                     
                PUSH=(513:ID=8)),                           
        IFTHEN=(WHEN=(1,1,CH,EQ,C'#'),OVERLAY=(13:513,8))   
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 To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top