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
 

 

Maximum value for a Character field

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

Active User


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

PostPosted: Fri Jun 15, 2012 9:57 pm    Post subject: Maximum value for a Character field
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    Post subject: Re: Maximum value for a Character field
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: 183
Location: Toronto, ON, Canada

PostPosted: Fri Jun 15, 2012 11:32 pm    Post subject:
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    Post subject:
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    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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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