Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

value clause in file section? 1

Status
Not open for further replies.

jimlee

Programmer
Jan 27, 2001
213
GB
g'day,

can someone please tell me if it is legal to assign a VALUE to the FD entry in the file section of the data division thus:

DATA DIVISION.
FILE SECTION.
FD TRANS-FILE.
01 TRANS-REC.
03 TRANS-REF PIC X(5).
88 END-OF-TRANS VALUE HIGH-VALUES.
03 NEW-VALUE PIC 999.
etc...

my cobol manual tells me that it is illegal to assign a value to a data item in the file section, and then goes on to give me the above code in an example program.
Is it that are only allowed in a level 88 condition (which i thought were also illegal in the file section), but not assigned directly to a data field? I'm a bit confused.
any help appreciated, cheers jimlee, who is just about to take exams, wish me luck!!!
 
VALUE clauses on Level-88 items do NOT assign a value to storage. VALUE clauses on other items in a record in the FILE SECTION are not allowed.

I encourage you to use 88-levels liberally in ALL sections. They provide a good way to document field contents and can centralize constants that otherwise might be hard-coded in the procedure division. Some examples:

Code:
   05  PR-EMPL-GENDER                PIC X.
       88  VALID-PR-EMPL-GENDER      VALUES "F" "M" "U".
       88  PR-EMPL-GENDER-IS-UNKNOWN VALUE "U".

   05  PR-EMPL-RATE                  PIC 9(3)V9(4).
       88  HIGH-RATE-EMPLOYEE        VALUES ARE 25.0000 THRU
                                               999.9999.

GOOD LUCK!!
 
oh yeah , of course, it's a boolean condition isn't it, there's no value assigned, .. doh!
all is clear now, thanx v much for help. jimlee, who is just about to take exams, wish me luck!!!
 
Hi Jimlee,

Just one other point. Value clauses are "not allowed" in an FD, but are ingored with a warning message. The compile continues and an object module is created.

This allows copybooks that contain value clauses, to be used anywhere in the Data Division. I can't speak for all COBOL dialects, but I know this as fact for IBM mainframe COBOL.

Jack
 
Jimlee,

besides everything said earlier on, what use is a value clause in an I/O-area ?!!
If it's input, the file contents fill it, if it's output, you really want to control the record content actively in the procedure div. Otherwise, if a field should contain the same value in every output record it's reason for being there is doubtful.

Good luck,
Ronald.
 
hi Ronald B,

you're right, it's no use, and definately not a good idea!
I was just making sure that level 88 conditional values were legal in file section, as I was under the impression before that the value verb in all its forms was illegal in the file section.
all is clear now
cheers for everyones help jimlee
 
Hi Ron,

While the values contained in a VALUE clause can never be assigned to a data name in an FD clause, they can be useful in a record definition of an output record, i.e READ INTO. Take a report heading line, for instance; the initial values are rarely changed by PD code.

As I stated earlier, value clauses are routinely found in the file section when copybooks are used because of their duality of function. It's merely ignored by the compiler.

Regards, Jack.
 
Here's some additional information for you on the VALUE clause in the file section. Yes, it is ignored. Sometimes you see them because the same record description is used in Working-Storage and then the value clause has meaning.

In the next COBOL standard, one will be able to use the INITIALIZE statement to set data items to the value specified in the VALUE clause - giving the clause more power and more of a reason to live in the file section.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top