Format Text Date

 

      //___________________________________________________________
      //  TextDate():  Returns the current date, formatted as text
      //
      //     For example:  ‘Aug 25, 2009′
      //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
     p TextDate        b
     d                 pi            25a
     d  peDate                         d   Options(*NoPass)
     d                                     DatFmt(*ISO)

     d CurDate         s               d   DatFmt(*ISO)
     d                                     Inz(*Sys)
     d CurDay          s              2p 0
     d CurYear         s              4p 0
     d CurMM           s              2p 0
     d CurMonth        s              3a   varying

     d retField        s             25a

     d MonthsDS        ds
     d                                3a   Inz(‘Jan’)
     d                                3a   Inz(‘Feb’)
     d                                3a   Inz(‘Mar’)
     d                                3a   Inz(‘Apr’)
     d                                3a   Inz(‘May’)
     d                                3a   Inz(‘Jun’)
     d                                3a   Inz(‘Jul’)
     d                                3a   Inz(‘Aug’)
     d                                3a   Inz(‘Sep’)
     d                                3a   Inz(‘Oct’)
     d                                3a   Inz(‘Nov’)
     d                                3a   Inz(‘Dec’)
     d Months                         3a   Overlay(MonthsDS)
     d                                     Dim(12)

      /Free

           If %Parms > 0;
             CurDate = peDate;
           EndIf;
           CurDay  = %subdt(CurDate :*Days);
           CurYear = %subdt(CurDate :*Years);
           CurMM   = %subdt(CurDate :*Months);

           CurMonth = Months(CurMM);

           retField = CurMonth + ‘ ‘
                    + %EditC( CurDay: ‘X’ ) + ‘, ‘
                    + %EditC( CurYear: ‘X’ );

           Return retField;

      /End-Free
     p                 e

 

Tags: ,

RPG center text Procedure

    h NoMain
     //_______________________________________________________________
     //    šCenter text.
     //    šReturns passed in text centered within size of field
     //    špassed in.
           //     Copyright 2009
     //    iPort Tech  www.iPortTech.com
     //_______________________________________________________________
     //ˆRevision Log
     //žDate       žProgrammer   žComment
 
     /Copy cpysrc,z_Center
 
     //_______________________________________________________________
    p z_Center        b                   Export
    d                 pi           256a
    d peString                     256a   Const
    d                                     Varying
    d peLength                       5u 0 Const
    d                                     Options(*NoPass)
 
    d StartPos        s              5i 0 Inz
    d wwLen           s              5i 0 Inz
    d retField        s            256a   Varying
 
     /Free
      If %Parms > 1;
        wwLen = peLength;
      Else;
        wwLen = %Len(peString);
      EndIf;
      retField = wwLen;
      StartPos = ((wwLen – %Len(%Trim(peString))) / 2) + 1;
      %SubSt(retField :StartPos) = %Trim(peString);
 
      Return retField;
     /End-Free

    p                 e 

Tags: ,

API Programming

The number of API’s available on the Power i are increasing with each release of the OS. Why aren’t you taking advantage of these handy tools?

Admittedly some API’s are very complex and cumbersome. We can help you write simple to use wrappers around some of these giving your programming staff easy access to these tools.

Tags: , ,

Binding Directories

Did you know by placing the correct H spec in your RPG code listing a binding directory you can eliminate the need to manually bind all procedures and service programs when you create your program?

The use of binding directories in combination with /Copy code can help standardize your applications and reduce complex processes to compile code.

Tags: , ,

Service Programs

When do you use a service program and when do you use a module? There is a difference in performance with each and using the correct method can save processing time for your applications. We use modules when they are called for and service programs when the application justifies it.

As always, if you have questions we’d love to help you answer them.

Tags: , , ,

Subfile Programming

Subfile programming can be tricky but is an essential part of RPG programming.

We have the expertise to develop or enhance subfile applications for you. Don’t hesitate to contact us and take advantage of our knowledge and experience. We listen to what you want.

Tags: , ,

Embedded SQL

Have you wanted to see multiple views of a physical file and had to create a logical file for each view? How about deleting whole sets of records without chaining or reading each one?

With embedded SQL in RPG we can gather data from files in almost any view without creating logical files. The flexibility this provides is nearly invaluable. We can incorporate embedded SQL in applications for you.

Contact us for a sample embedded SQL RPGLE program.

Tags: ,