Is there a way to force fully qualified variables



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Is there a way to force fully qualified variables

Postby kenW » Fri Nov 04, 2016 5:57 pm

Hi have a test case where a group appears in a record more than once. They are at different levels but under the same higher level group.

01 AAA.
   02  BBB.
       07  DDD.
           12  EEE PIC X(1).
       07  CCC.
           12  DDD.
               17  EEE PIC X(1).
 

I cannot reference the first EEE because "EEE OF DDD OF BBB OF AAA" is not unique since the compiler can use that qualification as either EEE.

If I have code like "MOVE 'Z' TO EEE OF DDD OF BBB OF AAA." I get error - IGYPS0037-S "EEE OF DDD OF BBB OF AAA" was not a uniquely defined name.

Is there a way (compiler option?) to force the compiler to use fully qualified names only?
kenW
 
Posts: 2
Joined: Fri Nov 04, 2016 3:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: Is there a way to force fully qualified variables

 

Re: Is there a way to force fully qualified variables

Postby Robert Sample » Fri Nov 04, 2016 6:35 pm

As you have your code now, you CANNOT directly reference your first EEE variable. This is not a COBOL issue, hence there is no way to force COBOL to allow you to reference it as coded. You have three choices:
1. Forget referencing the first EEE variable directly.
2. Add another unique variable name between AAA and the first EEE that allows you to uniquely reference that variable.
3. Change the name of the first EEE variable to something else.
Robert Sample
Global moderator
 
Posts: 3130
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 185 times

Re: Is there a way to force fully qualified variables

Postby kenW » Fri Nov 04, 2016 7:19 pm

Thanks Roberts. These options make sense. I'm not sure I understand your statement that this is not a COBOL issue. We have used this structure in other languages (like C) successfully since the fully qualified name is expected. But I understand that COBOL allows what I would call flexible qualification and therefore cannot determine uniqueness for my case.
kenW
 
Posts: 2
Joined: Fri Nov 04, 2016 3:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: Is there a way to force fully qualified variables

Postby Robert Sample » Fri Nov 04, 2016 7:25 pm

It is not a COBOL issue because you could have allowed both EEE variables to be referenced -- for example, changing BBB from level 02 to level 07 and increasing the level number of the DDD under BBB to at least 08 would allow you to qualify EEE OF BBB and EEE of CCC. So the issue arises due to YOUR coding technique, not anything inherent in COBOL.

And it is totally irrelevant whether or not other languages allow you to do this -- you are dealing with COBOL, which was designed in 1959, so you have to deal with COBOL as it is (unless you give up writing in COBOL and use whatever other language allow you to do this).
Robert Sample
Global moderator
 
Posts: 3130
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 185 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post