View previous topic :: View next topic
|
Author |
Message |
dileepv
New User
Joined: 03 Nov 2005 Posts: 2 Location: Hyderabad,AP,India
|
|
|
|
Hello, I am new to this great forum. I am facing a strange problem..
I have a variable defined 3 times as below.
Code: |
01 I-DATA.
05 GROUP-01.
07 DATA-01 PIC X(10).
07 DATA-02 PIC X(10).
05 GROUP-2.
07 CUST-ID PIC X(10). --> 1st CUST-ID
07 S-I-DAT.
09 AD-DAT.
15 AT-DAT-01.
17 CUST-ID PIC X(10). --> 2nd CUST-ID
15 AT-DAT-02.
17 CUST-ID PIC X(10). --> 3rd CUST-ID |
While I am referring to 1st CUST-ID, I am getting Ambiguous identifier error. Could you please help me resolving this. Am I defining it incorrectly ? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why would you want to do that? Just define different names, what's the problem? You're confused, and you are coding it. Think about how the next people along are going to feel. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you have COBOL V5.2 you can use compiler option QUALIFY(EXTEND) (new in V5.2) to reference your first non-unique item.
Although IBM have added this, I don't know why. Perhaps you can explain why you have that type of structure? Ah. XML-related? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Am I defining it incorrectly ? |
Yes. When you have multiple variables with the same name in COBOL, each much be uniquely identifiable through qualification. Your structure does not allow the first CUST-ID to be uniquely identified -- CUST-ID OF GROUP-2 identifies all three CUST-ID variables. You need an 06 level variable before and after the 07 CUST-ID (with different names for each 06 level) to be able to uniquely qualify the first CUST-ID. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Robert's way will work (you qualify with the first new 06-level data-name), because the duplicate names are no longer in the same vertical hierarchy, but I suspect it won't work for you as you are generating XML from it (that's still a guess).
Continuing with the guess, my suggestion of not using non-unique names won't do you either.
Which leaves you with using V5.2 (fine if you already have it installed, and the means to use QUALIFY(EXTEND)) or REDEFINES of the 01-level, which is a bit clunky.
You need to explain why you've got those duplicates, and how you want to use them. |
|
Back to top |
|
|
|