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

Author Message
srm_s

New User

Joined: 29 Dec 2011
Posts: 5
Location: US

Posted: Thu Dec 29, 2011 10:31 pm    Post subject: DFSORT- Compare two Alphanumeric ranges

Hi All,
I have a requirment to find a range between the records in the input file.

input file: 3 bytes Alphanumeric

039
040
041
069
10K
12K
12L
14J
15J
150
164
16A
16B
16C
171
expected output:
039 041
069 069
10K 10K
12K 12L
14J 14J
15J 15J
150 150
164 164
16A 16C
171 171

output record 1 : 039 041 <= grouped input rec 1,input rec 2,input rec 3 since they a continuous range.
output record 2 : 069 069 <= not a continous range,so written as same starting and ending range.

I tried to acheive this by Eztrieve, I read the input as NUMERIC and found the DIFF of the two records and written the output when the numeric difference is > 1. Its not working properly for few ranges like the one shown below.

input
15J
150

expected output
15J 15J
150 150

actual ouput
15J 150 <= which finding the differnce of X(F1F5D1) and X(F1F5F0), it came with a diff of 1 so considered these are a consecutive numbers.but they are not so, after 15J , 15K thru Z should follow.

151

 Code: //STEPLIB   DD DSN=SYSSUPP.EZTRIEVE.V6R1.LOAD,DISP=SHR                  //          DD DSN=SYS3.MVSV5.RUNTIME,DISP=SHR                          //         DD DISP=SHR,DSN=SYS3.MVSV5.RUNTIME   INSERTED FOR LE RUNTIME //SYSPRINT  DD SYSOUT=*                                                  //SYSSNAP   DD SYSOUT=*                                                  //SYSOUT    DD SYSOUT=*                                                  //PRT1      DD SYSOUT=*                                                  //EZTVFM    DD UNIT=SYSDA                                                //MSSB      DD DSN=SSYG.USER.SSY311.MSSBBR.CUT1,DISP=SHR                //REP1      DD DSN=SSYG.USER.SSY311.MSSBBR.CUT1RPT,                      //*            DISP=SHR                                                  //             DISP=(NEW,CATLG,DELETE),                                  //             DCB=(RECFM=FBA,LRECL=80,BLKSIZE=0)                        //SYSIN     DD *                                                        FILE MSSB FB (80 ,  0)            MS-BRCH   03 03 N                  MS-BRCH-A 03 03 A                                                    FILE REP1 FB (50 ,  0)            WS-START-BR   02 03 A              WS-END-BR     12 03 A              *                        WS-BR1 W 5 N            WS-BR2 W 5 N            WS-BR1A W 3 A            WS-BR2A W 3 A            WS-DIFF  W 5 N          JOB INPUT NULL  START INIT-PROC                              *                                                                 DO WHILE (  MS-BRCH-A NE ' ' OR NOT EOF MSSB )                 GET MSSB                                                      IF EOF MSSB                                                     DISPLAY 'HOLD EOD'                                           GOTO RAJA                                                  ELSE                                                             WS-BR2 = MS-BRCH                                             WS-BR2A = MS-BRCH-A                                        END-IF                                                       WS-DIFF = WS-BR1 - WS-BR2                                     DISPLAY 'DIFF:' WS-BR1A '::' WS-BR2A '::' WS-DIFF             IF WS-DIFF > 1                                                  WS-END-BR =   WS-BR1A                                        PUT REP1            WS-BR1 = MS-BRCH                        WS-START-BR = MS-BRCH                    WS-BR1A = MS-BRCH-A                      WS-START-BR = MS-BRCH-A                ELSE                                     WS-BR1 = MS-BRCH                     WS-BR1A = MS-BRCH-A                END-IF                              END-DO                             *****                                 RAJA                                  DISPLAY 'FINSHED'                    STOP                               INIT-PROC. PROC                       GET MSSB                                    WS-BR1 = MS-BRCH                      WS-START-BR = MS-BRCH                WS-BR1A = MS-BRCH-A                  WS-START-BR = MS-BRCH-A       END-PROC

dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Thu Dec 29, 2011 11:15 pm    Post subject: why go to a 5 char workarea from a 3 char????? change all from numeric to BINARY. then everything will work.
srm_s

New User

Joined: 29 Dec 2011
Posts: 5
Location: US

 Posted: Thu Dec 29, 2011 11:17 pm    Post subject: SOLVED Solved the issue,but using DFSORT TRAN function to convert the alpha to Hex and then used that to find the difference between two hex values after the EZ output used UNHEX to convert back to Alphanumeric.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Thu Dec 29, 2011 11:17 pm    Post subject: Reply to: DFSORT- Compare two Alphanumeric ranges Do you really have two different types of data here? One, a three-digit numeric, and the other a two-digit numeric plus an alpha? If so, what happens after 16Z? Is 17A the next in the sequence? If not, can you explain the three-character fields more exactly, please?
srm_s

New User

Joined: 29 Dec 2011
Posts: 5
Location: US

 Posted: Thu Dec 29, 2011 11:21 pm    Post subject: thanks Dick, defined the input as 3 byte Binary, working as expected.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Fri Dec 30, 2011 12:00 am    Post subject: Reply to: DFSORT- Compare two Alphanumeric ranges

Well, if you're happy...

 Code: 038 F0F3F8 039 F0F3F9 040 F0F4F0

If you are saying that, in the Easytrieve, you defined the fields as binary and then carried on with the calculations as is, I can see 038 to 039 "working", but how does it lnow that 040 is next?

Even ignoring that you are doing the subtraction the "wrong way round" and getting the answer of one or greater than one because you are using an unsigned fielld as your result, when you do the 039 - 040, in binary, you are not going to get an answer of one.

Also, with the letters, how does I get to be included with J, and R with S?

I'd like to see the code you have.

If you've got your solution with Easytrieve, this topic should go to the CA forum. although if we leave it here tonight, we might see the DFSORT solution anyway...
Skolusu

Senior Member

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

Posted: Fri Dec 30, 2011 1:05 am    Post subject:

The following DFSORT JCL will give you the desired results

 Code: //STEP0100 EXEC PGM=SORT                                            //SYSOUT   DD SYSOUT=*                                              //SORTIN   DD *                                                    039                                                                040                                                                041                                                                069                                                                10K                                                                12K                                                                12L                                                                14J                                                                15J                                                                150                                                                164                                                                16A                                                                16B                                                                16C                                                                171                                                                //SORTOUT  DD SYSOUT=*                                              //SYSIN    DD *                                                      SORT FIELDS=COPY                                                    INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,3,X)),                        IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=83,                            INOUT=(C'A',C'01',C'B',C'02',C'C',C'03',C'D',C'04',C'E',C'05',             C'F',C'06',C'G',C'07',C'H',C'08',C'I',C'09',C'J',C'10',             C'K',C'11',C'L',C'12',C'M',C'13',C'N',C'14',C'O',C'15',             C'P',C'16',C'Q',C'17',C'R',C'18',C'S',C'19',C'T',C'20',             C'U',C'21',C'V',C'22',C'W',C'23',C'X',C'24',C'Y',C'25',             C'Z',C'26'))),                                                                                                                  IFTHEN=(WHEN=(84,1,CH,EQ,C' '),OVERLAY=(81:C'0',82:1,3))                                                                                OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(86:SEQNUM,4,ZD)),                IFTHEN=(WHEN=INIT,                                                  OVERLAY=(91:81,4,ZD,SUB,86,4,ZD,M11,LENGTH=8)),                    IFTHEN=(WHEN=GROUP,KEYBEGIN=(91,8),PUSH=(10:1,3))                                                                                      OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                              SECTIONS=(10,3,TRAILER3=(10,3,' --> ',1,3))                      //*

The output of this is
 Code: 039 --> 041 069 --> 069 10K --> 10K 12K --> 12L 14J --> 14J 15J --> 15J 150 --> 150 164 --> 164 16A --> 16C 171 --> 171
srm_s

New User

Joined: 29 Dec 2011
Posts: 5
Location: US

Posted: Fri Dec 30, 2011 1:38 am    Post subject:

