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

count totals


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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Mon Aug 25, 2014 11:41 pm
Reply with quote

I have file:

20 read
10 write
15 skip

Output should be:
20 read
10 write
25 skip

The skip is 20(read)-10(write) + 15(skip) = 25 . is it possible? Thanks.
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: Tue Aug 26, 2014 12:01 am
Reply with quote

Is that it for the entire file? If not, show something representative and expected output.

Assuming that is it, you need WHEN=GROUP for 'read' and PUSH the 1,2 for the count to an extension of the record, RECORDS=3. WHEN=GROUP for 'write', PUSH 1,2 to a different place. WHEN=(logical expression) for 'skip' and calculate with 1,2 and the two PUSHed values.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 26, 2014 12:08 am
Reply with quote

yes, it is entire file ...ok, I can push 1,2 for read and write ... then I can use ifthen skip, but how I can calculate the result from previous records?
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 26, 2014 1:39 am
Reply with quote

Thanks - it worked
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: Tue Aug 26, 2014 2:06 am
Reply with quote

Glad you've got it.

If you can post the code, it may help someone with a similar tasks.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 26, 2014 6:19 pm
Reply with quote

so you think your first sugesstion wasn't enough icon_biggrin.gif ( just kidding):
Code:

//STEP020  EXEC PGM=ICETOOL,                                           
//     PARM='SIZE(MAX),DYNALLOC=(SYSDA,100)'                           
//IN    DD *                                                           
20  READ                                                               
10  WRITE                                                               
15  SKIP                                                               
//OUT   DD SYSOUT=*                                                     
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)           
//SYSOUT    DD SYSOUT=*                                                 
//DFSMSG    DD SYSOUT=*                                                 
//TOOLMSG   DD SYSOUT=*                                                 
//TOOLIN    DD *                                                       
  COPY   FROM(IN) TO(T1)  USING(CTL1)                                   
  COPY   FROM(T1) TO(OUT)  USING(CTL2)                                 
//CTL1CNTL DD *                                                         
 INREC IFTHEN=(WHEN=GROUP,                                             
 BEGIN=(5,5,CH,EQ,C'READ '),PUSH=(81:1,2)),                             
  IFTHEN=(WHEN=GROUP,                                                   
 BEGIN=(5,5,CH,EQ,C'WRITE'),PUSH=(83:1,2)),                             
  IFTHEN=(WHEN=(5,4,CH,EQ,C'SKIP'),                         
 BUILD((81,2,ZD,SUB,83,2,ZD),ADD,01,2,ZD,EDIT=(TT),3,80))   
//CTL2CNTL DD *                                             
 INREC BUILD=(1,80)                                         


output is:
Code:

20  READ                                             
10  WRITE                                           
25  SKIP                                             
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: Tue Aug 26, 2014 6:30 pm
Reply with quote

This is basically your code from the first CNTL file. To cut back down to 80-byte records, you could have used OUTREC BUILD, or OUTFIL BUILD or you can use IFOUTLEN (the most efficient way to do it) which sets the record-length to the value specified. I've cange your BUILD to OVERLAY, and included the RECORDS= I suggested (not particularly give you much for this task, but gets you used to what they can do).


Code:
  OPTION COPY
 INREC  IFOUTLEN=80,
      IFTHEN=(WHEN=GROUP,                                             
               BEGIN=(5,5,CH,EQ,C'READ '),
                       RECORDS=3,
                       PUSH=(81:1,2)),                             
      IFTHEN=(WHEN=GROUP,                                                   
               BEGIN=(5,5,CH,EQ,C'WRITE'),
                       RECORDS=2,
                       PUSH=(83:1,2)),                             
      IFTHEN=(WHEN=(5,4,CH,EQ,C'SKIP'),                         
               OVERLAY=((81,2,ZD,
                        SUB,83,2,ZD),
                        ADD,01,2,ZD,
                        EDIT=(TT))) 


Untested, but should be about there. Make more use of indentation, you'll find things easy to flip around.

Other than choosing ICETOOL rather than SORT you did a fairly good job of implementing what I suggested. This will help you with similar tasks in the future.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 26, 2014 6:34 pm
Reply with quote

wow.... your code so elegant!!!!
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Count the number of characters in a f... CA Products 1
Search our Forums:

Back to Top