× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Michael,
        As I learned from this list the BIFs %INT() and %DEC() are
expecting character data of numeric data to be formatted in the same
manner you would get if you put a numeric value through %CHAR().

Try this example out, 
d num             s              8S 2 
d char_num        s             10A   
                                      
 /Free                                
   num = 12345.78;                    
   char_num = %char(num);             
   dsply char_num;                    
                                      
   num = %dec(char_num:8:2)+.02;      
   dsply num;                         
                                      
   num = -12345.78;                   
   char_num = %char(num);             
   dsply char_num;                    
                                      
   num = %dec(char_num:8:2)+.02;      
   dsply num;                         
                                      
   *inlr = *on;                       
 /End-free                            

I used "+.02" to show that the conversion from char to decimal works by
altering the result before DSPLY.  

Unfortunately, if you are carrying the sign in the character like you
have shown, I do not believe there is direct solution. You could create
a DS that maps character to zone, like the following...
d mapper          ds                 
d  char_num               1     15A  
d  num                    1     15S 2
 /Free                               
  char_num = '  000000000255N';      
  dsply num;                         
  *inlr = *on;                       
 /End-free                           

The above is not very elegant and prone to data decimal errors.

Thanks, Matt



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Michael Jacobsen
Sent: Thursday, March 09, 2006 1:35 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: How to convert character field w/ negative numeric data
(255N)

Alan,

That was a good suggestion, and something I hadn't thought of. 
Unfortunately, that didn't fix the problem.  I still receive the same 
error with or without the spaces. 

Oh well.  I'll just use move if there is no other way.


Mike


rpg400-l-bounces@xxxxxxxxxxxx wrote on 03/09/2006 03:21:53 PM:

> 
> Hi Michael - in this instance, I think its the leading spaces that is
> causing the problem, and not the N. So replace the blanks with 0
(zero) 
and
> try it
> 
> 
> 
> Alan Shore

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.