IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting Ambiguous identifier error


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dileepv

New User


Joined: 03 Nov 2005
Posts: 2
Location: Hyderabad,AP,India

PostPosted: Tue Jun 09, 2015 1:26 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2015 2:49 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2015 6:00 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 09, 2015 8:14 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 09, 2015 12:16 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top