Getting error while executing packed to decimal



IBM's Command List programming language & Restructured Extended Executor

Getting error while executing packed to decimal

Postby Balua2g » Wed Mar 02, 2011 8:04 pm

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
Balua2g
 
Posts: 2
Joined: Tue Sep 21, 2010 4:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Getting error while executing packed to decimal

Postby NicC » Wed Mar 02, 2011 8:09 pm

In which line are you getting the error?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Getting error while executing packed to decimal

Postby prino » Wed Mar 02, 2011 8:14 pm

Have you used "trace ?r" or "trace ?i" to see what's happening?

Obviously not...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times

Re: Getting error while executing packed to decimal

Postby enrico-sorichetti » Wed Mar 02, 2011 8:17 pm

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
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: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Getting error while executing packed to decimal

Postby enrico-sorichetti » Wed Mar 02, 2011 8:31 pm

awkward way of checking for negativity
wouldn' t be enough to compare with 0
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: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post