MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Joinkeys, Calculating number of group records.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Thu Aug 25, 2016 2:56 pm    Post subject: Joinkeys, Calculating number of group records. Reply with quote

Hi,

Is there any other way to find group records count ?

Input LRECL=80 and output LRECL=80
The example below appears like input is sequence, but actually both the input files are not in sequence,

input

File1
Code:

111111111111111111   
2                   
3AAAAAAAAAAAAAA     
122222222222222222   
2                   
3BBBBBBBBBBBBBB     
133333333333333333   
2                   
3BBBBBBBBBBBBBB     


File2
Code:

111111111111111111
333333333333333333


output

Code:

AAAAAAA0203080082216
111111111111111111 
2                   
3AAAAAAAAAAAAAA         
133333333333333333
2                   
3BBBBBBBBBBBBBB     
BBBBBBB0200000020000006082216   


Code i tried
Code:

//SYMNAMES DD * 
HDATE,C'082216' 
//SYSIN    DD *                                   
  OPTION COPY                                     
                                                 
  JOINKEYS F1=INA,FIELDS=(81,17,A)               
  JOINKEYS F2=INB,FIELDS=(1,17,A)                 
                                                 
  REFORMAT FIELDS=(F1:1,80,98,1)                 
                                                 
  OUTFIL HEADER1=(C'AAAAAAA0203080',HDATE),       
         TRAILER1=(C'BBBBBBB02',                 
                   TOT=(81,1,ZD,EDIT=(TTTTTTT)), 
                   COUNT=(EDIT=(TTTTTTT)),HDATE) 
                                                 
//JNF1CNTL DD *                                   
  INREC IFTHEN=(WHEN=GROUP,                       
                BEGIN=(1,1,CH,EQ,C'1'),           
                END=(1,1,CH,EQ,C'3'),             
                PUSH=(81:2,17)),                 
                                                 
        IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),           
                OVERLAY=(98:C'1'))               


Dividing the total count by 3 will give the actual group record count and we can remove following code, but i don't know how to do it here. Please advise if this is possible.

Code:

        IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),   
                OVERLAY=(98:C'1'))




Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Thu Aug 25, 2016 4:12 pm    Post subject: Reply with quote

Magesh_J,

I am confused at your requirement. Do you want to find the number of group after the JOIN or just within the first file?
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Thu Aug 25, 2016 4:17 pm    Post subject: Reply with quote

Kolusu,

Thanks for looking into it, yes after JOIN i need to find the count of group records.


Regards,
Magesh
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Thu Aug 25, 2016 4:34 pm    Post subject: Reply with quote

Kolusu,

Also we can handle this if condition in Main task too. which would be more efficient.

Code:

REFORMAT FIELDS=(F1:1,80)
INREC    IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),           
                OVERLAY=(81:C'1'))



And i missed to restrict OUTFIL to 80 bytes.

Is there is a way to achieve this by dividing the count of records by 3. If we could do this then we can remove the IFTHEN overlay statement.

Regards,
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Thu Aug 25, 2016 6:23 pm    Post subject: Reply with quote

Magesh_J,

It is quite simple. Stop focusing on the idea of dividing by 3. You can use the JOIN indicator to figure out the count. If the JOIN indicator is "B" that means it matched, so you can check that indicator and actual group indicator of "1" So if the combination is B1 then obviously it is match and you need to count that as 1 group.

So here is a JCL which will give you the desired results. I also changed your Symnames to handle the System symbols. I assumed you wanted the current date in MMDDYY format.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYMNAMES DD *                                                     
HDATE,S'&LMON.&DAY.&LYR2'                                           
//SYMNOUT  DD SYSOUT=*                                             
//SYSOUT   DD SYSOUT=*                                             
//INA      DD *                                                     
111111111111111111                                                 
2                                                                   
3AAAAAAAAAAAAAA                                                     
122222222222222222                                                 
2                                                                   
3BBBBBBBBBBBBBB                                                     
133333333333333333                                                 
2                                                                   
3BBBBBBBBBBBBBB                                                     
144444444444444444                                                 
2                                                                   
3CCCCCCCCCCCCCC                         
//INB      DD *                                                     
111111111111111111                                                 
333333333333333333                                                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  JOINKEYS F1=INA,FIELDS=(81,17,A)                                 
  JOINKEYS F2=INB,FIELDS=(01,17,A)                                 
  JOIN UNPAIRED,F1                                                 
  REFORMAT FIELDS=(F1:1,80,?)                                       
                                                                   
  INREC IFOUTLEN=81,IFTHEN=(WHEN=INIT,                             
         OVERLAY=(82:01,1,                                         
                  81:81,2,CHANGE=(1,C'B1',C'1'),NOMATCH=(C'0')))   
                                                                   
  OUTFIL REMOVECC,BUILD=(1,80),                                     
         HEADER1=(C'AAAAAAA0203080',HDATE),                         
         TRAILER1=(C'BBBBBBB02',                                   
                   TOT=(81,1,ZD,EDIT=(TTTTTTT)),                   
                   COUNT=(EDIT=(TTTTTTT)),HDATE)                   
                                                                   
//*                                                                 
//JNF1CNTL DD *                                                   
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),PUSH=(81:2,17))
//*                                                               


The output from this job is
Code:

AAAAAAA0203080082516                   
111111111111111111                     
2                                       
3AAAAAAAAAAAAAA                         
122222222222222222                     
2                                       
3BBBBBBBBBBBBBB                         
133333333333333333                     
2                                       
3BBBBBBBBBBBBBB                         
144444444444444444                     
2                                       
3CCCCCCCCCCCCCC                         
BBBBBBB0200000020000012082516           

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Aug 26, 2016 10:12 am    Post subject: Reply with quote

Hi Kolusu,

Thanks, I am not even near to your thought process, great alternate thinking.


Regards
Magesh
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Oct 21, 2016 5:19 pm    Post subject: Reply with quote

Hi Kolusu,

Please add INCLUDE COND in the main task, since UNPAIRED, F1 gives matching + unmatched F1.

But we need matched record only

Code:

INCLUDE COND=(81,1,CH,EQ,C'B')   


thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Oct 21, 2016 8:53 pm    Post subject: Reply with quote

Magesh_J wrote:
Hi Kolusu,

Please add INCLUDE COND in the main task, since UNPAIRED, F1 gives matching + unmatched F1.

But we need matched record only

Code:

INCLUDE COND=(81,1,CH,EQ,C'B')   


thanks
Magesh


huh? If your intention is to just get the matched records, why bother with having the JOIN statement. The Default of Joinkeys is getting matched records. So if you eliminate the JOIN UNPAIRED,F1 statement completely you would get ONLY the matched records and you don't even need the INCLUDE statement.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Mon Oct 24, 2016 10:57 am    Post subject: Reply with quote

Thanks Kolusu.


Regards
Magesh
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group