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 

Copy Field for a different matching field using Sort

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


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Fri May 06, 2011 5:39 am    Post subject: Copy Field for a different matching field using Sort Reply with quote

This is the file format
Rec-Type X(02)
CRD-DBT X(01)
CBS-ID 9(09)
GRP-ID 9(09)

File 1:
Code:

02C111111111000000011
02C111111112000000012
02C111111113000000000
02C111111114000000014
02C111111115000000013

File 2:
Code:

02D000000000000000011
02D000000000000000012
02D000000000000000000
02D000000000000000014
02D000000000000000013

If GRP-ID of file1 and file2 matches and if its greater than zero, we have to place the CBS-ID from File1 to File2. So output shud be

Output 1:
Code:

02C111111111000000011
02C111111112000000012
02C111111113000000000
02C111111114000000014
02C111111115000000013

Output 2:
Code:

02D111111111000000011
02D111111112000000012
02D000000000000000000
02D111111114000000014
02D111111115000000013

Note : IF GRP-ID is greater than zero, it will be unique in a file.
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Fri May 06, 2011 10:36 am    Post subject: Reply with quote

arvibala,

The following DFSORT JCL will give you the desired results. I assumed you don't have duplicates in your input files. If you do have then you would end up with more records

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//INA      DD DSN=&&INA,DISP=SHR                             
//INB      DD DSN=&&INB,DISP=SHR                             
//OUT1     DD SYSOUT=*                                       
//OUT2     DD SYSOUT=*                                       
//SYSIN    DD *                                               
  JOINKEYS F1=INA,FIELDS=(13,9,A)                             
  JOINKEYS F2=INB,FIELDS=(13,9,A)                             
  JOIN UNPAIRED                                               
  REFORMAT FIELDS=(F1:1,29,?,F2:1,21)                         
  SORT FIELDS=(22,8,CH,A)                                     

  OUTFIL FNAMES=OUT1,INCLUDE=(30,1,SS,EQ,C'B,1'),BUILD=(1,21)

  OUTFIL FNAMES=OUT2,INCLUDE=(30,1,SS,EQ,C'B,2'),             
  IFTHEN=(WHEN=(30,1,CH,EQ,C'B',AND,43,9,ZD,GT,0),           
  BUILD=(31,3,4,9,43,9)),                                     
  IFTHEN=(WHEN=NONE,BUILD=(31,21))                           
//JNF1CNTL DD *                                               
  INREC OVERLAY=(22:SEQNUM,8,ZD)                             
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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