IBM AS/400 manual Binding to a Program, Sample Service Program, Modul

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 122
Image 122

Sample Service Program

Note that a binding directory is not required here

because

all mo

to create the service program have been specified

with the

MODUL

eter.

 

 

The service program CVTTOHEX will be created in the library MYLIB. It debugged using a statement view; this is determined by the default 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 CVTHEXPGM which is bound to the service program. It uses a seven-chara string which it passes to CVTTOHEX twice, once where the value of the is 10 (that is, convert 5 characters) and again where the value is 1 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 servi program would normally be used by many other programs, or many times by programs; otherwise the overhead of initial call does not justify making service program.

To create the application follow these steps:

1.Create the module from the source in Figure 45 on page 99, by ente

CRTRPGMOD MODULE(MYLIB/CVTHEXPGM) SRCFILE(MYLIB/QRPGLESR￿C)

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 in face it uses to interact with the service program. This is the s 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

verif

that:

 

 

 

 

 

 

 

 

¹

The

service program CVTTOHEX in library MYLIB

can

be

found

 

¹

The

public interface

used

by CVTHEXPGM when

it

was

created

is s

 

at

run

time.

 

 

 

 

 

 

If either of the above is not true, then an error message is i

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

Page 122
Image 122
IBM manual Binding to a Program, Sample Service Program, Modul, ILE RPG for AS/400 Programmers Guide