Sample Service Program
*=================================================================*
* CvtToHex - convert input string to hex output string
*
* Parameters
* 1. Input: string character(n)
* 2. Output: hex string character(2 * n)
*=================================================================*
D CvtToHex PR OPDESC
D InString 16383 CONST OPTIONS(*VARSIZE)
D HexString 32766 OPTIONS(*VARSIZE)
Figure 43. Source for /COPY Member with Prototype for CvtToHex
When designing this service program, it was decided to make use of binder lan-
guage to determine the interface, so that the program could be more easily updated
at a later date. Figure 44 shows the binder language needed to define the exports
of the service program CVTTOHEX. This source is used in the EXPORT, SRCFILE
and SRCMBR parameters of the CRTSRVPGM command.
STRPGMEXP SIGNATURE('CVTHEX')
EXPORT SYMBOL('CVTTOHEX')
ENDPGMEXP
Figure 44. Source for Binder Language for CvtToHex
The parameter SIGNATURE on STRPGMEXP identifies the interface that the
service program will provide. In this case, the export identified in the binder lan-
guage is the interface. Any program bound to CVTTOHEX will make use of this
signature.
The binder language EXPORT statements identify the exports of the service
program. You need one for each procedure whose exports you want to make avail-
able to the caller. In this case, the service program contains one module which
contains one procedure. Hence, only one EXPORT statement is required.
For more information on binder language and signatures, see
ILE Concepts
.
Creating the Service Program
To create the service program CVTTOHEX, follow these steps:
1. Create the module CVTTOHEX from the source in Figure 42 on page 95, by
entering:
CRTRPGMOD MODULE(MYLIB/CVTTOHEX) SRCFILE(MYLIB/QRPGLESRC)
2. Create the service program using the module CVTTOHEX and the binder lan-
guage shown in Figure 44.
CRTSRVPGM SRVPGM(MYLIB/CVTTOHEX) MODULE(*SRVPGM)
EXPORT(*SRCFILE) SRCFILE(MYLIB/QSRVSRC)
SRCMBR(*SRVPGM)
The last three parameters in the above command identify the exports which the
service program will make available. In this case, it is based on the source
found in the member CVTTOHEX in the file QSRVSRC in the library MYLIB.
Chapter 8. Creating a Service Program 97