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

Can this be done with DFSORT?


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

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Wed Apr 22, 2015 4:59 pm
Reply with quote

Hi Bill,

I've now done a real test against the Danish streets. To do this, I first made the Streetcode 8,ZD, and the Housenumber 3,ZD - using your brilliant symbol file, that was a walk in the park.. icon_wink.gif

Now, there's an issue with my collegues street, Anyvej (we do call it Anyway icon_razz.gif).. There are some strange holes on this street. Here's the input:
Code:

00008548    002
00008548    004
00008548    006
00008548    008
00008548    009
00008548    010
00008548    011
00008548    012
00008548    013
00008548    014
00008548    016
00008548    020
00008548    022
00008548    024
00008548    026
00008548    028

And output:
Code:

STREETCODE     HOUSE-FR  HOUSE-TO  EVEN/ODD
00008548         009       013         O   
00008548         016       016         E   
00008548         020       028         E   

Somehow, it misses out on the first even interval from 2-16, and only registers 16? Maybe this has to do with your recent change?

BR, Claes
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: Wed Apr 22, 2015 6:13 pm
Reply with quote

Hi Claes,

I made that street number 7, and used only two-digit house numbers and got this:
Code:

7          09          13              O
7          02          16              E
7          20          28              E


Whilst attempting this I did make a mistake by not increasing the size of OUTJ-RECORD and things got confusing. Once I changed 10 to 11 it was OK.

The other tricky part of the change is to get the last digit of the house number for odd/even. For three digits it would be:

Code:
  INJ-HOUSE-NO,*,3,ZD
  POSITION,INJ-HOUSE-NO
  SKIP,2
  INJ-HOUSE-NO-LAST,*,1,ZD


The curious thing is that I'd expect there to be more items listed (if something is out with the definitions) rather than have something go missing.

So I made the full change to match your data, and got this (with my HEADING1):

Code:
STREET            HOUSEFROM    HOUSETO   EVEN/ODD
00008548          009          013              O
00008548          002          016              E
00008548          020          028              E


This is the complete symbol file I used for that output:

Code:
* INPUT RECORD TO JNFNCNTL
 INJ-STREET-REF,1,8,CH
 SKIP,4
 INJ-HOUSE-NO,*,3,ZD
 POSITION,INJ-HOUSE-NO
 SKIP,2
 INJ-HOUSE-NO-LAST,*,1,ZD
* EXTENSION FROM JNFNCNTL
 EXTJ-LAST-OF-NUMBER-BITS,*,8,CH
 POSITION,EXTJ-LAST-OF-NUMBER-BITS
 SKIP,7
 EXTJ-LAST-BIT-OF-BITS,*,1,CH
* OUTPUT FROM JNFNCNTL
 OUTJ-RECORD,1,19,CH
 OUTJ-STREET-REF,1,8,CH
 OUTJ-ODDEVEN-BIT,*,1,CH
 OUTJ-NUMBER,*,3,CH
 OUTJ-ODDEVEN-SEQ,*,7,CH
* REFORMAT RECORD
 REF-F1-STREET,1,8,CH
 REF-F1-ODDEVEN,*,1,CH
 POSITION,REF-F1-STREET
 REF-F1-STREET-ODDEVEN,=,9,CH
 REF-F1-NUMBER,*,3,ZD
 REF-F1-SEQUENCE,*,7,CH
 REF-F2-STREET,*,8,CH
 REF-F2-ODDEVEN,*,1,CH
 POSITION,REF-F2-STREET
 REF-F2-STREET-ODDEVEN,=,9,CH
 REF-F2-NUMBER,*,3,ZD
 REF-F2-SEQUENCE,*,7,CH
* EXTEND REFORMAT RECORD
 REFEX-NUMBER-DIFF,*,5,CH
 REFEX-START-NUMBER,*,3,CH
 REFEX-SAVE-F2-NUMBER,*,3,CH
 REFEX-SEQ,*,1,BI
 REFEX-LEFT-DIFF,*,5,CH     


I'll try some more testing as well, I think.

I'll also see if I can improve on the symbol definitions, there are several places needing lengths to be changed: it would be nice if there were just one :-)

If your symbols match the above, can you post the previous street to the one where you see the problem, please?
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Wed Apr 22, 2015 7:20 pm
Reply with quote

Hi Bill,

