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!

Redefines, is this code valid

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
01 a pic 9(6).
01 b redefines a.
05 a-1 pic 99.
05 a-2 pic 99.
05 a-3 pic 99.
01 c redefines b pic $$$$$$.

Is this valid according to coding rules.
It works on the compiler we are using, but according to the manuals it is not valid......

Please get back to me asap.

 
If you want a leading $ sign then you have to make the field one character longer; otherwise you may trucate a 6 digit number. For that reason the redefine is invalid.

I thought you needed to move the amount as a number to edit it normally.

I didn't actually test this theory!!!!

If you do not like my post feel free to point out your opinion or my errors.
 
It is a valid redefinition in the WORKING-STORAGE SECTION and in the LINKAGE SECTION.

In the FILE SECTION, this would be in error. One is not permitted to redefine 01 level items in the FILE SECTION, because the redefinition is implicit for all 01 level items defined in the same FD.
Tom Morrison
 
Hi John,

Another thing to remember when chopping up a numeric data item into smaller numeric items, is that it's safe only if the original is an unsigned numeric display item. In that case all the data items created via the redefines are valid numeric items.

On the other hand, a redefined signed numeric item would carry the sign only in the low order 2 byte field. A COMP-3 field redefined as 3 COMP-3 2 byte fields would produce an 0C7 interrupt when used.

Nit-picking perhaps, but worth keeping in mind, JIC.

Regards, Jack.
 
This is valid (except in the File Section, as Tom mentioned, and also not in the obsolete Communications Section. It DOES seem to be valid in the new SCREEN SECTION.).
Redefinitions do not have to be consistent as to class, but it is a dangerous practise. Your example is OK.
Please quote the rule that you feel prohibits it, and tell us which compiler you are using.

Stephen J Spiro
ANSI COBOL Standards Committee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top