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

seperate odd numbers and even numbers using SORT


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

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Thu Oct 03, 2013 4:58 pm
Reply with quote

hi,
i have a file of record length(80).

first two byte of file can have odd or even numbers. i just have to seperate odd numbers and even numbers and write it into two different files using SORT?.

say for example.

my input file:

Code:
01AAAAAAAAAAAAAAAA
02BBBBBBBBBBBBBBBB
04CCCCCCCCCCCCCC
07DDDDDDDDDDDDDD


OUTPUT FILE 1:(Should contain only odd numbers )

Code:
01AAAAAAAAAAAAAAAA
07DDDDDDDDDDDDDD


OUTPUT FILE 2:(Should contain only Even numbers )

Code:
02BBBBBBBBBBBBBBBB
04CCCCCCCCCCCCCC


how can we differentiate odd numbers and even numbers using sort?
kindly help me in this regard


Regds,
useit.
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Thu Oct 03, 2013 5:09 pm
Reply with quote

hi,
i have tried this syntax. and below sort card worked for me. thanks a lot:)

Code:
//SORT01  EXEC PGM=SORT           
//SORTIN  DD *                     
01                                 
02                                 
03                                 
04                                 
//ODD     DD SYSOUT=*             
//EVEN    DD SYSOUT=*             
//SYSIN   DD *                     
  OPTION COPY                     
  OUTFIL FNAMES=(ODD,EVEN),SPLIT   
/*                   
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: Thu Oct 03, 2013 5:21 pm
Reply with quote

Try it with your original sample data and let us know.
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: Thu Oct 03, 2013 6:00 pm
Reply with quote

If you look at this, there is so code to identify odd and even numbers.

Code:
 OUTFIL FNAMES=EVEN,INCLUDE=(2,1,BI,EQ,B'.......0')
 OUTFIL FNAMES=ODD,SAVE
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Thu Oct 03, 2013 7:11 pm
Reply with quote

thanks a lot Bill..i tried this and it is working fine:)
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: Thu Oct 03, 2013 7:18 pm
Reply with quote

Hi..I was just trying something and came up with a solution using MOD function. Not sure if this is the best way..so just posting here.

Code:
//STEP01   EXEC PGM=SORT                                   
//SORTIN   DD *                                           
01AAA                                                     
02BBB                                                     
04CCC                                                     
05DDD                                                     
07EEE                                                     
//ODD      DD SYSOUT=*                                     
//EVEN     DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//SYSIN    DD *                                           
 OPTION COPY                                               
 INREC  IFTHEN=(WHEN=INIT,                                 
                BUILD=(1,5,6:1,2,ZD,MOD,+2,TO=ZD,LENGTH=1))
 OUTFIL FNAMES=ODD,INCLUDE=(6,1,CH,EQ,C'1'),BUILD=(01,05) 
 OUTFIL FNAMES=EVEN,INCLUDE=(6,1,CH,EQ,C'0'),BUILD=(01,05)
/*                                                         
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: Thu Oct 03, 2013 7:38 pm
Reply with quote

Yes, MOD will do it. but it uses more CPU than just testing the riight-most bit of the final byte for being 0 (even) or 1 (odd). Frank Yaeger said so :-) (Remember, Vasanthz?).

Using the SAVE is a good habit to get into. There's one fewer set of conditions to worry about, no tortuous negation which is sometimes necessary otherwise, and you can be sure all the records end up "somewhere" at least.

Where conditions are "theoretically" mutually exclusive but not logically so, I'd even code an extra OUTFIL, just to covered in case the spec was not correct on that :-) Then check that the OUTFIL is empty.
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: Thu Oct 03, 2013 7:52 pm
Reply with quote

Quote:
Yes, MOD will do it. but it uses more CPU than just testing the riight-most bit of the final byte for being 0 (even) or 1 (odd).

Thanks Bill. I was not aware of this.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Oct 04, 2013 3:37 am
Reply with quote

Bit data checking is efficient when compared to using MOD function.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Alternative of JoinKeys in SORT DFSORT/ICETOOL 2
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Simplify SORT CARD to combine INREC a... DFSORT/ICETOOL 6
No new posts Sort card to generate the DSN DFSORT/ICETOOL 17
Search our Forums:


Back to Top