Problem when trying to moving alpha numeric to char



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

Problem when trying to moving alpha numeric to char

Postby STYLISHVINOD » Tue Sep 18, 2012 8:33 pm

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.
STYLISHVINOD
 
Posts: 1
Joined: Fri Aug 27, 2010 3:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem when trying to moving alpha numeric to char

Postby BillyBoyo » Tue Sep 18, 2012 8:35 pm

Can you show your data definitions, and also explain why you would think it a good idea to have "/" in a numeric field?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Problem when trying to moving alpha numeric to char

Postby enrico-sorichetti » Tue Sep 18, 2012 8:41 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Problem when trying to moving alpha numeric to char

Postby Robert Sample » Tue Sep 18, 2012 8:43 pm

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).
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Problem when trying to moving alpha numeric to char

Postby dick scherrer » Wed Sep 19, 2012 12:53 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post