Page 1 of 1

Getting error while executing packed to decimal

PostPosted: Wed Mar 02, 2011 8:04 pm
by Balua2g
Hi All,

I have a requirement where in which i need to validate the comp-3 field in the input file, I have coded it in rexx as below.
I am using C2X function to convert the packed to hexadecimal and validating it for numeric check, but the code is giving problem.
The comp-3 field declaration is as follows
S9(9)V99 COMP-3


NUMB = OFFC       
CALL PAK2DEC(NUMB)

IF ¬DATATYPE(RESULT,N)         
THEN DSN = 'AMOUNT NOT VALID'
IF (RESULT = -NUMB)
THEN DSN = 'AMOUNT is NEGATIVE'

EXIT

PAK2DEC:                                     
/* CONVERT PACKED DATA TO HEX AND SPLIT */   
ERG = C2X(NUMB)                             
SIGN = RIGHT(ERG,1)                         
NUMB = LEFT(ERG,LENGTH(ERG)-1)               
/* CHECK SIGN AND NUMERIC SECTIONS */       
  IF  VERIFY(SIGN, "ABCDEF" ) > 0 THEN ,     
      RETURN ""                             
  IF  VERIFY( NUMB, "0123456789" ) > 0 THEN ,
      RETURN ""                             
/* CHECK NEGATIVE SIGN */                   
  IF  POS(SIGN, "BD" ) > 0 THEN,             
      RETURN -NUMB                           
  ELSE ,                                     
      RETURN  NUMB                           


I am getting one error as below
Bad arithmetic conversion

Re: Getting error while executing packed to decimal

PostPosted: Wed Mar 02, 2011 8:09 pm
by NicC
In which line are you getting the error?

Re: Getting error while executing packed to decimal

PostPosted: Wed Mar 02, 2011 8:14 pm
by prino
Have you used "trace ?r" or "trace ?i" to see what's happening?

Obviously not...

Re: Getting error while executing packed to decimal

PostPosted: Wed Mar 02, 2011 8:17 pm
by enrico-sorichetti
0FFC is not a packed <thing>

here are the links to two topics where I posted
the REXX functions for packing and unpacking

http://ibmmainframes.com/about31547.html

http://ibmmainframes.com/about27921.html

Re: Getting error while executing packed to decimal

PostPosted: Wed Mar 02, 2011 8:31 pm
by enrico-sorichetti
awkward way of checking for negativity
wouldn' t be enough to compare with 0