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
 

 

count totals

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Mon Aug 25, 2014 11:41 pm    Post subject: count totals
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 26, 2014 12:01 am    Post subject: Reply to: count totals
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Aug 26, 2014 12:08 am    Post subject: Reply to: count totals
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Aug 26, 2014 1:39 am    Post subject: Reply to: count totals
Reply with quote

Thanks - it worked
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 26, 2014 2:06 am    Post subject: Reply to: count totals
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Aug 26, 2014 6:19 pm    Post subject: Reply to: count totals
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 26, 2014 6:30 pm    Post subject: Reply to: count totals
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

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Aug 26, 2014 6:34 pm    Post subject: Reply to: count totals
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    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 abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Update the Sortout file with record c... karthik_sripal SYNCSORT 8 Tue May 17, 2016 8:52 pm
No new posts CQM : Exec count is 0 but getpages &g... soundarr DB2 1 Thu Mar 17, 2016 10:08 pm
No new posts JCL SORT to split the file and put re... Bill Woodger DFSORT/ICETOOL 17 Wed Feb 17, 2016 4:17 pm


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