0

I'm Facing with issue in my programs. There is 2 physical files which declares field as xxBABA. 'xx' is different for two of this PF's and the these fields have different types one char other decimal. There exist logic file which contains this two files.

In program 'xx' prefix is replaced by YY for all fields so there is YYBABA char and YYBABA decimal.

Is there any way to get data from the second one?

jmarkmurphy
  • 11,030
  • 31
  • 59
Silver
  • 3
  • 4
  • What language is the program in? You could define a data structure for the file record and name the fields something unique. – Richard Evans May 04 '18 at 09:52
  • Or change the logical so that it renames one of the two fields, to avoid this? This clash sounds like an accident waiting to happen, to me. (Ideally I'd have thought you'd give the fields properly different names on their parent physicals, if they do different things. but no doubt it's far far too late to do that!) (P.S. I'm wondering if this is Synon/2?) – MandyShaw May 04 '18 at 10:43
  • mutli-format logicals are a bad idea in modern RPG... – Charles May 04 '18 at 15:15

2 Answers2

1

If the program is in RPG, you can rename one or both of the fields using an I spec.

     IPF1RECFMT    
     I              XXBABA                      XXBABA#                               
     IPF2RECFMT    
     I              XXBABA                      XXBABA@
Rob Schember
  • 206
  • 1
  • 3
0

No, You can't even compile it that way.

One way you may resolve this is to rename the one field with an I spec as suggested by @RobSchember. Another way, as of v7.1, would be to put a Qualified keyword on the file, and do IO into a data structure. That way like named fields are now associated with their specific record. It looks like this:

dcl-f file1       Disk Qualified;

dcl-ds rec1       LikeRec(file1.record1: *input);
dcl-ds rec2       LikeRec(file1.record2: *input);

read file1.record1 rec1;
read file1.record2 rec2;
jmarkmurphy
  • 11,030
  • 31
  • 59