ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Upper case function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Upper case function

    Is there an upper case function in RPGLE? I can't find one. We have a little routine that works but it is not clean. Anyone have a clean function they would like to share?

  • #2
    Re: Upper case function

    Hi rpgKnight:

    Give this a shot:

    Code:
         D A2ZU            C                   CONST('ABCDEFGHIJKLMNOPQRST+
         D                                     UVWXYZ')                    
         D A2ZL            C                   CONST('abcdefghijklmnopqrst+
         D                                     uvwxyz')                    
          /FREE                                                            
                     MyString= %XLATE(a2zl:a2zu:MyString);
          /END-FREE
    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Upper case function

      I believe the %upper bif is being implemented in RPGV.

      Until then, you can wrap what GLS coded into a function / subprocedure. That way ,you dont need the arrays in each program. (Because you dont want some doofus changing a letter in the array, which would screw up the translation.)
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #4
        Re: Upper case function

        Thanks.

        We currently use the XLATE version.

        Comment


        • #5
          Re: Upper case function

          sql works

          Code:
          update  oezoord                                      
           set ozcname = upper(substr(ozcname, 1, 1)) ||   
          lower(substr(ozcname, 2))
          Code:
          
          d MyField         s             30    inz('snfdAredff')   
                                                                    
           /free                                                    
                                                                    
                  exec sql                                          
                  select upper(:MyField) into :Myfield              
                        FROM SYSIBM/SYSDUMMY1;                      
                                                                    
                  *inlr = *on;                                      
                                                                    
           /end-free



          This works -- I think

          Code:
           *    -------------------------------------------------------------                           
          D ConvertCase     PR                  ExtProc('QlgConvertCase')                               
          D                               22                                         Request Control Blk
          D                               92    options(*varsize)                    input data         
          D                               92    options(*varsize)                    returned data      
          D                               10i 0 const                                length of data     
          Db                                    like(vApiErrDS)                      error parm         
          
          C                   callp     ConvertCase(CaseCtlBlk:defkeyword:     
          C                             defkeyword:%len(defkeyword):vApiErrDs)
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Upper case function

            @Jamie:

            When using SQL Scalar functions, you do not need to access any table, simply use the SQL SET statement:
            Code:
            /Free
               Exec SQL  Set :UpperText = Upper(:MyText);
            /End-Free
            ... the SQL function UPPER works for single byte and double byte character sets and in any language environment you are working in (no need to care about any special characters such as the German ä,ü,ö)

            Birgitta
            Last edited by B.Hauser; August 27, 2011, 03:28 AM.

            Comment


            • #7
              Re: Upper case function

              Thanks Birgitta

              Have a great weekend.
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment

              Working...
              X