I've got the exact same symbol file - except that I've defined
Code:
INJ-LRECL,*
right after
Code:
EXTJ-LAST-BIT-OF-BITS
and also (on page 2 that you did not present):
Code:
  REFEX-RIGHT-DIFF,*,5,CH   
  REFEX-LRECL,*             
* VALUES                     
  EVEN-BIT-VALUE,C'0'       
  ODD-BIT-VALUE,C'1'         
  DIFFERENCE-OF-TWO,C'00002'

Here, I added the
Code:
  REFEX-LRECL,*
field.

The LRECL fields I use in INREC IFOUTLEN=lrecl - just to be able to indent like I wish to...
Code:
OUTREC IFOUTLEN=REFEX-LRECL,                         
  IFTHEN=(WHEN=INIT,                                 
    OVERLAY=(REFEX-NUMBER-DIFF:                       
      REF-F2-NUMBER,SUB,REF-F1-NUMBER,TO=ZD,LENGTH=5,
      REFEX-SEQ:SEQNUM,1,ZD)),                       
I'm positive this won't affect output, right?

I've isolated the test to just Anyvej - meaning I use this input:
Code:
00008548    002
00008548    004
00008548    006
00008548    008
00008548    009
00008548    010
00008548    011
00008548    012
00008548    013
00008548    014
00008548    016
00008548    020
00008548    022
00008548    024
00008548    026
00008548    028
For this input, I get this output:
Code:
STREETCODE     HOUSE-FR  HOUSE-TO  EVEN/ODD
00008548         009       013         O   
00008548         016       016         E   
00008548         020       028         E   
Can you please verify you get the correct output using my input file here - then I must have copied something wrong somewhere..

BR
/Claes
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: Wed Apr 22, 2015 7:38 pm
Reply with quote

That data was the same as I had. I ran it anyway, and it produced the same results as I showed previously:

Code:
STREET            HOUSEFROM    HOUSETO   EVEN/ODD
00008548          009          013              O
00008548          002          016              E
00008548          020          028              E


That "lrecl" is a nice thing. I can' do that, as I don't have DFSORT 2.1, which greatly extended the places where a symbol could be used. It adds one unnecessary byte, but a small price to pay in this type of situation.

I can't imagine how the IFOUTLEN would affect the results. I'll try a manual one anyway.
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: Wed Apr 22, 2015 7:49 pm
Reply with quote

Using IFOUTLEN=61 didn't affect the results.

I'm wondering if something went wrong when you re-indented?

Here's the cards I'm running after the symbol conversion:

Code:
JOINKEYS F1=INA,FIELDS=(13,7,A)                                       
JOINKEYS F2=INB,FIELDS=(13,7,A)                                       
 JOIN UNPAIRED,F1                                                     
