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

Maximum value for a Character field


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

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Fri Jun 15, 2012 9:57 pm
Reply with quote

Is there an ICETOOL or SORT statement that will give me the maximum (or mininum) value of a field with FORMAT=CH ? Can this be done without doing a sort on the field? I am looking for just a single value not all of the records. I looked through the manual and could not find one.

The STATS command works only for numeric fields.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 15, 2012 11:03 pm
Reply with quote

jerryte wrote:
Is there an ICETOOL or SORT statement that will give me the maximum (or mininum) value of a field with FORMAT=CH ? Can this be done without doing a sort on the field? I am looking for just a single value not all of the records. I looked through the manual and could not find one.

The STATS command works only for numeric fields.


DFSORT does not have any features to count characters. This can be done by sorting the data and picking the first and last record using Header and trailer. Another alternative is to write an user exit.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Fri Jun 15, 2012 11:32 pm
Reply with quote

Thanks. This would make a good enhancement for the STATS command to return min and max values for a character field.

If I use an INREC to extract just the field I want and then SORT in descending order I can then use an OUTFIL to get the max value. Below is a sample:
Code:
INREC FIELDS=(87,26)     
SORT FIELDS=(1,26,CH,D) 
OUTFIL FILES=OUT,ENDREC=1
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Jun 16, 2012 12:01 am
Reply with quote

jerryte wrote:
Thanks. This would make a good enhancement for the STATS command to return min and max values for a character field.

If I use an INREC to extract just the field I want and then SORT in descending order I can then use an OUTFIL to get the max value. Below is a sample:
Code:
INREC FIELDS=(87,26)     
SORT FIELDS=(1,26,CH,D) 
OUTFIL FILES=OUT,ENDREC=1


If you can SORT the Field then you can get both MIN and MAX at the same time. Here is a sample for Sorting 10 bytes of character data.

Code:

//STEP0100 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                           
A                                         
AA                                       
AAA                                       
AAAAAAAA                                 
AAAAAAAAA                                 
AAAAAAAAAA                               
AAAA                                     
AAAAA                                     
AAAAAA                                   
AAAAAAA                                   
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  SORT FIELDS=(1,10,CH,A)                 
                                         
  OUTFIL REMOVECC,NODETAIL,               
  HEADER1=('MIN VALUE RECORD : ',1,10),   
  TRAILER1=('MAX VALUE RECORD : ',1,10)   
//*


The output is as follows
Code:

MIN VALUE RECORD : A         
MAX VALUE RECORD : AAAAAAAAAA
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top