IBM AS/400 manual Creating the Service Program, Sample Service Program

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 121
Image 121
43. Source for /COPY Member with Prototype for CvtToHex

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

guage

to

determine

the interface, so that the program

could

be

mor

at

a

later date.

Figure 44

shows the binder

language

needed to

d

of

the service program CVTTOHEX. This source is

used in

the

EXPORT,

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 i guage is the interface. Any program bound to CVTTOHEX will make use o signature.

The binder language EXPORT statements identify the exports

of

the

se

program.

You

need

one

for each procedure

whose

exports

you

want

t

able

to

the

caller.

In this

case,

the service

program

contains one

contains

one procedure. Hence, only one EXPORT statement is required.

For

more

information

on

binder

language

and

signatures,ILE Conceptsee.

 

 

 

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

CRTRPGMOD MODULE(MYLIB/CVTTOHEX) SRCFILE(MYLIB/QRPGLESRC￿)

2.Create the service program using the module CVTTOHEX and the bind 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 expo service program will make available. In this case, it is based o found in the member CVTTOHEX in the file QSRVSRC in the library MYL

Chapter 8. Creating a Service Program97

Page 121
Image 121
IBM AS/400 manual Creating the Service Program, Sample Service Program, Source for /COPY Member with Prototype for CvtToHex