Archive for category Service Programs

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: ,

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: , , ,