REFORMAT FIELDS=(F1:1,19,F2:1,19)                                     
SORT FIELDS=(1,8,CH,A,9,1,CH,D,10,3,ZD,A),EQUALS                       
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(39:29,3,ZD,SUB,10,3,ZD,TO=ZD,LENGTH=*
              5,50:SEQNUM,1,ZD)),IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,9),PUS*
              H=(44:10,3,10,3)),IFTHEN=(WHEN=GROUP,BEGIN=(39,5,CH,NE,C*
              '00002',AND,1,9,CH,EQ,20,9,CH),END=(1,9,CH,NE,20,9,CH),P*
              USH=(47:29,3)),IFTHEN=(WHEN=GROUP,BEGIN=(50,1,BI,EQ,B'..*
              .....1'),RECORDS=2,PUSH=(51:39,5)),IFTHEN=(WHEN=GROUP,BE*
              GIN=(50,1,BI,EQ,B'.......0'),RECORDS=2,PUSH=(56:39,5)),I*
              FTHEN=(WHEN=(1,9,CH,NE,20,9,CH),OVERLAY=(44:47,3)),IFTHE*
              N=(WHEN=(56,5,CH,NE,C'00002',AND,51,5,CH,NE,C'00002'),OV*
              ERLAY=(44:10,3)),IFOUTLEN=61                             
OUTFIL INCLUDE=(1,9,CH,NE,20,9,CH,OR,39,5,CH,NE,C'00002'),BUILD=(1,8,1*
              0X,44,3,10X,10,3,10X,4X,9,1,CHANGE=(1,C'0',C'E',C'1',C'O*
              ')),HEADER1=('STREET            HOUSEFROM    HOUSETO   E*
              VEN/ODD')                                               
OUTFIL FNAMES=TMPD 


And:

Code:
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(16:15,1,TRAN=BIT)),IFTHEN=(WHEN=(23,1*
               ,CH,EQ,C'0'),BUILD=(1,8,23,1,13,3,SEQNUM,7,ZD,START=5000*
               000)),IFTHEN=(WHEN=NONE,BUILD=(1,8,23,1,13,3,SEQNUM,7,ZD*
               ,START=1))                                               


And:

Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(16:15,1,TRAN=BIT)),IFTHEN=(WHEN=(23,1*
              ,CH,EQ,C'0'),BUILD=(1,8,23,1,13,3,SEQNUM,7,ZD,START=4999*
              999)),IFTHEN=(WHEN=NONE,BUILD=(1,8,23,1,13,3,SEQNUM,7,ZD*
              ,START=0))
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 11:26 am
Reply with quote

Hi Bill,

I found my mistake. icon_redface.gif

I couldn't find your definition for AN-ODD-NUMBER and AN-EVEN-NUMBER, so I guessed - but guessed wrong. Now I get the same result as you do. icon_smile.gif

I'll perform some more tests today.

Thanks again,
Claes
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 11:46 am
Reply with quote

Hi Bill,

I'm sorry, but there seems to be an issue more. Giving this input:

Code:
00000024    001
00000024    002
00000024    003
00000024    006
00000024    007
00000024    008
00000024    009
00000024    010
00000024    011
00000024    012
00000024    013
00000024    014
00000024    015
00000024    016
00000024    017
00000024    018
00000024    020
00000024    021
00000024    023
00000024    024
00000024    025
00000024    026
00000024    027
00000024    028
00000024    029
00000024    031
00000024    033

I get this:
Code:
STREETCODE     HOUSE-FR  HOUSE-TO  EVEN/ODD
00000024         001       003         O   
00000024         001       017         O   <== 7-17 expected
00000024         021       033         O   
00000024         002       002         E   
00000024         002       020         E   <=== 6-20 expected
00000024         024       028         E

Can you please verify you get the same?

/Claes
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 Apr 23, 2015 11:59 am
Reply with quote

Yes. I get the same. Looking.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 1:04 pm
Reply with quote

Bill Woodger wrote:
That "lrecl" is a nice thing. I can' do that, as I don't have DFSORT 2.1, which greatly extended the places where a symbol could be used. It adds one unnecessary byte, but a small price to pay in this type of situation.

Didn't see this post at first. Yes, I agree. A small price to pay. Would be fantastic if we could have calculations in symbols..
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 Apr 23, 2015 2:16 pm
Reply with quote

Claes,

If you add this as the last GROUP in the OUTREC:
Code:

        IFTHEN=(WHEN=GROUP,
                  BEGIN=(REFEX-NUMBER-DIFF,
                          EQ,
                         DIFFERENCE-OF-TWO,
                        AND,
                        (REFEX-LEFT-DIFF,
                          NE,
                         DIFFERENCE-OF-TWO,
                         OR,
                         REFEX-RIGHT-DIFF,
                          NE,
                         DIFFERENCE-OF-TWO)),
                  PUSH=(REFEX-START-NUMBER:
                         REFEX-SAVE-F2-NUMBER)),
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 2:26 pm
Reply with quote

Bill, the last comma in your code makes me wonder where to put it exactly, because last group would be right before OUTFIL - thus the comma shouldn't be there?

Edit: got it.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 2:40 pm
Reply with quote

I think you nailed it, Bill! icon_biggrin.gif
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Apr 23, 2015 9:16 pm
Reply with quote

In the mean time, I also worked a little more and got something working. I know it's not the best but I believe it's easier to debug and understand what is being done if you use multiple steps. I know Bill would not agree but that would be me doing it ;-)

1. Identify Even/Odd.

2. ICETOOL Step: Run this step 2 times using Even and Odd file separately. You'll get 2 output files (one from each run):
Code:
//TOOLIN DD *                                         
 COPY FROM(IN) TO(T1) USING(CTL1)                     
 COPY FROM(IN) TO(T2) USING(CTL2)                     
 COPY FROM(T1) TO(OUT) USING(CTL3)                   
