Zero is moved to variable



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

Zero is moved to variable

Postby gauthamnagpur18 » Thu Mar 05, 2015 2:33 pm

Hi,

When i try to move S9(8) comp variable to X(02), zero is getting moved instead of actual value . I know this is not a valid way to move. Still i am trying to understand whether we can move the comp variable to alphanumeric variable.

Thanks for your help.

Thanks,
Gautham
gauthamnagpur18
 
Posts: 93
Joined: Sat Oct 23, 2010 1:28 pm
Location: Chennai, India
Has thanked: 3 times
Been thanked: 2 times

Re: Zero is moved to variable

 

Re: Zero is moved to variable

Postby BillyBoyo » Thu Mar 05, 2015 3:08 pm

What are you trying to do? S9(8) can have a value -99,999,999 to +99,999,999. A character number (Zoned Decimal) in a PIC XX can have a value zero to 99.

You should consult the Enterprise COBOL Language Reference. If you don't understand it straight off, then experiment, and read again. Repeat until you understand, or you make no further progress. Then explain here what you have got to.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Move EIBRESP to Temp variable

Postby gauthamnagpur18 » Thu Mar 05, 2015 3:39 pm

Hi,

I am trying to move EIBRESP to ws-temp-variable.

EIBRESP is defined as S9(8) comp . When we copy EIBRESP to temp variable which i have defined as X(02), data is not getting populated correctly.

For example, EIBRESP got value 12 as VSAM file was closed , but when i try to move that value to ws-temp-variable, zero is getting moved instead of 12 .

Thanks,
Gautham
gauthamnagpur18
 
Posts: 93
Joined: Sat Oct 23, 2010 1:28 pm
Location: Chennai, India
Has thanked: 3 times
Been thanked: 2 times

Re: Zero is moved to variable

Postby Akatsukami » Thu Mar 05, 2015 3:56 pm

Read and understand topics 6.2.24.1.1, "Elementary move rules" and 5.1.6.8, "Alignment rules" of the Enterprise COBOL for z/OS Language Reference, and you will understand why you get the result that you do.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Zero is moved to variable

Postby Robert Sample » Thu Mar 05, 2015 5:23 pm

As otherwise indicated, your results are normal and expected for what you did. COBOL (through the Enterprise COBOL Language Reference manual) is very clear about which MOVEs are allowed and what happens when the MOVE occurs.
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: Zero is moved to variable

Postby Terry Heinze » Thu Mar 05, 2015 7:56 pm

In addition to the previous replies, S9(8) comp is a 4-byte field and X(02) is a 2-byte field. Why are you defining ws-temp-variable as X(02)?
.... Terry
Terry Heinze
 
Posts: 193
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times

Re: Zero is moved to variable

Postby gauthamnagpur18 » Thu Mar 05, 2015 10:44 pm

Hi Terry,

Ya you are right . it should be 9(02).

Its working now.

Thanks,
Gautham
gauthamnagpur18
 
Posts: 93
Joined: Sat Oct 23, 2010 1:28 pm
Location: Chennai, India
Has thanked: 3 times
Been thanked: 2 times

Re: Zero is moved to variable

Postby Mickeydusaor » Fri Mar 06, 2015 3:19 am

it should be 9(04)
User avatar
Mickeydusaor
 
Posts: 29
Joined: Fri Feb 24, 2012 11:24 pm
Has thanked: 1 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post