I have developed a JOINKEYS application, but I need to do one more function as 
part of the process, if it is possible.

I am joining two VB files on 2 keys in the fixed part of the VB records and 
using OUTFIL statements to split the result into multiple output files.  In 
each of the output files there is a header record (key values = all X'00') and 
a trailer record (key values = all X'FF').

I also want to insert a "true record count" into each trailer record in each 
output file, i.e. a record count that excludes the header and trailer records 
in a particular output file.

Frank Yaeger already helped me in a prior email to construct a way to produce 
this count for a single-file COPY operation using an INREC and an OUTREC, which 
would require a separate pass over each output file.  This is that function:

  OPTION COPY
* ADD SEQNUM BETWEEN RDW AND DATA.                         
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5:SEQNUM,11,ZD,16:5)),
* USE SEQNUM-2 TO PUT COUNT OF DATA RECORDS IN             
* LAST RECORD (IDENTIFIED BY X'FF').                       
      IFTHEN=(WHEN=(16,1,BI,EQ,X'FF'),                     
         OVERLAY=(160:5,11,ZD,SUB,+2,M11,LENGTH=11))       
* REMOVE SEQNUM.                                           
  OUTREC BUILD=(1,4,5:16)                                  

Below is a sanitized version of my JOINKEYS application with just two of the 
OUTFIL statements as an example.

My question is, where do I place the INREC above to accomplish the insertion of 
the SEQNUM fields for each record in each OUTFIL such that each OUTFIL has the 
correct record count in the trailer record?  If I could do that, I could adjust 
the BUILD parameters in the OUTFIL statements to remove the SEQNUM inserted by 
the INREC.

I did try just adding the INREC/OUTREC following the SORT statement, but that 
results in a trailer count for the entire JOINed file, not individually for 
each OUTFIL file.

Can this be done in one pass?  Or do I need a separate "trailer count" pass for 
each output file?

TIA for any assistance you can provide.

Peter


Sanitized JOINKEYS application:

 OPTION VLSCMP,VLSHRT                                                  
* SPECIFY JOIN RECORD RETENTION                                        
 JOIN UNPAIRED,F2                                                      
* SPECIFY THE JOIN KEYS FOR FILE 1 AND 2                               
 JOINKEYS FILE=F1,FIELDS=(21,3,A,83,25,A)                              
 JOINKEYS FILE=F2,FIELDS=(21,3,A,83,25,A)                              
* SPECIFY REFORMAT FOR FILE 1 AND 2
* POSITIONS 1-2 OF ALL INPUT DATA RECORDS (VB POS 5-6) ALWAYS CONTAIN 'D1'
* POSITION 106 (VB POS 110) OF F1 DATA RECORDS ALWAYS CONTAINS 'J'
* POSNS 1-2 AND 106 (VB POS 506 AND 110) OF HEADER  RECORDS CONTAIN X'00'
* POSNS 1-2 AND 106 (VB POS 506 AND 110) OF TRAILER RECORDS CONTAIN X'FF'
 REFORMAT FIELDS=(F2:1,4,F1:110,1,F2:6)                                
 SORT FIELDS=COPY                                                      
* THIS SELECTS ONLY MATCHED RECORDS                               
* AND HEADER/TRAILER RECORDS                                           
* OUTPUT RECORD BUILD CHANGES THE 'J' BACK TO 'D'                      
 OUTFIL FNAMES=OUT1,INCLUDE=((5,2,CH,EQ,C'J1'),OR,                     
                             (5,2,CH,EQ,X'0000'),OR,                   
                             (5,2,CH,EQ,X'FFFF')),                     
                    IFTHEN=(WHEN=(5,2,CH,EQ,C'J1'),                    
                            BUILD=(1,4,C'D',6:6)),                     
                    IFTHEN=(WHEN=((5,2,CH,EQ,X'0000'),OR,              
                                  (5,2,CH,EQ,X'FFFF')),                
                            BUILD=(1,4,5:5))                           
* THIS SELECTS ONLY UNMATCHED RECORDS OF ONE TYPE 
* AND HEADER/TRAILER RECORDS                           
* OUTPUT RECORD BUILD CHANGES THE ' ' BACK TO 'D'                       OUTFIL 
FNAMES=OUT2,INCLUDE=(((05,2,CH,EQ,C' 1'),AND,  
                              (15,4,CH,EQ,C'0700')),OR,     
                             (5,2,CH,EQ,X'0000'),OR,     
                             (5,2,CH,EQ,X'FFFF')),       
                    IFTHEN=(WHEN=(5,2,CH,EQ,C' 1'),      
                            BUILD=(1,4,C'D',6:6)),       
                    IFTHEN=(WHEN=((5,2,CH,EQ,X'0000'),OR,
                                  (5,2,CH,EQ,X'FFFF')),  
                            BUILD=(1,4,5:5))             
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
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