/*                                                   
//CTL1CNTL DD *                                       
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,2,ZD))   
 SORT FIELDS=(17,2,CH,A)                             
/*                                                   
//CTL2CNTL DD *                                       
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,2,ZD))   
 SORT FIELDS=(17,2,CH,A),                             
 SKIPREC=1                                           
/*                                                   
//CTL3CNTL DD *                                       
 JOINKEYS F1=T1,FIELDS=(17,2,A)                       
 JOINKEYS F2=T2,FIELDS=(17,2,A)                       
 REFORMAT FIELDS=(F1:13,3,                           
 F2:13,3,F1:1,8)                                     
 OPTION COPY                                         

3. Another ICETOOL using both the files we got from Step 2 and that is it:
Code:
//TOOLIN DD *                                                         
 COPY FROM(IN1) TO(T1) USING(CTL1)               
 COPY FROM(IN2) TO(T1) USING(CTL1)                             
 SELECT FROM(T1) TO(OUT) ON(10,3,CH) FIRST USING(CTL2)                 
/*                                                                     
//CTL1CNTL DD *                                                       
 INREC BUILD=(1,14,15:(4,3,ZD,SUB,1,3,ZD))                             
 OUTREC IFTHEN=(WHEN=(15,15,ZD,GT,2),BUILD=(1,6,3X,10:C'B',X,7,8)),   
        IFTHEN=(WHEN=(15,15,ZD,EQ,2),BUILD=(1,6,X,8:C'A',3X,7,8))     
/*                                                                     
//CTL2CNTL DD *                                                       
 INREC IFTHEN=(WHEN=GROUP,                                             
         END=(10,1,CH,EQ,C'B'),PUSH=(21:1,3)),                         
      IFTHEN=(WHEN=(10,1,CH,EQ,C'B'),BUILD=(12,8,X,21,3,X,C'-',X,1,3)),
      IFTHEN=(WHEN=(8,1,CH,EQ,C'A'),BUILD=(12,8,X,21,3,X,C'-',X,4,3)) 
 SORT FIELDS=(10,3,CH,A,16,3,CH,D)                                     
/*                                                                     


I gave Input as
Code:
00000024    001
00000024    002
00000024    003
00000024    006
00000024    007
00000024    008
00000024    009
00000024    010
00000024    011
00000024    012
00000024    013
00000024    014
00000024    015
00000024    016
00000024    017
00000024    018
00000024    020
00000024    021
00000024    023
00000024    024
00000024    025
00000024    026
00000024    027
00000024    028
00000024    029
00000024    031
00000024    033


And got OUTPUT as:
Code:
00000024 001 - 003
00000024 006 - 020
00000024 007 - 017
00000024 021 - 033
00000024 024 - 028


Claes,

Could you please try this one as well with your different Inputs to see if it works? I am just curious to know whether the approach fetched me the right results
.
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 Apr 23, 2015 10:10 pm
Reply with quote

The required output for that data is:

Code:
00000024 001 - 003
00000024 007 - 017
00000024 021 - 033
00000024 006 - 020
00000024 024 - 028


Your 2) is a long way round. You can just do a JOINKEYS with JNFnCNTL files. The SKIPREC gives the same effect as starting the sequence from 0/1 for the different files.

Then the point of you running it twice is for the odd and the even. So with the odd/even embedded in the file, it comes back to the JOINKEYS.

Everything in your 3) can be done in the Main Task of a JOINKEYS. So you have the two JNFnCNTLs, the two JOINKEYS, and the Main Task with SORT and OUTREC.

Not sure how that makes it more complicated :-)

Sure, I've had to change mine twice, but that's because I pickled it in the first place...
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Apr 23, 2015 11:31 pm
Reply with quote

@Bill: When I first looked at your earlier posts, I thought it would be complicated and I would not be able to achieve it. But then, somehow, I got some courage to try more on that to get to the above post of mine.

You have already given the solution but since I had also put some efforts, I want Claes to say it is also working and make me feel happy about it :-)

.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Apr 23, 2015 11:34 pm
Reply with quote

RahulG, I will for sure test your solution and compare it to Bill's tomorrow. icon_smile.gif
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Fri Apr 24, 2015 4:28 pm
Reply with quote

RahulG, where is the code for step 1? I'm confused.. icon_question.gif
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Apr 24, 2015 6:26 pm
Reply with quote

I thought it was already given earlier, so I skipped it.

Step 1: To identify Even/Odd:
Code:
//SYSIN DD *                                         
  OPTION COPY                                       
  OUTFIL FNAMES=EVEN,INCLUDE=(15,1,BI,EQ,B'.......0')
  OUTFIL FNAMES=ODD,SAVE                             
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts DFSORT - VB file RDW getting overridden DFSORT/ICETOOL 3
Search our Forums:

Back to Top