View previous topic :: View next topic
|
Author |
Message |
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
Can we use "VALUE" clause in "REDEFINES" clause? |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
Did you have a try |
|
Back to top |
|
|
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
Yes but it is giving an error. |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
sreenivasreddyg
New User
Joined: 23 Apr 2005 Posts: 39 Location: delhi
|
|
|
|
It is not a good idea to declare VALUE clause for a REDEFINES field. |
|
Back to top |
|
|
SCARCEBOYZ
New User
Joined: 16 May 2005 Posts: 32 Location: Millenium Business Park, Mumbai
|
|
|
|
Value Clauses should be only in Condition Names |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Could be
d |
|
Back to top |
|
|
earsha
New User
Joined: 16 Mar 2007 Posts: 17 Location: Pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome
Correct
Thank you for following up with us. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
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 |
|
|
|