Page 1 of 1

Problem when trying to moving alpha numeric to char

PostPosted: Tue Sep 18, 2012 8:33 pm
by STYLISHVINOD
Hi ,

when i am trying to move 6 byte alphanumeric data to 6 byte numeric variable, i am able to get the data properly.
but when i am passing an alphanumeric data greater than 6 bytes,my programcanhandle that data and get only the 6 bytes
from the input data in the alphanumeric variable then pass to the numeric variable.

in the second case i am not getting the correct output.

EX::

input :: AAA/ZA
Output :: AAA/ZA (as expected)

case2::
Input :: HFGBCHGAAA/ZA
Output :: AAA/Z1 (But expect output is AAA/ZA).

please suggest what changes i have to made in the code to get the correct output.

Thanks.

Re: Problem when trying to moving alpha numeric to char

PostPosted: Tue Sep 18, 2012 8:35 pm
by BillyBoyo
Can you show your data definitions, and also explain why you would think it a good idea to have "/" in a numeric field?

Re: Problem when trying to moving alpha numeric to char

PostPosted: Tue Sep 18, 2012 8:41 pm
by enrico-sorichetti
and the title talks about ...
Problem when trying to moving alpha numeric to char

ok for the language barrier, but what about rereading the post before hitting enter ???

better to scratch everything and restart from the beginning

Re: Problem when trying to moving alpha numeric to char

PostPosted: Tue Sep 18, 2012 8:43 pm
by Robert Sample
1. Numeric fields should contain numbers -- if the PICTURE is nothing but 9's, then you should have nothing but zero through nine in that varaible.
2. Moving AAA/ZA to a numeric variable, you will get AAA/Z1 and (depending upon the compiler option NUMPROC) that's the way COBOL works -- it will ensure there is a valid sign (or unsigned byte) so the X'C1' in the last byte will be changed to X'F1'.
3. You can get around the whole problem by changing the receiving variable to PIC X(6) instead of PIC 9(6) -- or whatever you have it defined as. You might have to investigate JUST RIGHT in the COBOL manual (link at the top of the page).

Re: Problem when trying to moving alpha numeric to char

PostPosted: Wed Sep 19, 2012 12:53 am
by dick scherrer
Hello and welcome to the forum,

Why does (did?) someone believe it was an acceptable approach to move such a value to a numeric field (AAA/ZA)?

What numeric value was to be expected?