Can DFSORT be used to do the following?
File 1 contains all records to be placed in the output.
File 2 contains only some records with the same key.
If the record is in file 2, then the output record should contain information 
from two fields in file 2.
Otherwise the output record should contain information from two fields in file 
1.
The output record will also contain two fields always pulled from file 1 (even 
though the same fields also exist on file 2).

Since examples are always better, see below.
CHFIN is file 1
CHSIN is file 2
Matching is done on CHR-PAN-ACCOUNT.
Each output record needs to always contain CHR-PIC-CNT and CHR-ISSUE-CNT from 
CHFIN (file 1).
If there is a corresponding record on CHSIN (file 2) then we want to use 
CHS-CNT-DATE and CHS-FEE-BILL-AMT from CHSIN.
Otherwise we want to use CHR-CNT-DATE and CHR-FEE-BILL-AMT from CHSIN.
Oh, and to make it more fun, CHR-PIC-CNT, CHR-FEE-BILL-AMT and CHR-FEE-BILL-AMT 
are all 1 byte smaller than their counterparts CHS-PIC-CNT, CHS-FEE-BILL-AMT 
and CHS-FEE-BILL-AMT.

//JKEYCHR  JOB NOTIFY=&SYSUID                
//*------------------------------------------
//SORT1    EXEC PGM=SORT                     
//CHFIN    DD DISP=SHR,DSN=DVFJS.CVSC.CVSCHF 
//CHSIN    DD DISP=SHR,DSN=DEVA.CVSC.CHS     
//CHSOUT   DD DISP=SHR,DSN=DEVC.CVSC.CHS     
//SYSIN    DD *                                              
* Control statements for JOINKEYS application                
  JOINKEYS F1=CHFIN,FIELDS=(CHR-PAN-ACCOUNT,A),SORTED,NOSEQCK
  JOINKEYS F2=CHSIN,FIELDS=(CHS-PAN-ACCOUNT,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F1                                           
  REFORMAT FIELDS=(F1:CHR-PAN-ACCOUNT,CHR-CNT-DATE,          
                      CHR-PIC-CNT,CHR-ISSUE-CNT,             
                   F2:CHS-FEE-BILL-AMT)                      
* Control statements for main task (joined records)          
  OPTION COPY                                                
  OUTFIL FNAMES=CHSOUT,FTOV                                  
  OUTREC BUILD=(OUT-PAN-ACCOUNT,                             
                OUT-CNT-DATE,                                
                OUT-PIC-CNT,TO=PD,LENGTH=2,                  
                OUT-ISSUE-CNT,TO=PD,LENGTH=2,
                OUT-FEE-BILL-AMT)            
//SYSOUT   DD SYSOUT=*                       
//SYMNAMES DD *                              
CHR-PAN-ACCOUNT,6,19,CH                      
CHR-PIC-CNT,1223,1,PD                        
CHR-ISSUE-CNT,1224,1,PD                      
CHR-CNT-DATE,1228,3,PD                       
CHR-FEE-BILL-AMT,1234,2,PD                   
CHS-PAN-ACCOUNT,1,19,CH                      
CHS-CNT-DATE,20,3,PD                         
CHS-PIC-CNT,23,2,PD                          
CHS-ISSUE-CNT,25,2,PD                        
CHS-FEE-BILL-AMT,27,3,PD                     
OUT-PAN-ACCOUNT,1,19,CH                      
OUT-CNT-DATE,20,3,PD                                         
OUT-PIC-CNT,23,1,PD                                          
OUT-ISSUE-CNT,24,1,PD                                        
OUT-FEE-BILL-AMT,25,3,PD                                     
//SYMNOUT  DD SYSOUT=*                                       


Probably I'll just end up restoring to writing a COBOL program, but doing it 
with DFSORT would be pretty cool!

Frank

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to