Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
useit

Active User

Joined: 05 Oct 2006
Posts: 151

Posted: Thu Oct 03, 2013 4:58 pm    Post subject: seperate odd numbers and even numbers using SORT

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.

useit

Active User

Joined: 05 Oct 2006
Posts: 151

Posted: Thu Oct 03, 2013 5:09 pm    Post subject:

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    /*
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Thu Oct 03, 2013 5:21 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT Try it with your original sample data and let us know.
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

Posted: Thu Oct 03, 2013 6:00 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT

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
useit

Active User

Joined: 05 Oct 2006
Posts: 151

 Posted: Thu Oct 03, 2013 7:11 pm    Post subject: thanks a lot Bill..i tried this and it is working fine:)
mistah kurtz

Active User

Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

Posted: Thu Oct 03, 2013 7:18 pm    Post subject:

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) /*
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Thu Oct 03, 2013 7:38 pm    Post subject: Reply to: seperate odd numbers and even numbers using SORT 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.
mistah kurtz

Active User

Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

Posted: Thu Oct 03, 2013 7:52 pm    Post subject:

 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.
Skolusu

Senior Member

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

 Posted: Fri Oct 04, 2013 3:37 am    Post subject: Bit data checking is efficient when compared to using MOD function.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Parsing more than 1000 columns in a s... ssuthagar SYNCSORT 10 Tue Sep 22, 2020 12:23 am SORT the records based on the second ... Ramsee SYNCSORT 1 Wed Aug 19, 2020 3:01 pm Required Date Format in Include Sort ... vivky_vivek DFSORT/ICETOOL 6 Fri Aug 14, 2020 6:52 am Problem while trying to manipulate re... amitc23 DFSORT/ICETOOL 3 Tue Jun 30, 2020 1:19 pm Feild level validation to test first ... sruthi3466 JCL & VSAM 10 Thu Apr 23, 2020 2:47 pm

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us