Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Update count of group records into the Trailer

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Update count of group records into the Trailer
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Apr 23, 2014 12:24 pm    Post subject: Reply to: Update count of group records into the Trailer
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    Post subject: Re: Reply to: Update count of group records into the Trailer
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Apr 23, 2014 5:29 pm    Post subject: Reply to: Update count of group records into the Trailer
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    Post subject: Re: Reply to: Update count of group records into the Trailer
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sun May 04, 2014 4:14 pm    Post subject: Reply to: Update count of group records into the Trailer
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    Post subject: Re: Reply to: Update count of group records into the Trailer
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    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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us