Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting Ambiguous identifier error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Getting Ambiguous identifier error
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Jun 09, 2015 2:49 am    Post subject: Reply to: Getting Ambiguous identifier though its correct. Please see
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Jun 09, 2015 6:00 am    Post subject: Reply to: Getting Ambiguous identifier though its correct. Please see
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: 8132
Location: East Dubuque, Illinois, USA

PostPosted: Tue Jun 09, 2015 8:14 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Jun 09, 2015 12:16 pm    Post subject: Reply to: Getting Ambiguous identifier though its correct. Please see
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts IDC2902I Error tzeche ABENDS & Debugging 2 Tue Mar 28, 2017 11:39 am
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us