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
 

 

Find out the uninitialized variable in COBOL program?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 10:19 am    Post subject: Find out the uninitialized variable in COBOL program?
Reply with quote

Hi all,

Is there any way to find out uninitialized variable in a program? Do those variable will be displayed somewhere in the job after compilation. Please let me know if there is any way to find it out

Regards
Sujatha
Back to top
View user's profile Send private message

Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 10:47 am    Post subject:
Reply with quote

As per my knowledge, it will not be displayed. It would be a logical error in the code. What do others say?
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Thu Nov 22, 2007 11:00 am    Post subject:
Reply with quote

Sujatha,

Quote:
Is there any way to find out uninitialized variable in a program?

Do you mean 'unused' variable in a program?

If you are looking for above, see the warning messages during compilation process.
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 11:09 am    Post subject: Reply to: Find out the uninitialized variable in COBOL progr
Reply with quote

No not the unused variable.
For Example: In a Program "A"......

01 name pic x(5) value 'hello' ------ this is initialized variable

01 age pic 9(2). ----- This is un initialized variable.

I want to know is the variable AGE will be displayed somewhere in the compile listing
Back to top
View user's profile Send private message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 12:25 pm    Post subject: Reply to: Find out the uninitialized variable in COBOL progr
Reply with quote

It will not be displayed
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 22, 2007 12:37 pm    Post subject: Reply to: Find out the uninitialized variable in COBOL progr
Reply with quote

Can u tell me is there any other way to make it display ?
Back to top
View user's profile Send private message
VinayCM

New User


Joined: 06 Nov 2007
Posts: 36
Location: Bengaluru

PostPosted: Thu Nov 22, 2007 12:45 pm    Post subject:
Reply with quote

Sujatha,
There is no way to display uninitialized variable.. You can find out unused variables.
Back to top
View user's profile Send private message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Thu Nov 22, 2007 1:05 pm    Post subject:
Reply with quote

May be, you can write a tool for that!!! That would be the solution to find out the uninitialized variables.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 1:52 am    Post subject:
Reply with quote

Edit your pgm in ISPF.

On the cmd line enter: x all; f ' pic';x all ' value '

What remains displayed s/b the "uninited" variables.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Nov 28, 2007 2:02 am    Post subject:
Reply with quote

mmwife wrote:
Edit your pgm in ISPF.

On the cmd line enter: x all; f ' pic';x all ' value '

What remains displayed s/b the "uninited" variables.


What about
1. items with pic on one line and value on the next
2. items with that are part of a redefines
3. LINKAGE Section
4. items defined in copy or includes?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 7:44 pm    Post subject:
Reply with quote

Quote:
What about
1. items with pic on one line and value on the next
2. items with that are part of a redefines
3. LINKAGE Section
4. items defined in copy or includes?


1. You're right. Add "a f all ' value '"
2. No value allowed in a redef.
3. LS only carries received items (no "value" allowed). Value in caller.
4. He's screwed unless he wants to copy the expanded compiler listing to ISPF or he could do the same thing to the copybk(s).
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Nov 28, 2007 7:55 pm    Post subject:
Reply with quote

[quote="mmwife"]
Quote:
2. No value allowed in a redef.
3. LS only carries received items (no "value" allowed). Value in caller.


But first he has to determine that it is a redefinition or LINKAGE Section item.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 9:00 pm    Post subject:
Reply with quote

I guess it all depends on the details of what he's attempting to do.

He could always put another "find all" or 2 in the mix.

But then there's the ques of the INIT verb, move spaces, etc.

As I said it's in the details. And these are ques he's got to ans, if he's interested enough.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Wed Nov 28, 2007 10:59 pm    Post subject:
Reply with quote

The problem is theoretically impossible.

If I could write a program to see if a given variable would ever have a value assigned to it, then I could solve the Halting Problem for Turing Machines (see any intro book on authomata theory) in the following way:

I'll write a program SIM to input another program PGM and its data, then simulate PGM. If the simulation halts, then SIM will initialize one of a own variables HALTED; otherwise, it won't.

Now, if I have a program INITTED that can tell if a variable in another program is ever initialized, I'll just run INITTED on SIM. If SIM initialized its variable HALTED, then I know the simulation halted, and therefore PGM halted.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 28, 2007 11:58 pm    Post subject:
Reply with quote

Phil,

You might be right, but I think it's simpler than that: he just wants to know the fields that don't have an associated VALUE clause.

But, then again, maybe not.
Back to top
View user's profile Send private message
SUJATHAA

New User


Joined: 26 Sep 2007
Posts: 7
Location: CHENNAI

PostPosted: Thu Nov 29, 2007 4:05 pm    Post subject: Reply to: Find out the uninitialized variable in COBOL progr
Reply with quote

Thanks For all the reply

So the final solution is to write a COBOL pgm which has to list all the un initialized variable. I am rite?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 30, 2007 1:13 am    Post subject:
Reply with quote

Hello,

You can surely write COBOL code that will parse other COBOL code.

It may not be so straight forward to get the exact results you want (please refer to the earlier discussion).

While you are working on the code and there are questions/problems, if you post them here, we may be able to offer suggestions.

Keep in mind that reference modification is your friend icon_wink.gif
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 How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am


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