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 

Select match and non-match withing a group.

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


Joined: 18 Apr 2016
Posts: 40
Topics: 12

PostPosted: Thu Aug 11, 2016 2:00 pm    Post subject: Select match and non-match withing a group. Reply with quote

Good day, need some help with the following.

Have a sequential dataset, RECFM=FB, LRECL=511.
Each record has account-number (1:15), delivery-loc (16:8) values.
Some records have verification-code value (344:10), others have spaces.

Task:
Group together all records that have the same account-number and delivery-loc, and select those with verification-code value.
Verification-code is unique for each account-number/delivery-loc pair.
If there is no verification-code on neither record within a group, just select the first one.
Also select all non-matching by account-number/delivery-loc records.

Input.
Code:

00000000AAZZ12300000111................................................................
00000000AAZZ12300000111...................PROVO17170......................
00000000AAZZ12300000111................................................................
00000000AAZZ12300000111...................PROVO17199......................
00000000AAZZ12300000111...............................................................
00000000AAZZ12300000222...............................................................
00000000AAZZ12300000222...................TREXA76680......................
00000000AAZZ12300000222...............................................................
00000000AAZZ12300000333...............................................................
00000000AAZZ12300000333...............................................................
00000000AAZZ12300000444...............................................................
00000000AAZZ12300000555...............................................................


Output.
Code:

00000000AAZZ12300000111...................PROVO17170....................
00000000AAZZ12300000111...................PROVO17199....................
00000000AAZZ12300000222...................TREXA76680.....................
00000000AAZZ12300000333...............................................................
00000000AAZZ12300000444...............................................................
00000000AAZZ12300000555...............................................................


Thanks.
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Thu Aug 11, 2016 4:13 pm    Post subject: Reply with quote

Here is the code for you.

Your input in 344 position appears to have low-values rather than spaces, If it is low value then you need to change the omit condition to omit low values rather than spaces.



Code:

//SYSIN   DD *                               
 SORT FIELDS=(001,23,CH,A,                   
              344,10,CH,D)                   
                                             
 SUM FIELDS=NONE                             
                                             
 OUTREC IFTHEN=(WHEN=GROUP,                 
                KEYBEGIN=(1,23),             
                PUSH=(512:SEQ=6))           
                                             
 OUTFIL OMIT=(344,10,CH,EQ,C'          ',AND,
              512,06,ZD,GT,1)               


I assumed you may have 999999 unique records maximum(6 bytes), if it is lesser you can reduce it accordingly

Code:

PUSH=(512:SEQ=6))   

512,06,ZD,GT,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 11, 2016 7:19 pm    Post subject: Reply with quote

Magesh_J,

Why do you need SUM FIELDS=NONE ? It is already established that the "Verification-code is unique for each account-number/delivery-loc pair." So it is mere waste of resources trying to remove the duplicates as you chose to remove the duplicate the records via GROUP clause. Also remember you need BUILD statement to remove the additional seqnum you built at the end.

You don't need to pad 10 spaces for the INCLUDE/OMIT condition as DFSORT internally pads the spaces to the length of the fields to be compared.

Code:

//SYSIN   DD *           
                 
 SORT FIELDS=(001,23,CH,A,                   
              344,10,CH,D)                   
                                             
 OUTREC IFTHEN=(WHEN=GROUP,                 
                KEYBEGIN=(1,23),             
                PUSH=(512:SEQ=6))           
                                             
 OUTFIL OMIT=(512,06,ZD,GT,1),BUILD=(1,511)
//*

_________________
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 12, 2016 1:12 am    Post subject: Reply with quote

Thanks Kolusu, you are right i missed it

Kolusu wrote:

Code:

//SYSIN   DD *           
                 
 SORT FIELDS=(001,23,CH,A,                   
              344,10,CH,D)                   
                                             
 OUTREC IFTHEN=(WHEN=GROUP,                 
                KEYBEGIN=(1,23),             
                PUSH=(512:SEQ=6))           
                                             
 OUTFIL OMIT=(512,06,ZD,GT,1),BUILD=(1,511)
//*



I think you missed (344,10,CH,EQ,C' ')

Updated code as per your advise
Code:

//SYSIN   DD *           
                 
 SORT FIELDS=(001,23,CH,A,                   
              344,10,CH,D)                   
                                             
 OUTREC IFTHEN=(WHEN=GROUP,                 
                KEYBEGIN=(1,23),             
                PUSH=(512:SEQ=6))           
                                             
 OUTFIL OMIT=(512,06,ZD,GT,1,AND,344,10,CH,EQ,C' '),BUILD=(1,511)
//*
Back to top
View user's profile Send private message
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 40
Topics: 12

PostPosted: Fri Aug 12, 2016 9:28 am    Post subject: Reply with quote

Thank you very much, kolusu and Magesh_J for your help and prompt responses.
I tested both versions and it seems like "344,10,CH,EQ,C' '" in the OMIT st-t can cause erroneous results in some cases. I used a small sample of data and the Magesh_J version picked up an extra record where kolusu version didn't.
Thanks again for your help.
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 Aug 12, 2016 10:07 am    Post subject: Reply with quote

Magesh_J wrote:
T
I think you missed (344,10,CH,EQ,C' ')


Not really. I deliberately omitted that check as it is a moot point to have it. Your check for 1 should eliminated any dups so there is no use for it and hence I removed it and from the looks of it OP does not need it.
_________________
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 12, 2016 11:18 am    Post subject: Reply with quote

Kolusu,

Sorry, Still not convinced.

Code:

00000000AAZZ12300000111...................PROVO17170....................
00000000AAZZ12300000111...................PROVO17199....................


in this case, the code suggest by you will remove below entry

Code:

00000000AAZZ12300000111...................PROVO17170....................


Thanks
Magesh
Back to top
View user's profile Send private message
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 40
Topics: 12

PostPosted: Fri Aug 12, 2016 12:45 pm    Post subject: Reply with quote

Magesh_J, sorry if my data representation threw you off.
A situation like the one below could never occur, and like I stated earlier, violation-code is unique for each account-number/delivery-loc record or group of records.
There could be the same violation-code for different account-number/delivery-loc, but not the other way around.

Code:

00000000AAZZ12300000111...................PROVO17170....................
00000000AAZZ12300000111...................PROVO17199....................
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