Page 1 of 1

Join files using SYMNAMES

PostPosted: Mon Jun 06, 2011 5:13 pm
by javivi
Hi

I'm using the SYMNAMES file to join files with JOINKEYS. It work but I have the problem that when I want to build a output file I can't use the fields names on SYSMNAMES because the position of the files are relatives from the begining of the file and as I'm using the REFORMAT card, it don't work correctley...

I meen

//SYMNAMES DD DISP=SHR,DSN=FICHE1                   
//         DD DISP=SHR,DSN=FICHE2
(the files:)
FILE1_REGIS,1,16
FILE1_FIELD1,1,4,CH
FILE1_FIELD2,5,2,CH
FILE1_FIELD3,7,10,CH

FILE2_FIELD,1,17
FILE2_FIELD1,1,4,CH
FILE2_FIEL2,5,7,CH
FILE2_FIELD3,12,6,CH

FILE1 RECORDS:
0001AA1111111111
0002BB2222222222
0003CC3333333333

FILE2_RECORDS:
00020000001YYYYYY
00030000003ZZZZZZ


OUTPUT FILE
0002BB0002BB22222222220

//SYSIN DD *                                                           
  SORT FIELDS=COPY                                                     
  JOINKEYS FILE=F1,FIELDS=(FILE1_FIELD1,A),                             
           INCLUDE=(FILE1_FIELD1,EQ,C'0011',AND,                             )
  JOINKEYS FILE=F2,FIELDS=(FILE2_FIELD1,A)                               
  JOIN UNPAIRED,F1                                                     
  REFORMAT FIELDS=(F1:FILE1_REGIS,F2:FILE2_REGIS,?),FILL=C'*'           
  OUTFIL FNAMES=SALIDA,                                                 
         INCLUDE=(34,1,CH,EQ,C'B'),                                   
           BUILD=(FILE1_FIELD1,FILE1_FIELD2,FILE2_FIELD1,FILE2_FIELD2,FILE2_FIELD3)

Re: Join files using SYMNAMES

PostPosted: Mon Jun 06, 2011 11:19 pm
by Frank Yaeger
I think you're saying that you can't use the File1 and File2 symbols for the OUTFIL statement. That's correct because the OUTFIL statement references the fields from the reformatted record created by the REFORMAT statement. You would need to specify a new set of Symbols for the fields in the reformatted record created by the REFORMAT statement and use those symbols with OUTFIL BUILD.

Re: Join files using SYMNAMES

PostPosted: Thu Jun 09, 2011 6:52 pm
by javivi
Thanks Frank.