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

Can we use "VALUE" clause in "REDEFINES"


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

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Oct 05, 2007 3:30 pm
Reply with quote

Can we use "VALUE" clause in "REDEFINES" clause?
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Fri Oct 05, 2007 3:37 pm
Reply with quote

Did you have a try icon_question.gif
Back to top
View user's profile Send private message
earsha

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Fri Oct 05, 2007 3:41 pm
Reply with quote

Yes but it is giving an error.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Fri Oct 05, 2007 4:13 pm
Reply with quote

You cannot have VALUE clause for a REDEFINE variable

This is what the manual says

Quote:
The redefining entry (identified by data-name-1), and any subordinate entries, must not contain any VALUE clauses.


Here data-name-1 refers to the variable used for redefining.

For more on REDEFINE.Search for "REDEFINES" in the COBOL manual.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 05, 2007 8:21 pm
Reply with quote

you will receive a compiler error when trying to use the value clause in a structure that is subordinate to a redefining entry.

you will receive a compiler warning when you use the value clause for an element defined in the linkage section.
Back to top
View user's profile Send private message
sreenivasreddyg

New User


Joined: 23 Apr 2005
Posts: 39
Location: delhi

PostPosted: Sat Oct 06, 2007 12:04 am
Reply with quote

It is not a good idea to declare VALUE clause for a REDEFINES field.
Back to top
View user's profile Send private message
SCARCEBOYZ

New User


Joined: 16 May 2005
Posts: 32
Location: Millenium Business Park, Mumbai

PostPosted: Sat Oct 06, 2007 2:32 pm
Reply with quote

Value Clauses should be only in Condition Names
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Oct 06, 2007 9:33 pm
Reply with quote

Hello,

Quote:
Value Clauses should be only in Condition Names
That may be the standard in your organization, but it is not the rule most places.

Most places accept/require values for many items such as heading line constants, initial settings for flags/switches, values for all numerics, etc.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat Oct 06, 2007 9:58 pm
Reply with quote

dick scherrer wrote:
That may be the standard in your organization, but it is not the rule most places.
I do think he was referring to "in a redefined area".....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Oct 06, 2007 10:10 pm
Reply with quote

Could be icon_confused.gif

d
Back to top
View user's profile Send private message
earsha

New User


Joined: 16 Mar 2007
Posts: 17
Location: Pune

PostPosted: Mon Oct 08, 2007 11:07 am
Reply with quote

Thank you all for your replies!
I have got my answer.
we can use the value clause in redefines but it should be in the following structure

01 TTEST PIC X(10) VALUE 'MAINFRAMES'.
01 RTEST REDEFINES TTEST PIC X(10) is possible

But

01 TTEST PIC X(10).
01 RTEST REDEFINES TTEST PIC X(10) VALUE 'MAINFRAMES'.
Not possible.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Oct 09, 2007 7:46 am
Reply with quote

You're welcome icon_smile.gif

Correct icon_smile.gif

Thank you for following up with us.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Tue Oct 09, 2007 7:32 pm
Reply with quote

About using the VALUE clause, we tell our programmers to follow these rules:

1. OK to use VALUE for 88 levels.
2. OK to use VALUE to declare constants.

All other variables must be initialized in PROCEDURE DIVISION using MOVE, INITIALIZE or SET.

There is one exception. Some variables (switches and counters) must ONLY be initialized on the first time in and the only way to do this is to use the VALUE clause. For example, a switch that keeps track of whether a table has been loaded with data.

Reason why is: VALUE only executes on first call to routine whereas MOVE statement will execute on every call. In cases where your routine gets called many times VALUE will only initialize on the first time in.

In the CICS world where you use LINK to invoke your routine, use of the VALUE clause will not cause any problems because LINK creates a new run unit - thus every LINK is like a first time CALL. Nevertheless, we urge programmers not to use VALUE to initialize variables that need to be initialized every time in.

On occasion we convert LINKs to CALLs for performance reasons and if programmers follow the rules, then they should be able to do this conversion without any problems. As well, CICS logic is often ported into the batch environment so proper use of VALUE clause will allow this to happen without much grief.

Still... many experienced COBOL programmers seem to have trouble following these rules. Misuse of the VALUE clause emerges in almost every code walkthru we do. Not sure why this is...
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 PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts To search DB2 table based on Conditio... DB2 1
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Using PARM=('JPn"&SYMBOL&quo... DFSORT/ICETOOL 2
Search our Forums:

Back to Top