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

Field wise count in ICETOOL or SORT


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

New User


Joined: 29 Jun 2006
Posts: 25

PostPosted: Mon Sep 08, 2014 5:43 pm
Reply with quote

Hi all,

My requirement is to count the no of values in each field (column) and display in Count in bottom for each column.

Sample:
Code:
XXX XXX XXX XXX
YYY YYY     YYY   
ZZZ ZZZ ZZZ ZZZ
111         222 
---------------
  4   3   2   4
---------------


This count shows the no of values in each field or column (wont count the Spaces)

Thanks,
Venkata.

Code'd and de-mangled
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: Mon Sep 08, 2014 5:59 pm
Reply with quote

On INREC, IFTHEN in WHEN=INIT to set a four-byte extension to zero. Four IFTHENs to test the field for non-blank and extend the record by one byte for each column with a value of one if non-blank.

Use OUTFIL reporting functions with REMOVECC, use TRAILER2 for some TOTs and BUILD to drop of the four excess bytes.
Back to top
View user's profile Send private message
sudhakar_mainframe
Warnings : 1

New User


Joined: 29 Jun 2006
Posts: 25

PostPosted: Tue Sep 09, 2014 12:44 pm
Reply with quote

Can you give sample code plz. urgent

Thanks,
Venkata.
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 Sep 09, 2014 1:19 pm
Reply with quote

If you can type out a request like that, you can type out the code yourself. Really, which part was difficult? Probably the TRAILER2, so find examples of that (the manual, here, internet search).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 09, 2014 2:28 pm
Reply with quote

Hi Bill,

Don't you think HIT=NEXT will also be needed on IFTHEN statements (in case of more than one overlay is required for same record)?
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 Sep 09, 2014 4:52 pm
Reply with quote

Yes, mistah kurtz, very good point.

I spent more time coding and de-mangling than thinking about it, because I half-suspect that the columns will turn out not to be fixed-position and that, along with the lines of dashes magically appearing, led me to expect a request for code, rather than hints :-)
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 09, 2014 6:22 pm
Reply with quote

Hi Sudhakar.

Please try something similar to the below code. First understand it and then modify it to get the required output.
Code:
  OPTION   COPY                                   
  INREC    IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1111')),
           IFTHEN=(WHEN=(01,03,CH,EQ,C'   '),     
                   OVERLAY=(81:C'0'),HIT=NEXT),   
           IFTHEN=(WHEN=(05,03,CH,EQ,C'   '),     
                   OVERLAY=(82:C'0'),HIT=NEXT),   
           IFTHEN=(WHEN=(09,03,CH,EQ,C'   '),     
                   OVERLAY=(83:C'0'),HIT=NEXT),   
           IFTHEN=(WHEN=(13,03,CH,EQ,C'   '),     
                   OVERLAY=(84:C'0'))             
  OUTFIL   REMOVECC,BUILD=(1,80),                 
           TRAILER2=(1:TOT=(81,1,ZD,EDIT=(IIT)),   
                     5:TOT=(82,1,ZD,EDIT=(IIT)),   
                     9:TOT=(83,1,ZD,EDIT=(IIT)),   
                    13:TOT=(84,1,ZD,EDIT=(IIT)))   

And please don't pester for code. Nobody is going to help you that way even if someone wants to.
Back to top
View user's profile Send private message
sudhakar_mainframe
Warnings : 1

New User


Joined: 29 Jun 2006
Posts: 25

PostPosted: Tue Sep 09, 2014 6:43 pm
Reply with quote

thanks for the responses. Any how i already got the solution before this post. I derived the result in same way. (Used Build instead of OVERLAY)

Thanks,
Venkata.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Sep 09, 2014 7:22 pm
Reply with quote

Good for you!
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 Sep 10, 2014 4:28 am
Reply with quote

I've been passed this one, which is a very useful way to do it:

Code:
  OPTION COPY                                                   
  INREC OVERLAY=(51:C'0000',                                     
                 51:01,3,CHANGE=(1,C'   ',C'0'),NOMATCH=(C'1'),
                 52:05,3,CHANGE=(1,C'   ',C'0'),NOMATCH=(C'1'),
                 53:09,3,CHANGE=(1,C'   ',C'0'),NOMATCH=(C'1'),
                 54:13,3,CHANGE=(1,C'   ',C'0'),NOMATCH=(C'1'))


The OUTFIL would be the same.

It is well worth understanding, and CHANGE doesn't seem to get the use it deserves. Anyone want to have a go at explaining exactly what that single OVERLAY statement does?
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Sep 10, 2014 12:06 pm
Reply with quote

This is really great! The single OVERLAY is by default populating the string '0000' in the 51st column and the subsequent CHANGE statements are looking up for spaces and setting the value to 1 if it does not find the match.

CHANGE syntax:
Code:
input field start position,input field length,CHANGE=(output field length,find value,set value if find a match),NOMATCH=(set value if does not match)


Thanks Bill for sharing this.
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 Sep 10, 2014 12:19 pm
Reply with quote

Correct mistah kurtz.

All in one shot it:

Sets four bytes from position 51 to zero
In position 51, for one byte, it will change that value to zero where there are spaces at position 1,3 otherwise it will be "1" at that position
This is repeated for the remaining three byte groups and one-byte positions from 52 to 54.

Note that the OVERLAY allows re-use of a position whose value has already changed in the OVERLAY. You can't do that with BUILD (you can use CHANGE in BUILD, of course).
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top