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



Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

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

Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

Answer / ram.g

you can try with redefine....

Is This Answer Correct ?    3 Yes 1 No

Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

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

Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

Answer / gans

NICX's statements worked for me...
Thanks NICX....

Is This Answer Correct ?    0 Yes 0 No

Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

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

Hi All, Can anyone tell me how we can MOVE value of a X(19) variable to a S9(17) COMP-3 variable?..

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

Post New Answer

More COBOL Interview Questions

I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?

3 Answers   IBM,


1)what is the maximum limit for occurs? Eg: 01 A PIC X(10) OCCURS N TIME. What is the max value for N?

11 Answers   Wipro,


What is the significance of the PROGRAM-ID paragraph? If this name doesnt match with the name of the COBOL program, does it make a difference? Is the name specified in the PROGRAM-ID paragraph used as a name for the load module or any such thing?

4 Answers   IBM,


How to concatenation one or more string?

4 Answers   Temenos,


What is the difference between next sentence and continue in cobol programing language?

0 Answers  






In INITIALIZE what is Repalcing Word will do

1 Answers   CTS,


what is qualification on occurs clause?

2 Answers  


What is the difference between subscript and index?

1 Answers  


How to find whether a Flat file is empty or not without Reading a file in COBOL Program. (not using JCL)

9 Answers   Bank Of America,


i have two file, each file having : file1 is having 2 fields field1 field2 file2 is having 3 fields field1 field2 field3 my req is to make it one file like: field1 field2 field1 field2 field3 if anyone know please send me syntax, i tried this with DFSORT but could not succeed.

9 Answers   Syntel,


Write a cobol program making use of the redefine clause.

0 Answers  


What are the pertinent COBOL commands?

0 Answers   Satyam,


Categories