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

DFSORT Output file order query


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

New User


Joined: 24 Mar 2010
Posts: 19
Location: USA

PostPosted: Thu Mar 26, 2020 11:59 pm
Reply with quote

Dear friends,

I am working on joining two files as mentioned below. I want to keep the order of file 1 as it is in the output. Whereas I can see that DFSORT is sorting output based on the joinkey. Any idea how can I join 2 files and keep the order of the output same as file 1 as requested below ?


File 1 :

TEST.T1
-----------
Code:
AAA 001 PQR
ZZZ 009 ADR
QQQ 231 PFR
CCC 031 FDR
BBB 201 DSR
LLL 031 QAR


File 2 :

TEST.T2
-----------
Code:
ZZZ 009 ADR TEST1
AAA 001 PQR TEST2
BBB 201 DSR TEST3
CCC 031 FDR TEST4
LLL 031 QAR TEST5
QQQ 231 PFR TEST6


Output file generated :

File 3 :

TEST.T3
-----------
Code:
AAATEST2
BBBTEST3
CCCTEST4 
LLLTEST5   
QQQTEST6 
ZZZTEST1


Expected output :

Code:
AAATEST2
ZZZTEST1 
QQQTEST6 
CCCTEST4 
BBBTEST3
LLLTEST5   


Sort job I have used :

Code:
//STEP01 EXEC PGM=SRT
//SORTJNF1 DD DSN=TEST1.T1,DISP=SHR
//SORTJNF2 DD DSN=TEST1.T2,DISP=SHR
//SORTOUT  DD DSN=TEST1.T3,DISP=(NEW,CATLG,CATLG),DCB=(RECFM=FB,BLZSIZE=0),
//         SPACE=(CYL,(10,10),RLSE),UNIT=SYSDA
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//SYSIN DD *
  SORT FIELDS=COPY
  JOINKEYS FILE=F1,FIELDS=(1,3,A)
  JOINKEYS FILE=F2,FIELDS=(1,3,A)
  JOIN UNPAIRED,F1
  REFORMAT FIELDS=(F1:1,3,F2:13,5)
  OPTION EQUALS
/*

Please note; input files will not be in sorted order.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1231
Location: Bamberg, Germany

PostPosted: Fri Mar 27, 2020 1:11 am
Reply with quote

Code:
//SIMPLE   EXEC PGM=ICEMAN                   
//F1       DD *                             
AAA 001 PQR                                 
ZZZ 009 ADR                                 
QQQ 231 PFR                                 
CCC 031 FDR                                 
BBB 201 DSR                                 
LLL 031 QAR                                 
/*                                           
//F2       DD *                             
ZZZ 009 ADR TEST1                           
AAA 001 PQR TEST2                           
BBB 201 DSR TEST3                           
CCC 031 FDR TEST4                           
LLL 031 QAR TEST5                           
QQQ 231 PFR TEST6                           
/*                                           
//SORTOUT  DD SYSOUT=*                       
//SYSOUT   DD SYSOUT=*                       
//SYSIN DD *                                 
  JOINKEYS F1=F1,FIELDS=(1,3,A)             
  JOINKEYS F2=F2,FIELDS=(1,3,A)             
  JOIN UNPAIRED,F1                           
  REFORMAT FIELDS=(F1:1,3,F2:13,5,F1:40,4)   
  SORT FIELDS=(9,4,ZD,A)                     
  OUTFIL FNAMES=(SORTOUT),BUILD=(1,8)       
/*                                           
//JNF1CNTL DD *                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(40:SEQNUM,4,ZD))
  END                                               
/*

Output:
Code:
AAATEST2
ZZZTEST1
QQQTEST6
CCCTEST4
BBBTEST3
LLLTEST5
Back to top
View user's profile Send private message
A_programmers

New User


Joined: 24 Mar 2010
Posts: 19
Location: USA

PostPosted: Thu Apr 09, 2020 4:10 pm
Reply with quote

Thanks Joerg. It is working as expected. Appreciate your help.
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

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top