Page 1 of 1

Cobol move variables

PostPosted: Wed Mar 09, 2011 11:53 pm
by cooldude14344
PERCENT PIC 9(5)V999
WS10-PERCENTAGE PIC Z(9)9.
03 WS10-PERCENTAGE-RED REDEFINES WS10-PERCENTAGE.
05 FILLER PIC X(4).
05 WS10-REQUIRED PIC X(6).
INVESTMENT-PROPN-REGULAR PIC X(6).

PERCENT = 20.555

MOVE PERCENT TO WS10-PERCENTAGE
MOVE WS10-REQUIRED TO INVESTMENT-PROPN-REGULAR

What would be the value in WS10-REQUIRED,INVESTMENT-PROPN-REGULAR and WS10-PERCENTAGE.



If you could explain the reason also would be great.

Cheers
R

Re: Cobol move variables

PostPosted: Thu Mar 10, 2011 12:34 am
by Robert Sample
Since WS10-PERCENTAGE has no decimal places, the first MOVE drops all digits after the decimal point and only 20 is left. WS10-REQUIRED has the same value since it is a REDEFINE. The 20 will be moved in the next MOVE statement. You can count the appropriate number of spaces, and remember that numeric moves justify to the decimal point and alphanumeric moves work left to right.

Re: Cobol move variables

PostPosted: Thu Mar 10, 2011 4:06 am
by cooldude14344
Thanks a lot