Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Can we use "VALUE" clause in "REDEFINES"

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Can we use "VALUE" clause in "REDEFINES"
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: Chennai

PostPosted: Fri Oct 05, 2007 3:37 pm    Post subject: Reply to: Value clause in redefines
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    Post subject:
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: Chennai

PostPosted: Fri Oct 05, 2007 4:13 pm    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Fri Oct 05, 2007 8:21 pm    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

Value Clauses should be only in Condition Names
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: Sat Oct 06, 2007 9:33 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat Oct 06, 2007 9:58 pm    Post subject:
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

Site Director


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

PostPosted: Sat Oct 06, 2007 10:10 pm    Post subject: Reply to: Can we use "VALUE" clause in "REDEF
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    Post subject:
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

Site Director


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

PostPosted: Tue Oct 09, 2007 7:46 am    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Tue Oct 09, 2007 7:32 pm    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts Include/omit with "ALL" pa... mgl DFSORT/ICETOOL 6 Wed Jun 14, 2017 2:31 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us