MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting Data treating as CH and BI Differences

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Thu Nov 07, 2013 11:29 am    Post subject: Sorting Data treating as CH and BI Differences Reply with quote

Code:


  3 RR-U                     13/GRP
    4 RR-A                    2/NUM
    4 RR-B                    5/NUM
    4 RR-C                   5/NUM
    4 FILLER                 1/NUM
  3 R-G                      3/AN     
  3 R-SER                  4/BI      -- 17,4,BI or CH? which one I have to use.
  3 R-IN                    1/AN
  3 R-POD                 5/NUM


Code:

SORT FIELDS=(1,13,CH,A,14,3,CH,A,17,4,CH,A,22,5,CH,A)
SORT FIELDS=(1,13,CH,A,14,3,CH,A,17,4,BI,A,22,5,CH,A)

The sort ended with maxcc 00 with CH and BI and I get the same output file. Did anyone know if this makes any difference?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Nov 07, 2013 11:49 am    Post subject: Reply with quote

vak255,

BI is binary format - it can be used to sort unsigned binary values of any type.
CH is character format - it can be used to sort character data.

In your case, your R-SER field is unsigned and contains digits of the form X'Fd'. You can sort this type of data correctly with CH or BI format.

CH and BI are generally interchangeable for sorting unless you are using a parameter that affects CH but not BI such as CHALT or LOCALE.

To illustrate the difference between signed and Unsigned values run this JCL and see the contents at 23(Binary) and 33 (Fixed Point Signed)
Code:

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                             
+247                                       
-247                                       
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                             
  OPTION COPY                               
  INREC OVERLAY=(10:1,4,SFF,BI,LENGTH=4,   
                 16:1,4,SFF,FI,LENGTH=4)   
                                           

  OUTREC OVERLAY=(23:10,4,HEX,             
                  33:16,4,HEX)             
//*                                         


Now remove the OPTION COPY statement and Run 2 tests with the following SORT statement

Test 1:
Code:
SORT FIELDS=(16,4,FI,A)
and see how -247 comes first

Test 2 :
Code:
SORT FIELDS=(10,4,BI,A)   
and see the data is not sorted even though you have a negative value because Binary field is treated as unsigned.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Thu Nov 07, 2013 12:00 pm    Post subject: Reply with quote

you always rock!!
I got it now.


Thanks for your time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group