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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move numeric non integer data item to alphanumeric data item? 3

Status
Not open for further replies.

yuriyking

Programmer
Jan 29, 2004
26
0
0
DE
Hi all.
Sorry, if the question is stupid, but I am totally new to COBOL.

I have two data items:

01 NNI PIC 9(05)V9(02) USAGE IS DISPLAY.
01 AN PIC X(07).

When trying to move:

MOVE NNI TO AN


I have the following error:

1561 IGYPA3005-S "NNI (NUMERIC NON-INTEGER)" AND "AN (ALPHANUMERIC)" DID NOT FOLLOW THE "MOVE" STATEMENT
COMPATIBILITY RULES. THE STATEMENT WAS DISCARDED.

It is OS/390, IBM COBOL FOR MVS & VM 1.2.2.

My question: can I somehow move value from NNI (without comma) to AN without using REDEFINES.

Thans a lot.
 
Quoting from the IBM COBOL for MVS & VM Language Reference manual:

"If the data item referenced by data-name-1 is described as numeric, numeric-edited, alphabetic, or alphanumeric-edited, it is operated upon for purposes of reference modification as if it were redefined as an alphanumeric data item of the same size as the data item referenced by data-name-1."

"Reference modification creates a unique data item which is a subset of the data item referenced by data-name-1. This unique data item is considered an elementary item without the JUSTIFIED clause."

Therefore:
MOVE NNI(1:) TO AN

will work just fine. It will move according to the rules of an alphanumeric MOVE.
1.If AN is shorter, truncation occurs on the right.
2.If they are equal in length, no problem.
3.If AN is longer, space filling occurs on the right.
 
All -

You should note that LENGTH OF is NOT part of the 1985 standard and is not available on some compilers. AN(1:) and AN(1:LENGTH OF AN) are equivalent AFAIK.

I was a bit surprised to find out that only the presence of the implied decimal point make the MOVE NNI TO AN illegal. Without the decimal point, the MOVE is perfectly legal and functions as you might expect (i.e. NNI is treated as a simple alphanumeric field). I guess I generally avoid this sort of thing just because it is not clear to many programmers exactly what will happen.

Regards.

Glenn
 
My documentation repeats pretty much what COBOLKenny quoted.

Since the rules are relatively nebulous, I tend to be explicit with reference modification for my own peace of mind.

Dimandja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top