View previous topic :: View next topic
|
Author |
Message |
saurabh39 Warnings : 1 Active User
Joined: 11 Apr 2008 Posts: 144 Location: Jamshedpur
|
|
|
|
Hi All,
To understand the MOVE & REDEFINE Statement, I wrote a small program.
Below is the Data Division
Code: |
01 WS-COMP-VAR-NO-DEC PIC S9(05) COMP
VALUE 99999.
01 WS-COMP-VAR-WITH-DEC PIC S9(04)V9(05) COMP.
01 WS-ZONED-DEC-VAR PIC S9(09)
VALUE -273647889.
01 WS-COMP3-GRP-VAR.
05 WS-COMP3-ELEM-VAR PIC S9(05) .
01 WS-ALPHA-COMP3-GRP-X REDEFINES WS-COMP3-GRP-VAR PIC X(02).
01 WS-COMP3-VAR PIC s9(04)v9(05) .
01 WS-ALPHA-COMP3-X REDEFINES WS-COMP3-VAR PIC X(02).
01 WS-COMP3-UNSIGN PIC 9(04)v9(05) .
01 WS-ALPHA-UN-COMP3-X REDEFINES WS-COMP3-UNSIGN
PIC X(02).
|
Below is the procedure division -
Code: |
PROCEDURE DIVISION.
DIVIDE WS-ZONED-DEC-VAR BY WS-COMP-VAR-NO-DEC
GIVING WS-COMP-VAR-WITH-DEC,WS-COMP3-VAR
MOVE WS-COMP-VAR-WITH-DEC TO WS-COMP3-GRP-VAR
MOVE WS-COMP-VAR-WITH-DEC TO WS-COMP3-UNSIGN
DISPLAY 'WS-ALPHA-COMP3-GRP-X :'WS-ALPHA-COMP3-GRP-X
DISPLAY 'WS-ALPHA-COMP3-X :'WS-ALPHA-COMP3-X
DISPLAY 'WS-ALPHA-UN-COMP3-X :'WS-ALPHA-UN-COMP3-X
DISPLAY 'WS-COMP3-UNSIGN :'WS-COMP3-UNSIGN
DISPLAY 'WS-COMP-VAR-WITH-DEC :'WS-COMP-VAR-WITH-DEC
DISPLAY 'WS-COMP3-VAR :'WS-COMP3-VAR
DISPLAY 'WS-COMP3-GRP-VAR :'WS-COMP3-GRP-VAR
DISPLAY 'WS-COMP3-ELEM-VAR :'WS-COMP3-ELEM-VAR
GOBACK.
|
And and the Output is following -
Code: |
*********************************
WS-ALPHA-COMP3-GRP-X :
WS-ALPHA-COMP3-X :27
WS-ALPHA-UN-COMP3-X :27
WS-COMP3-UNSIGN :273650625
WS-COMP-VAR-WITH-DEC :27365062N
WS-COMP3-VAR :27365062N
WS-COMP3-GRP-VAR : %
WS-COMP3-ELEM-VAR : %
|
I was able to account for all the other results, but WS-COMP3-GRP-VAR & WS-COMP3-ELEM-VAR is beyond my understanding.(I am not able to reason out why % will be displayed)
Pointers needed for the same.
Also,please variable name is no way related to PIC type, so pleae don't get confused. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
I ran your code and got slightly different results:
Code: |
WS-ALPHA-COMP3-GRP-X :Õ^
4EE6CDDCC6CDDDF6CDD6E47EB
0620137810364730797070AF0
------------------------------------------
WS-ALPHA-COMP3-X :27
4EE6CDDCC6CDDDF6E47FF
062013781036473070A27
------------------------------------------
WS-ALPHA-UN-COMP3-X :27
4EE6CDDCC6ED6CDDDF6E47FF
062013781045036473070A27
------------------------------------------
WS-COMP3-UNSIGN :273650625
4EE6CDDDF6EDECCD47FFFFFFFFF
06203647304529750A273650625
------------------------------------------
WS-COMP-VAR-WITH-DEC :027365062N
4EE6CDDD6ECD6ECEC6CCC47FFFFFFFFFD
0620364705190693804530A0273650625
------------------------------------------
WS-COMP3-VAR :27365062N
4EE6CDDDF6ECD47FFFFFFFFD
06203647305190A273650625
------------------------------------------
WS-COMP3-GRP-VAR :Õ^%.
4EE6CDDDF6CDD6ECD47EB63
062036473079705190AF0CF
------------------------------------------
WS-COMP3-ELEM-VAR :Õ^%.
4EE6CDDDF6CDCD6ECD47EB63
0620364730535405190AF0CF |
What compiler are you using (the first line of compiler output will tell you)? And, note that you must use a hexadecimal display to properly see the displayed values -- character display will not show the values. It is also interesting that several of your variables have COMP3 as part of their name, yet you don't put COMP-3 on them. |
|
Back to top |
|
|
saurabh39 Warnings : 1 Active User
Joined: 11 Apr 2008 Posts: 144 Location: Jamshedpur
|
|
|
|
@Robert - Thanks for the quick response.
Quote: |
What compiler are you using
|
COBOL II Release 4.0
Quote: |
It is also interesting that several of your variables have COMP3 as part of their name, yet you don't put COMP-3 on them. |
I was trying various combination. First I tried with COMP-3, so the name has COMP-3 in it. But when I moved to ZD, i just changed the PIC clause. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
At this point, VS COBOL II (which is what I assume you meant by "COBOL II") is approaching 30 years of age and is FOUR generations behind the current compiler Enterprise COBOL for z/OS and OS/390. Fortunately, the COBOL features are pretty much the same although you are missing out on the "newer" (in some cases, 20 years old at this point) features that can be used. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Quote: |
I was able to account for all the other results, but WS-COMP3-GRP-VAR & WS-COMP3-ELEM-VAR is beyond my understanding.(I am not able to reason out why % will be displayed) |
Tusha, the contents of the files are the binary result of the calculation in a floating point format. You need to look at the hexadecimal output in order to see the binary values. The characters displayed are dependent on what code pages are used at your installation, and poosibly also in your terminal emulator setup. |
|
Back to top |
|
|
|