Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine Field name with dot(.) notation #74

Closed
bprasen opened this issue Apr 27, 2019 · 4 comments
Closed

Redefine Field name with dot(.) notation #74

bprasen opened this issue Apr 27, 2019 · 4 comments
Labels
question Further information is requested

Comments

@bprasen
Copy link

bprasen commented Apr 27, 2019

Hi,
while searching for REDEFINE fields attached with a given statement(Group/Primitive), found it is provided only the field name. This can be an issue if there are multiple fields with the same name in the copybook. Is it possible to provide exact field name with hierarchy with dot(.) notation ?

@yruslan
Copy link
Collaborator

yruslan commented Apr 27, 2019

Hi, do I understand it right that you are traversing an AST to find if a given field is redefined by another field and, if yes, find that redefined field?

As far as I understand a field can redefine another field only if that field is at the same hierarchical level (same level of nesting) and is consecutive to the field being redefined.

For instance, this is ok:

   10   A    PIC X(5).
   10   B    PIC X(5) REDEFINES A.
   10   C    PIC X(5) REDEFINES A.

But this is incorrect since C does not redefine A:

   10   A    PIC X(5).
   10   B    PIC X(5) REDEFINES A.
   10   C    PIC X(5).
   10   D    PIC X(5) REDEFINES A.

This means that an ambiguity in redefined field names can only occur if there is more than 1 field with the same name at the same level of nesting. But such fields are prohibited by the compiler and even if this was allowed a fully qualified name won't help resolve the ambiguity.

But I'm not sure I understand correctly the issue you are trying to solve. Maybe you can share the piece of code you use for redefined fields searching I can help you with that.

@yruslan yruslan added the question Further information is requested label Apr 27, 2019
@bprasen
Copy link
Author

bprasen commented Apr 29, 2019

Hi,
I understand your point. I was working with a copybook like below

01 COMPANY-DETAILS.
05 SEGMENT-ID PIC X(5).
05 COMPANY-ID PIC X(10).
05 STATIC-DETAILS.
10 COMPANY-NAME PIC X(15).
10 ADDRESS PIC X(25).
10 TAXPAYER REDEFINES ADDRESS.
15 TAXPAYER-TYPE PIC X(1).
15 TAXPAYER-STR PIC X(8).
15 TAXPAYER-NUM REDEFINES TAXPAYER-STR PIC 9(8) COMP.
05 CONTACTS REDEFINES STATIC-DETAILS.
10 COMPANY-ID PIC X(17).
10 CONTACT-PERSON REDEFINES COMPANY-ID PIC X(28).
10 PHONE-NUMBER-X PIC X(2).
10 CONTACT-PERSON-X REDEFINES PHONE-NUMBER-X PIC X(2).

in this structure, there are two COMPANY-IDs. So when I am trying to find out Compant-id it is giving me an error like "Multiple fields with name 'COMPANY_ID' found in the copybook. Please specify the exact field using '.' notation.". But as you stated avobe, I can implement some rules to find out correct Copmany-ID. Thanks for your answer.

@yruslan
Copy link
Collaborator

yruslan commented Apr 29, 2019

If you are using getFieldByName() or getFieldValueByName() to search for COMPANY-ID, you can use a fully qualified name, e.g. COMPANY-DETAILS.COMPANY-ID or CONTACTS.COMPANY-ID.

@bprasen
Copy link
Author

bprasen commented Apr 29, 2019

Yes, that I was asking as a part of Redefine info of a Statement(Group/Statment) :-)

@yruslan yruslan closed this as completed Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants