Pete,
Your suggestion worked. thanks. I did not know about using a period
in the picture clause, that was the trick that makes the redefines
graceful.
For the benefit of others, here is a cut and paste ready scrap of
code:
01 CONSTANTS.
02 ACOMP3 PIC 9(4)v9 COMP-3.
02 ADISPLAY PIC X(6).
02 ANUMERIC PIC Z(4).9.
02 ASTRING REDEFINES ANUMERIC PIC X(6).
*
PROCEDURE DIVISION.
FIRST-PARA.
MOVE 1234.5 TO ACOMP3.
* MOVE ACOMP3 TO ADISPLAY.
* DISPLAY ADISPLAY.
MOVE ACOMP3 TO ANUMERIC.
DISPLAY "ASTRING = " ASTRING.
STOP RUN.
The commented out MOVE statement produces this error on the latest
version of microfocus compiler:
pottmi@[EMAIL PROTECTED]
> cob moverule.cbl
20 MOVE ACOMP3 TO ADISPLAY.
*1029-
E***************************
**
** A non-integer is being moved to an alphanumeric data item
Given that, can you clarify your statement that the MOVE is legal?
--
Michael Potter
On Mar 5, 6:48 pm, "Pete Dashwood"
<dashw...@[EMAIL PROTECTED]
> wrote:
> "pottmi" <pot...@[EMAIL PROTECTED]
> wrote in message
>
>
news:3417ff0f-baad-4cb9-9b24-f23079af4c18@[EMAIL PROTECTED]
>
> > COBOL Crew,
>
> > This code is broken because the non-integer move to alphanumeric is
> > illegal.
>
> No it isn't. The code is not broken and the move is not illegal. You can
> move non-integer to Alphanumeric with no problem.
>
> Your understanding may be "broken" :-)
>
> It currently shows 12345b ...where "b" is a blank, right?
>
> > --------------------
> > 01 ACOMP3 PIC 9999v9 COMP-3.
> > 01 ADISPLAY PIC X(6).
>
> > MOVE 1234.5 to ACOMP3.
> > MOVE ACOMP3 TO ADISPLAY.
> > DISPLAY ADISPLAY.
> > -------------------
>
> > What are some options for me to change this code such that the output
> > of the "DISPLAY ADISPLAY" statement is "1234.5" with the constraint
> > that ACOMP3 and ADISPLAY must remain defined as they are?
>
> That seems to be a very unlikely thing to actually want to do (You could
> simply move "1234.5" to ADISPLAY and display it to achieve what you
stated
> above...), so I have assumed that what you really want is a single
decimal
> place, preceded by a point, capable of handling various values:
>
> 01 ACOMP3 PIC 9999v9 COMP-3.
> 01 ADISPLAY PIC X(6).
>
> ... add two lines...
> 01 ADISPLAY-EDITED PIC z(4).9.
> 01 ADSTRING REDEFINES ADISPLAY-EDITED PIC X(6).
> ...
> MOVE 1234.5 to ACOMP3.
> MOVE ACOMP3 TO ADISPLAY-EDITED.
> MOVE ADSTRING TO ADISPLAY.
> DISPLAY ADISPLAY.
>
> This will do what you require, within the constraints you specified.
>
> REDEFINES is one of the most powerful features in COBOL.
>
> Pete.
> --
> "I used to write COBOL...now I can do anything."


|