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 

Data reassignment in DFSORT.

 
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: 43
Topics: 14

PostPosted: Tue Aug 23, 2016 11:48 am    Post subject: Data reassignment in DFSORT. Reply with quote

Hi, I have a sequintial file, FB, LRECL=77

File has DEST-ID (1:11) and TRANS-RCPT (68:10) fields.
DEST-ID is mandatory, where TRANS-RCPT may or may not have value.

I need to search the entire file, find matching TRANS-RCPTs, and move all records from DEST-ID "B" of a matching pair
to DEST-ID "A", assigning them all DEST-ID "A" value. There could be more than 2 matches on the same TRANS-RCPT.
Also, the rest of records that either didn't have matching TRANS-RCPT or have no value in that field at all, should also
be placed into output seq. dataset, so the output has the same number of records as input.

Is something like that possible with DFSORT?
Thanks.

Input.
Code:

ZZR19984M15  record-1                 
ZZR19984M15  record-2              0000000106
QQWM998401W  record-3              0000000106
78N74B332TT  record-4              0000000113
78N74B332TT  record-5                       
876HAGS5S26  record-6                                 
LLKJ487HJAS  record-7              0000000138
8CNMN43489H  record-8              0000000113
653244BNBSA  record-9                       
VNSEPP1112A  record-10              0000000106                 
VNSEPP1112A  record-11                               
VNSEPP1112A  record-12                               


Output.
Code:

ZZR19984M15  record-1                 
ZZR19984M15  record-2              0000000106
ZZR19984M15  record-3              0000000106
ZZR19984M15  record-10              0000000106                 
ZZR19984M15  record-11                               
ZZR19984M15  record-12                               
78N74B332TT  record-4              0000000113
78N74B332TT  record-5
78N74B332TT  record-8              0000000113                       
876HAGS5S26  record-6                                 
LLKJ487HJAS  record-7              0000000138
653244BNBSA  record-9                       
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Aug 23, 2016 12:19 pm    Post subject: Reply with quote

ramy2016,

Your Output does NOT match the requirements. How did you have 876HAGS5S26 record-6 after 78N74B332TT record-8. Shouldn't it be after record-5 ?

You have moved

Code:

VNSEPP1112A  record-10              0000000106                 
VNSEPP1112A  record-11                               
VNSEPP1112A  record-12                           


right after

Code:

ZZR19984M15  record-2              0000000106
QQWM998401W  record-3              0000000106


But then you did not do the same for

Code:

78N74B332TT  RECORD-4            0000000113   
78N74B332TT  RECORD-5                                                           
876HAGS5S26  RECORD-6                                                           

_________________
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: Tue Aug 23, 2016 6:43 pm    Post subject: Reply with quote

ramy2016,

ramy2016 wrote:

DEST-ID "B" of a matching pair
to DEST-ID "A", assigning them all DEST-ID "A" value.


Which one is DEST-ID "A" and which one is DEST-ID "B" here ?


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


Joined: 18 Apr 2016
Posts: 43
Topics: 14

PostPosted: Wed Aug 24, 2016 11:10 am    Post subject: Reply with quote

kolusu, the main idea here is that upon match on TRANS-RCPT, records should get included under the same DEST-ID, regardless
of their order within DEST-ID group.

Thia is what should happen.

1.record-2 from DEST-ID ZZR19984M15 that had a TRANS-RCPT of 0000000106 got matched to the record-3 having the same TRANS-RCPT.
record-3 from DEST-ID QQWM998401W got moved to the DEST-ID ZZR19984M15.
record-10 from DEST-ID VNSEPP1112A also got matched on TRANS-RCPT of 0000000106, so it got moved to the DEST-ID ZZR19984M15.
remaining record-11, record-12 from DEST-ID VNSEPP1112A also became ZZR19984M15.

That resulted in
Code:

ZZR19984M15  record-1                 
ZZR19984M15  record-2              0000000106
ZZR19984M15  record-3              0000000106
ZZR19984M15  record-10              0000000106                 
ZZR19984M15  record-11                               
ZZR19984M15  record-12                               


2.record-4 from 78N74B332TT matched on TRANS-RCPT of 0000000113 to record-8 from 8CNMN43489H
record-8 went from 8CNMN43489H to 78N74B332TT, resulting in

Code:

78N74B332TT  record-4              0000000113
78N74B332TT  record-5
78N74B332TT  record-8              0000000113



3.record-6 from 876HAGS5S26 didn't have a matching TRANS-RCPT, so no changes there - goes to the output.
4.record-7 from LLKJ487HJAS didn't have a matching TRANS-RCPT, so no changes there - goes to the output.
5.record-9 from 653244BNBSA didn't have a matching TRANS-RCPT, so no changes there neither - goes to the output.

Final Output.
Code:

ZZR19984M15  record-1                 
ZZR19984M15  record-2              0000000106
ZZR19984M15  record-3              0000000106
ZZR19984M15  record-10              0000000106                 
ZZR19984M15  record-11                               
ZZR19984M15  record-12                               
78N74B332TT  record-4              0000000113
78N74B332TT  record-5
78N74B332TT  record-8              0000000113                       
876HAGS5S26  record-6                                 
LLKJ487HJAS  record-7              0000000138
653244BNBSA  record-9                       



Magesh_J

By DEST-ID "A" and DEST-ID "B" I meant to indicate the 1st and 2nd entities in a matching pair.
For ex.
DEST-ID "A" - ZZR19984M15 record-2 0000000106
DEST-ID "B" - QQWM998401W record-3 0000000106
where upon match, they both get DEST-ID "A" value of ZZR19984M15.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Aug 24, 2016 11:44 am    Post subject: Reply with quote

ramy2016,

