Cobol move variables



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Cobol move variables

Postby cooldude14344 » Wed Mar 09, 2011 11:53 pm

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
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol move variables

 

Re: Cobol move variables

Postby Robert Sample » Thu Mar 10, 2011 12:34 am

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.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Cobol move variables

Postby cooldude14344 » Thu Mar 10, 2011 4:06 am

Thanks a lot
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post