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



On Thu, 2004-02-12 at 00:37, murali dhar wrote:
> Hi, 
> I want to suppress the leading zero in CEXPR field of
> my PF. It is the printable strike price(7 char) field
> and my application  stores this field with leading
> zeros. This is causing problems for client web when
> they upload the data. So they want us to suppress the
> leading zeros in the 7 char field. 
> which string fucntion in RPG i can use ? 
> if anyone know ,please share the knowledge, as I dont
> ve much time to refer notes,however i will do it,your
> help is more appreciated
> --- 
> Murali.
Murali,

Just write one if you aren't sure of an API.   See below...

--
Regards,
Rich

Current Conditions in Des Moines, IA
Overcast
Temp 15.8F, Windchill 0.8F
Winds out of the North at 15mph
Light Snow 

     H dftactgrp(*no)

     D $rc             s              7
     D $test0          s              7    inz('0000123')
     D $test1          s              7    inz('1234567')
     D $test2          s              7    inz('0000000')

     D  suppress       pr             7a
     D  input                         7a

     C                   eval      $rc = suppress($test0)
     C     $rc           dsply
     C                   eval      $rc = suppress($test1)
     C     $rc           dsply
     C                   eval      $rc = suppress($test2)
     C     $rc           dsply

     C                   eval      *inlr = '1'

      *************************************************************
      *
      * procedure: suppress
      *
      * suppress leading zeros on input field.
      * This code actually left justifies the field,
      * removing the zeros
      *
      * If there aren't any zeros in the data:
      *    returns the original data
      *
      * If the data is just zeros:
      *    returns blanks
      *
      * If the data has at least some leading zeros:
      *    returns data from most significant byte and on

     P suppress        b
     D suppress        pi             7a
     D input                          7a

      * results go here
     D result          s              7a

      * temp vars
     D i               s             10i 0

      * In case there aren't any zeros in the data
      * In case all there are is zeros in the data
     C     input         ifne      *all'0'
     C                   eval      result = input
     C                   endif

     C     1             do        7             i
     C                   if        %subst(input:i:1) > '0'
     C                   eval      result = %subst(input:i)
     C                   leave
     C                   endif
     C                   enddo

     C                   return    result
     P                 e



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.