Do you need to retain the original order of the records for the space records or is it okay if the values are transposed for the mathcing TRANS-RCPT? If you need the original order then you need 2 passes of data.
_________________
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: Wed Aug 24, 2016 3:09 pm    Post subject: Reply with quote

If we need not maintain the order then use the below code.
Code:

//STEP01  EXEC PGM=SORT                                             
//SORTIN  DD DSN=YOUR INPUT FILE                                   
//SORTOUT DD DSN=&&TEMP,DISP=(,CATLG,DELETE),                       
//           SPACE=(CYL,(1,1),RLSE)                                 
//SYSOUT  DD SYSOUT=*                                               
//SYSIN   DD *                                                      \

  INREC IFTHEN=(WHEN=INIT,
                OVERLAY=(90:SEQNUM,8,ZD)),               

        IFTHEN=(WHEN=GROUP,
                KEYBEGIN=(1,11),
                PUSH=(81:ID=8)), 
       
        IFTHEN=(WHEN=(68,10,CH,EQ,C' '),
                OVERLAY=(89:C'A'))
         
  SORT FIELDS=(81,08,ZD,A,
               68,10,CH,D) 
                             
  OUTREC IFTHEN=(WHEN=GROUP,
                 KEYBEGIN=(1,11),
                 PUSH=(68:68,10))       

//STEP02  EXEC PGM=SORT                                       
//SORTIN  DD DSN=&&TEMP,DISP=SHR                             
//SORTOUT DD DSN=YOUR OUTPUT,DISP=(,CATLG,DELETE),           
//           SPACE=(CYL,(1,1),RLSE)                           
//SYSOUT  DD SYSOUT=*                                         
//SYSIN   DD * 
                                             
  SORT FIELDS=(68,10,CH,D,
               90,08,CH,A)
                         
  OUTREC IFTHEN=(WHEN=GROUP,
                 KEYBEGIN=(68,10),
                 PUSH=(1:1,11)),
 
         IFTHEN=(WHEN=(89,1,CH,EQ,C'A'),
                 OVERLAY=(68:10X)),

         IFOUTLEN=77     


output
Code:

LLKJ487HJAS  RECORD-7              0000000138   
78N74B332TT  RECORD-4              0000000113   
78N74B332TT  RECORD-5                           
78N74B332TT  RECORD-8              0000000113   
ZZR19984M15  RECORD-1                           
ZZR19984M15  RECORD-2              0000000106   
ZZR19984M15  RECORD-3              0000000106   
ZZR19984M15  RECORD-10             0000000106   
ZZR19984M15  RECORD-11                           
ZZR19984M15  RECORD-12                           
876HAGS5S26  RECORD-6                           
876HAGS5S26  RECORD-9                           
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Aug 24, 2016 5:27 pm    Post subject: Reply with quote

Magesh_J,

why do you need 2 passes? and 2 sorts? And you shouldn't overlay the KEY for record-6 and record-9 as they both do NOT have a match

Code:

876HAGS5S26  RECORD-6                           
876HAGS5S26  RECORD-9                           


Should be

Code:

876HAGS5S26  RECORD-6 
653244BNBSA  RECORD-9 


Either way here is a sample if the ORDER is not required.

Code:

//STEP0100 EXEC PGM=SORT                                                     
//SYSOUT   DD SYSOUT=*                                                       
//SORTIN   DD *                                                               
ZZR19984M15  RECORD-1                                                         
ZZR19984M15  RECORD-2                                              0000000106
QQWM998401W  RECORD-3                                              0000000106
78N74B332TT  RECORD-4                                              0000000113
78N74B332TT  RECORD-5                                                         
876HAGS5S26  RECORD-6                                                         
LLKJ487HJAS  RECORD-7                                              0000000138
8CNMN43489H  RECORD-8                                              0000000113
653244BNBSA  RECORD-9                                                         
VNSEPP1112A  RECORD-10                                             0000000106
VNSEPP1112A  RECORD-11                                                       
VNSEPP1112A  RECORD-12                                                       
//SORTOUT  DD SYSOUT=*                                                       
//SYSIN    DD *                                                               
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,11),PUSH=(78:68,10)),                 
        IFTHEN=(WHEN=(78,10,CH,EQ,C' ',AND,68,10,CH,GT,C' '),                 
       OVERLAY=(78:68,10))                                                   
                                                                             
  SORT FIELDS=(78,10,CH,A),EQUALS                                             
                                                                             
  OUTREC IFOUTLEN=77,                                                         
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(78,10),PUSH=(90:SEQ=8)),                       
  IFTHEN=(WHEN=GROUP,BEGIN=(90,8,ZD,EQ,1,AND,78,10,CH,NE,C' '),               
  PUSH=(01:01,11))                                                           
                                                                             
//*


Output is

Code:

ZZR19984M15  RECORD-1                                                         
876HAGS5S26  RECORD-6                                                         
653244BNBSA  RECORD-9                                                         
ZZR19984M15  RECORD-2                                              0000000106
ZZR19984M15  RECORD-3                                              0000000106
ZZR19984M15  RECORD-10                                             0000000106
ZZR19984M15  RECORD-11                                                       
ZZR19984M15  RECORD-12                                                       
78N74B332TT  RECORD-4                                              0000000113
78N74B332TT  RECORD-5                                                         
78N74B332TT  RECORD-8                                              0000000113
LLKJ487HJAS  RECORD-7                                              0000000138

_________________
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: Wed Aug 24, 2016 6:20 pm    Post subject: Reply with quote

Kolusu,

Sorry, mistake.

Fantastic thinking.


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


Joined: 18 Apr 2016
Posts: 43
Topics: 14

PostPosted: Mon Aug 29, 2016 12:44 pm    Post subject: Reply with quote

Thanks a lot kolusu, that's exactly what I needed.
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