I'm not the most Java saavy person but in essence, your assumption is
correct.  Service programs are simliar to jar files.  Below is the code
for a simple service program.

     h nomain
     h option(*nodebugio)

     * Files Used
     FCkEmpLMs  IF   E           K Disk    UsrOpn
     FCkClassF  IF   E           K Disk    UsrOpn

     * Copybooks
      /copy qcopysrc,KR0056PR

     * Internal Non-Exported Procedures
     DInitialize       PR

     * Global Variables
     D Files_Opened    S               n   Inz(*Off)
     D CompanyNumber   c                   Const(01)

     * Get Pay Period Procedure
     PGetPayPeriod     B                   Export
     DGetPayPeriod     PI
     D  StartDate                      D
     D  EndDate                        D
     D  Success                        n

     * Local Variables
     D Find_EmpNo      S              9s 0
     D SQL$            S           3000a   Varying

      /copy qcopysrc,sqloptions

     * Procedure Code

     * Find An Employee With Unposted Time
     c/exec sql
     c+ Select Max(TiEmpN) Into :Find_EmpNo From CkTimeFl Where
TiPHst<>'P'
     c/end-exec
      /free

         //Open Files If Not Open...
         Initialize();

         //Find The Employee's Record
         Chain (CompanyNumber:Find_EmpNo) CkEmpLMs;
         If Not %Found;
           Success=*Off;
           Return;
         EndIf;

         //Get The Current Pay Period Date From The Employee's Pay
Period Rule
         Chain (EETCod) CkClassF;
         If Not %Found;
           Success=*Off;
           Return;
         EndIf;

         //Return The Pay Period Dates
         StartDate=%Date(CFFDt1:*ISO);
         EndDate=%Date(CFTDt1:*ISO);
         Success=*On;

         Return;
      /end-free
     PGetPayPeriod     E

     * Procedure To Open Files & Initialize Variables
     PInitialize       B
     DInitialize       PI
      /free
         If (Files_Opened);
           Return;
         EndIf;

         Open CkEmpLMs;
         Open CkClassF;
         Files_Opened=*On;
      /end-free
     PInitialize       E

     * Procedure To Return Employee Record Data
     PGetEmployeeData  B                   Export
     DGetEmployeeData  PI
     D  GetEmpNumber                  9s 0 Const
     D  Name                         30a
     D  Branch                       10a
     D  Dept                         10a
     D  CoID                         10a
     D  Success                        n

     * Procedure Code
      /free

         //Ensure That The Files Are Open
         Initialize();

         Chain (CompanyNumber:GetEmpNumber) CkEmpLMs;
         If Not %Found;
            Success=*Off;
         Else;
            Name=EEName;
            Branch=EESec3;
            Dept=EESec4;
            CoID=EESec7;
            Success=*On;
         EndIf;
      /end-free
     PGetEmployeeData  E

     * Check For Other Productive
     PCheckForOT       B                   Export
     DCheckForOT       PI            10i 0
     D PayCodes                       5a   Dim(10) Const
     D Element         s             10i 0
      /free
        Element=%LookUp('OTHPR':PayCodes);
        Return Element;
      /end-free
     PCheckForOT       E

     * Check For Productive
     PCheckForPROD     B                   Export
     DCheckForPROD     PI            10i 0
     D PayCodes                       5a   Dim(10) Const
     D Element         s             10i 0
      /free
        Element=%LookUp('PROD':PayCodes);
        Return Element;
      /end-free
     PCheckForPROD     E

     * Get OT Hours
     PGetOTHours       B                   Export
     DGetOTHours       PI             5s 2
     D HoursArray                     5s 2 Dim(10) Const
     D Element                       10i 0 Const
      /free
        Return HoursArray(Element);
      /end-free
     PGetOTHours       E

     * Get PROD Hours
     PGetPrHours       B                   Export
     DGetPrHours       PI             5s 2
     D HoursArray                     5s 2 Dim(10) Const
     D Element                       10i 0 Const
      /free
        Return HoursArray(Element);
      /end-free
     PGetPrHours       E

     * Total Other Productive Hours
     PTotalOTHours     B                   Export
     DTotalOTHours     PI             6s 2
     D PayPeriodOT                    5s 2 Dim(14) Const
      /free
         Return %XFoot(PayPeriodOT);
      /end-free
     PTotalOTHours     E

     * Total Productive Hours
     PTotalPrHours     B                   Export
     DTotalPrHours     PI             6s 2
     D PayPeriodOT                    5s 2 Dim(14) Const
      /free
         Return %XFoot(PayPeriodOT);
      /end-free
     PTotalPrHours     E

     * Close Application Procedure
     PClose_App        B                   Export
     DClose_App        PI
      /free
         If %Open(CkEmpLMs);
           Close CkEmpLMs;
         EndIf;
         If %Open(CkClassF);
           Close CkClassF;
         EndIf;

         Files_Opened=*Off;
      /end-free
     PClose_App        E 

Basically a service program consists of a module or modules(similar to
the java class).  There is one source member per module.  A module can
consist of a single procedure or many procedures (similar to java
functions).  To create the service program you compile your source code
as type *MODULE, then you execute the CRTSRVPGM command listing the
modules (class if you prefer) to put into the service program(jar).
Additionally you can use binding directories & binding source to
function similar to a manifest.  Hope this is clear as mud & that I
haven't misrepresented anything...if so...blame it on Thursday...which
is typically all meetings for me LOL


Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces+tommy.holden=hcahealthcare.com@xxxxxxxxxxxx
[mailto:rpg400-l-bounces+tommy.holden=hcahealthcare.com@xxxxxxxxxxxx] On
Behalf Of Jake M
Sent: Thursday, March 30, 2006 9:07 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Service Program Vs Jar File.

I am a RPG newbie. So, here is a naive question. Are Service Programs
same
as Jar Files in Java, Or am I totally wrong? I create my  .jar files as
a
conglomeration of several .class files and then just that in all my
.java
code. I am looking for a simple example to create a service program and
use
that service program in RPGLE source member.

Thanks in advance,

Jake.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 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.