Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help Required in Understanding Move & Redefine Statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Wed Sep 15, 2010 5:02 pm    Post subject: Help Required in Understanding Move & Redefine Statement
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed Sep 15, 2010 5:19 pm    Post subject:
Reply with quote

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
View user's profile Send private message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Wed Sep 15, 2010 5:47 pm    Post subject: Reply to: Help Required in Understanding Move & Redefine
Reply with quote

@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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed Sep 15, 2010 6:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Sep 16, 2010 4:20 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us