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
 

 

seperate odd numbers and even numbers using SORT

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

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Thu Oct 03, 2013 4:58 pm    Post subject: seperate odd numbers and even numbers using SORT
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: 141

PostPosted: Thu Oct 03, 2013 5:09 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Oct 03, 2013 5:21 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Oct 03, 2013 6:00 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT
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: 141

PostPosted: Thu Oct 03, 2013 7:11 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Oct 03, 2013 7:18 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Oct 03, 2013 7:38 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Oct 03, 2013 7:52 pm    Post subject:
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    Post subject:
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    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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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