Hi Bill,
you are right, i got some junk characters when I tried to convert Binary to Alpha in EZ. As you pointed out the sequence for 39,39,40 was not considered as consecutive number.
 Code: 038 F0F3F8 039 F0F3F9 040 F0F4F0

I'll leave the EZ way,and try out the DFSORT from Kolusu
srm_s

New User

Joined: 29 Dec 2011
Posts: 5
Location: US

Posted: Fri Dec 30, 2011 1:45 am    Post subject:

Kolusu,

DFSORT is bang on target. I missed to tell you that the Alpha char can appear in any of those 3 positions. Maybe I should have posted a clear cut input seq.

input:

 Code: 039                                                                040                                                                041                                                                069                                                                1AA 1A0 1C5 10K                                                                12K                                                                12L                                                                AAA B21

Please tell me who I should modify the sort to parse out the Alpha to number on all 3 postions.
Skolusu

Senior Member

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

Posted: Fri Dec 30, 2011 2:21 am    Post subject: Reply to: DFSORT- Compare two Alphanumeric ranges

srm_s,

try this

 Code: //STEP0100 EXEC PGM=SORT                                              //SYSOUT   DD SYSOUT=*                                                //SORTIN   DD *                                                        039                                                                    040                                                                    041                                                                    069                                                                    1AA                                                                    1A0                                                                    1C5                                                                    10K                                                                    12K                                                                    12L                                                                    AAA                                                                    B21                                                                    //SORTOUT  DD SYSOUT=*                                                //SYSIN    DD *                                                          SORT FIELDS=COPY                                                      INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:1,3,3X)),              IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,                                INOUT=(C'A',C'01',C'B',C'02',C'C',C'03',C'D',C'04',C'E',C'05',               C'F',C'06',C'G',C'07',C'H',C'08',C'I',C'09',C'J',C'10',               C'K',C'11',C'L',C'12',C'M',C'13',C'N',C'14',C'O',C'15',               C'P',C'16',C'Q',C'17',C'R',C'18',C'S',C'19',C'T',C'20',               C'U',C'21',C'V',C'22',C'W',C'23',C'X',C'24',C'Y',C'25',               C'Z',C'26'))),                                                  IFTHEN=(WHEN=INIT,OVERLAY=(81:81,6,UFF,M11,LENGTH=6,SEQNUM,6,ZD)),    IFTHEN=(WHEN=INIT,OVERLAY=(93:81,6,ZD,SUB,87,6,ZD,M11,LENGTH=8)),      IFTHEN=(WHEN=GROUP,KEYBEGIN=(93,8),PUSH=(10:1,3))                                                                                            OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                                  SECTIONS=(10,3,TRAILER3=(10,3,' --> ',1,3))                          //*
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

Posted: Fri Dec 30, 2011 4:24 am    Post subject:

 Bill wrote: 038 to 039 "working", but how does it lnow that 040 is next

that is because 040 is not next.
04A is next.................

ALPHA will not work, because you can not add or subtract from APHA.

just so happens we are dealing with sorting sequence,
and not counting in hexidecimal.
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Fri Dec 30, 2011 4:33 am    Post subject: don't think that this is an overpunch numeric field. otherwise, they would all be. i believe that it is a 3 char field, with 36 possibilities for each char. A-Z,0-9. 36 cubed - that is more than 46K which is more than the 1000 that you would get from numerics and the 4096 you get when you count in hex.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Sun Jan 01, 2012 6:48 am    Post subject: Reply to: DFSORT- Compare two Alphanumeric ranges I've put an Easytrieve solution in the CA part of the forum, here. Do I need to warn anybody not to click on the link in the other post? Probably not.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Need urgent suggestion on DFSORT subratarec DFSORT/ICETOOL 6 Wed Mar 21, 2018 8:46 pm Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am Compare two PS files using ICE TOOL f... SENTHIL MURUGAAN DFSORT/ICETOOL 5 Sun Dec 24, 2017 1:26 pm Formatting using DFsort Guru Nandu DFSORT/ICETOOL 5 Thu Nov 30, 2017 7:33 am Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am

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