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
 
count totals

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

Active User


Joined: 20 May 2010
Posts: 111
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: 7315

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

Active User


Joined: 20 May 2010
Posts: 111
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

Active User


Joined: 20 May 2010
Posts: 111
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: 7315

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

Active User


Joined: 20 May 2010
Posts: 111
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: 7315

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

Active User


Joined: 20 May 2010
Posts: 111
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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm

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