IBM AS/400 Frozen Dessert Maker User Manual


 
Sample Service Program
Note that a binding directory is not required here because all modules needed
to create the service program have been specified with the MODULE param-
eter.
The service program CVTTOHEX will be created in the library MYLIB. It can be
debugged using a statement view; this is determined by the default DBGVIEW
parameter on the CRTRPGMOD command. No binder listing is produced.
Binding to a Program
To complete the example, we will create an 'application' consisting of a program
CVTHEXPGM which is bound to the service program. It uses a seven-character
string which it passes to CVTTOHEX twice, once where the value of the hex string
is 10 (that is, convert 5 characters) and again where the value is 14, that is, the
actual length.
Note that the program CVTHEXPGM serves to show the use of the service
program CVTTOHEX. In a real application the caller of CVTTOHEX would have
another primary purpose other than testing CVTTOHEX. Furthermore, a service
program would normally be used by many other programs, or many times by a few
programs; otherwise the overhead of initial call does not justify making it into a
service program.
To create the application follow these steps:
1. Create the module from the source in Figure 45 on page 99, by entering:
CRTRPGMOD MODULE(MYLIB/CVTHEXPGM) SRCFILE(MYLIB/QRPGLESRC)
2. Create the program by typing
CRTPGM PGM(MYLIB/CVTHEXPGM)
BNDSRVPGM(MYLIB/CVTTOHEX)
DETAIL(*BASIC)
When CVTHEXPGM is created, it will include information regarding the inter-
face it uses to interact with the service program. This is the same as reflected
in the binder language for CVTTOHEX.
3. Call the program, by typing:
CALL CVTHEXPGM
During the process of making CVTHEXPGM ready to run, the system verifies
that:
The service program CVTTOHEX in library MYLIB can be found
The public interface used by CVTHEXPGM when it was created is still valid
at run time.
If either of the above is not true, then an error message is issued.
The output of CVTHEXPGM is shown below. (The input string is 'ABC123*'.)
Result14++++++
Result10++
C1C2C3F1F2 10 character output
C1C2C3F1F2F35C 14 character output
98 ILE RPG for AS/400 Programmer's Guide