× 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.


  • Subject: Re: Char to numeric conversion question
  • From: "Scott Klement" <infosys@xxxxxxxxxxxx>
  • Date: 19 Apr 1999 16:26:25 -0500

Hmmm...  I can think of two different ways to do this...

     1) If you dont need things to be too terribly robust, and this
        is just a report where everything is always in the same column
        you could simply data the data before the "." and do an
        XLATE to translate all spaces to zeros...    then movel the
        part before the "." to your 9,2 and MOVE the part after the
        dot...    not terribly robust, but its easy.

     2) Assuming you're using a version of RPG that supports floating
        point you could call the atof function from the ILE C
        binding directories just by prototyping it and binding in
        the service prgorams...

     3) You could actually write an RPG routine to parse the number.
        This would involve writing a state-machine program where you
        read until you get a non-space, then read in all the numbers
        until you get a non-number, and store them somewhere.  then
        check to see if your non-number is a "." and if so, read in
        the numbers that follow it until you get a non-number and
        store that somewhere.   Then left pad the numbers before the
        decimal place with zeros, and right pad the ones after the
        decimal place with zeros, and throw the whole thing into a
        numeric field.

All of these (in my opinion) fall into the category of "relatively
simple."

If you need help, let me know...


Paul Jackson <paulgjackson@yahoo.com> wrote:
> Hello All,
>
> Ok here's my problem. I am converting a spool file
> into a data base work file.  I am reading the spooled
> file records and trying to convert edited numeric
> values into packed fields for storage.
>
> For example I have a value from the spool file that
> comes in as character 'bbbbb25.03' and I want to put
> this into a 9,2 packed field.
>
> I looked for RPGIV built in functions but could find
> none that seemed to do the job.  Any suggestions on
> how to do this in a relatively simple way?
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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.