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
 

 

MOVE and INITIALIZE
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Thu Jan 21, 2010 3:50 pm    Post subject: MOVE and INITIALIZE
Reply with quote

Hi could anyone please help me on this..

What 'll happen while

Moving SPACES to a

COMP variable,
Signed Numeric S9(3),

Initializing

COMP variable,
Signed Numeric S9(3)

Thanks in advance icon_smile.gif
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Jan 21, 2010 3:52 pm    Post subject:
Reply with quote

Hello pecram24,

Why dont you just tried both the case & get the result by urself?
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Thu Jan 21, 2010 4:10 pm    Post subject:
Reply with quote

I tried both the cases..
but i just wanted to know about in detail. That's the reason i am asking here...
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Jan 21, 2010 4:11 pm    Post subject:
Reply with quote

What was the result?
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Thu Jan 21, 2010 4:18 pm    Post subject:
Reply with quote

While moving SPACES into a COMP variable the value of that variable becomes ZERO.
Even while initializing also the value of the COMP variable is ZERO.

But in case of S9(3)....
After moving SPACES& INITIALIZING, i am getting an error message saying that INVALID DECIMAL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jan 21, 2010 6:19 pm    Post subject:
Reply with quote

Which compiler are you using? My results are a compile error (as expected):
Code:
             01  WS-DATA.
                 05  WS-VAR1                 PIC S9(03) COMP.
            *
             PROCEDURE DIVISION.
             S1000-INITIALIZE.
                 MOVE SPACES                 TO  WS-VAR1.

 IGYPA3005-S "SPACES" and "WS-VAR1 (BINARY INTEGER)" did not follow the "MOVE"
             statement compatibility rules.  The statement was discarded.

                 DISPLAY 'SPACES     ' WS-VAR1.
                 MOVE ZERO                   TO  WS-VAR1.
                 DISPLAY 'ZERO       ' WS-VAR1.
                 INITIALIZE WS-VAR1.
                 DISPLAY 'INITIALIZE ' WS-VAR1.

                 GOBACK.
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Fri Jan 22, 2010 10:40 am    Post subject:
Reply with quote

@ Robert Sample ..

My question is something different....
You are using S9(3) COMP.. but my question is about S9(3) and
S9(9) COMP....

Could you please try for this ...
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jan 22, 2010 10:44 am    Post subject:
Reply with quote

Hello,

Regardless of what the compiler might permit, code should not move spaces to numeric fields. . . There is no good reason to do this.

Organizations with programmiing standards will not allow such code to be promoted.
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Fri Jan 22, 2010 11:17 am    Post subject:
Reply with quote

I have one doubt here..
What the INITIALIZE verb 'll do..
my assumption is... it 'll move SPACES to the alphanumeric fields...and ZEROS to the numeric fields.....
but in my case it's not happening.. why like that
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jan 22, 2010 11:40 am    Post subject:
Reply with quote

Hellol,

Quote:
but in my case it's not happening.. why like that
You need to post the variables that are being initialized, the initialize code and show the unwanted values that result.

At the top of the page is a link to "IBM Manualls". The first set is for COBOL. Look in the Language Reference for your level of cobol and read all of the specifics about INITIALIZE.

If you find something that is not clear,post what you found and your doubt about it. Someone will be able to clarify.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Jan 22, 2010 4:11 pm    Post subject:
Reply with quote

Robert Sample wrote:
Which compiler are you using? My results are a compile error (as expected):
Code:
             01  WS-DATA.
                 05  WS-VAR1                 PIC S9(03) COMP.
            *
             PROCEDURE DIVISION.
             S1000-INITIALIZE.
                 MOVE SPACES                 TO  WS-VAR1.

 IGYPA3005-S "SPACES" and "WS-VAR1 (BINARY INTEGER)" did not follow the "MOVE"
             statement compatibility rules.  The statement was discarded.

                 DISPLAY 'SPACES     ' WS-VAR1.
                 MOVE ZERO                   TO  WS-VAR1.
                 DISPLAY 'ZERO       ' WS-VAR1.
                 INITIALIZE WS-VAR1.
                 DISPLAY 'INITIALIZE ' WS-VAR1.

                 GOBACK.

The compiler output tells you... The move SPACES instruction were discarded. You are displaying the initial storage contents in your working storage for the first display of WS-VAR1, and that is low values which is zero in a comp field.

If you manage to get 3 space characters into a S9(3) COMP mask you would get x'404040' which yields a value of 4.210.752.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 22, 2010 4:12 pm    Post subject:
Reply with quote

Quote:
What 'll happen while

Moving SPACES to a

