Hi All,
Can anyone tell me how we can MOVE value of a X(19)
variable to a S9(17) COMP-3 variable?
Answer with an Example will be of great help.
Answers were Sorted based on User's Feedback
Answer / nicx
The function NUMVAL can be used to change the X(19) to S
(17) and then moved to comp-3
Ex:
ws-variable PIC X(19)
ws-variable-1 PIC S9(17)
ws-variable-1 PIC S9(17) comp-3
Compute ws-variable-1 = function numval(ws-variable)
move ws-variable-1 to ws-variable-2.
Ofcourse you should be expecting a signed 9(17) value in
the ws-variable. Check out NUMVAL-C too. Both functions are
a great help in such situations.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / nk
05 MY-NUM-ALPHA PIC X(9).
05 MY-NUM REDEFINES MY-NUM-ALPHA PIC S9(17) COMP-3.
MOVE 'ABCDEFGHI' to MY-NUM-ALPHA.
note that comp-3 stores 2 numbers per byte so 17 digits
takes 9 bytes (half of one byte stores the sign.) So you
could move a 19-character variable to a 9-byte field but it
will be truncated.
| Is This Answer Correct ? | 5 Yes | 5 No |
Answer / gans
NICX's statements worked for me...
Thanks NICX....
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ram.g
Vamsi, u r wrong, you have to read the 2nd answer again...
we can't perform any numeric operations on arithmetic field
thats right for overcome that scenario only we are using
the method called redefine. when you redefine its pointing
to the same loacation only but just telling the MVS
consider the new picture clause for the new variable..one
thing is sure here which is nothing but truncation when you
try to move x(...) to comp-3 but we can perform arithmetic
operations for sure..you can try it out....
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / vamsi
First of all s9(17) comp-3 will occupy 9 bytes and X(19) has
19 bytes of memory.
When we move the text value to an comp-3 field, we will get
Soc7 error. We cannot move alpha values to numeric fields.
If the X(17) contain numeric values then we can move this
field to s(17) comp-3 field and we can move only 9 bytes
other data will be trucated.
| Is This Answer Correct ? | 4 Yes | 8 No |
How to use the same COBOL program in Batch and CICS on lines? explain with an example
With in these three which one is the default one Call Reference, Call By Value, Call By Content.-Which one is default?
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..
What is the meaning of 'TALLING' verb in cobol?
I have a occurs for 100 times but it has executed 101 time what could be the reason?
how can u redefine picx(10) with pic 9(6).
I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?
Consider the following: 77 W-NUM PIC 9 VALUE 0 ------ MOVE 1 TO W-NUM PERFORM PARA-X UNTIL W-NUM > 9. ------ PARA-X ADD 1 TO W-NUM How many times PARA-X is executed ?
if a pic 9(3) value 354,b pic x(2) value '46' then a)a>b 2)a<b 3)error
What are the differences between OS VS COBOL and VS COBOL II?
how do you reference the esds vsam file formats from cobol programs
How to delete leading spaces/blank in COBOL ? Example:- 01 data-name-1 pic x(220) " English is a language". I would like to delete leading spaces.