Page 1 of 1

Zero is moved to variable

PostPosted: Thu Mar 05, 2015 2:33 pm
by gauthamnagpur18
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

Re: Zero is moved to variable

PostPosted: Thu Mar 05, 2015 3:08 pm
by BillyBoyo
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.

Move EIBRESP to Temp variable

PostPosted: Thu Mar 05, 2015 3:39 pm
by gauthamnagpur18
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

Re: Zero is moved to variable

PostPosted: Thu Mar 05, 2015 3:56 pm
by Akatsukami
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.

Re: Zero is moved to variable

PostPosted: Thu Mar 05, 2015 5:23 pm
by Robert Sample
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.

Re: Zero is moved to variable

PostPosted: Thu Mar 05, 2015 7:56 pm
by Terry Heinze
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)?

Re: Zero is moved to variable

PostPosted: Thu Mar 05, 2015 10:44 pm
by gauthamnagpur18
Hi Terry,

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

Its working now.

Thanks,
Gautham

Re: Zero is moved to variable

PostPosted: Fri Mar 06, 2015 3:19 am
by Mickeydusaor
it should be 9(04)