COMP variable,
Signed Numeric S9(3),
If you MEANT two variables in your statement, why didn't you specify that they were different variables? If you cannot tell us precisely what your question is, how do you expect us to answer it correctly?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jan 22, 2010 5:31 pm    Post subject:
Reply with quote

Robert,

you are being too harsh! As Marso so eloquently explained in this thread,
despite the fact that this is an english forum about an english documented machine,
we should read between the lines and determine what the user has meant, not what the user has said.

treating language literally is only for compilers, apparently.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Jan 22, 2010 5:55 pm    Post subject:
Reply with quote

Kjeld wrote:
If you manage to get 3 space characters into a S9(3) COMP mask you would get x'404040' which yields a value of 4.210.752.

...provided you are working on a EBCDIC system. On a ASCII system you will get x'202020', with the decimal equivalent 2.105.376
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 22, 2010 6:07 pm    Post subject:
Reply with quote

Quote:
On a ASCII system you will get x'202020', with the decimal equivalent 2.105.376
And which IBM mainframe are YOU working on that uses ASCII?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 22, 2010 6:08 pm    Post subject:
Reply with quote

Quote:
we should read between the lines and determine what the user has meant, not what the user has said.
Dick, I had a job one time where it was documented in my annual review that one of my tasks was to read programmer's minds. I never did get rated well on that aspect of the job.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Jan 22, 2010 6:14 pm    Post subject:
Reply with quote

And, by the way, here's the code:
Code:
           05  WS-VAR1                 PIC S9(03) COMP.
           05  WS-VAR2                 PIC S9(03) .
      *
       PROCEDURE DIVISION.
       S1000-INITIALIZE.
           MOVE SPACES                 TO  WS-VAR1.
           DISPLAY 'SPACES     ' WS-VAR1.
           MOVE ZERO                   TO  WS-VAR1.
           DISPLAY 'ZERO       ' WS-VAR1.
           INITIALIZE WS-VAR1.
           DISPLAY 'INITIALIZE ' WS-VAR1.
           MOVE SPACES                 TO  WS-VAR2.
           DISPLAY 'SPACES     ' WS-VAR2.
           MOVE ZERO                   TO  WS-VAR2.
           DISPLAY 'ZERO       ' WS-VAR2.
           INITIALIZE WS-VAR2.
           DISPLAY 'INITIALIZE ' WS-VAR2.
and here's the compiler output:
Code:
            S1000-INITIALIZE.
                MOVE SPACES                 TO  WS-VAR1.

IGYPA3005-S "SPACES" and "WS-VAR1 (BINARY INTEGER)" did not follow the "MOVE"
            statement compatibility rules.  The statement was discarded.

                DISPLAY 'SPACES     ' WS-VAR1.
                MOVE ZERO                   TO  WS-VAR1.
                DISPLAY 'ZERO       ' WS-VAR1.
                INITIALIZE WS-VAR1.
                DISPLAY 'INITIALIZE ' WS-VAR1.
                MOVE SPACES                 TO  WS-VAR2.

IGYPA3005-S "SPACES" and "WS-VAR2 (NUMERIC INTEGER)" did not follow the "MOVE"
            statement compatibility rules.  The statement was discarded.

                DISPLAY 'SPACES     ' WS-VAR2.
                MOVE ZERO                   TO  WS-VAR2.
                DISPLAY 'ZERO       ' WS-VAR2.
                INITIALIZE WS-VAR2.
                DISPLAY 'INITIALIZE ' WS-VAR2.
Using COMP or not does not matter to the compiler -- moving SPACES to a numeric field is not allowed.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Jan 22, 2010 6:27 pm    Post subject:
Reply with quote

It was only because I read in another discussion that it would be a possibility if you were compiling for and executing the cobol code in a ASCII (UNIX?) system.
I have not seen an IBM mainframe that uses ASCII codepages, though.
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Fri Jan 22, 2010 6:27 pm    Post subject:
Reply with quote

Robert


Can u do me a favor..
Let's have both the variables under a group variable.. and try to move spaces to that group variable... and let me know what u are getting... because i didn't get error while doing compilation....
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 22, 2010 6:32 pm    Post subject:
Reply with quote

pecram24 wrote:
Robert


Can u do me a favor..
Let's have both the variables under a group variable.. and try to move spaces to that group variable... and let me know what u are getting... because i didn't get error while doing compilation....


Group moves are always alphanumeric!
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
Goto page 1, 2  Next
Page 1 of 2

 

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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Need information on COBOL MOVE CORRES... subratarec COBOL Programming 10 Tue Jun 28, 2016 10:38 pm
No new posts how to move view the remote file in o... mailtoashok CICS 2 Fri Feb 12, 2016 1:07 pm


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