1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer...

19
1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: [email protected]

Transcript of 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer...

Page 1: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

1

ILE Component Programming Reference

Presented By: Ric Slaten, Sr. Software Systems Engineer

E-mail: [email protected]

Page 2: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

2

Introduction

Using ILE components to build a 3-Tier application• Procedures

• Prototypes

• Parameters/Procedure Interface

• Modules

• Service programs• Binder Source

• Binding Directories

Page 3: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

3

Prototypes and Parameters

A prototype is a definition of the call interface. It includes the following information:• Whether the call is bound (procedure) or dynamic (program)

• How to find the program or procedure (the external name)

• The number and nature of the parameters

• Which parameters must be passed, and which are optionally passed

• Whether operational descriptors should be passed

• The data type of the return value, if any (for a procedure)

Page 4: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

4

Prototype Definition Example

D***Prototype definition D getMLTSITEL01sitename... D pr 51a ExtProc('getMLTSITEL01sitename') D 5s 0 Value D***Program working storage (continued) D d$SiteDataStr ds INZ D d$SiteStatus 1a D d$SiteName 50a C***Begin program logic C Eval d$SiteDataStr =

C getMLTSITEL01sitename(d$SiteDataStr)

Procedure name

Returned value specification

Input parameter declaration

Procedure call

Page 5: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

5

Procedure Interface

If a prototyped program or procedure has call parameters or a return value, then a procedure interface definition must be defined, either in the main source section (for a main procedure) or in the subprocedure section. A procedure interface definition repeats the prototype information within the definition of a procedure. It is used to declare the entry parameters for the procedure and to ensure that the internal definition of the procedure is consistent with the external definition (the prototype).

Page 6: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

6

Procedure Interface Definition Example

PgetMLTSITEL01sitename... P b Export D pi 51a DR$SiteCode 5s 0 Value *------------------------------------------------------------------- * Local function variables and return value definition. *------------------------------------------------------------------- Dd$SiteName ds D d$RecordStatus 1a D d$Name like(esitename) C Open (e) MLTSITEL01 C If %Error C Eval d$RecordStatus = FileError C Eval d$Name = *Blanks C Return d$SiteName C Endif C R$SiteCode Chain (e) RMLTSITE C Close MLTSITEL01 C If %Error C Eval d$RecordStatus = Locked

Procedure Name and the beginning ‘P’ specification

Procedure Interface marks thebeginning of the parameter listand allows the definition of a return value

Method used to pass the parameter to the procedure

EXPORT keyword allows procedure to be used in other modules and programs

Page 7: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

7

Procedure Interface Definition Alternative Example

PgetMLTSITEL01sitename... P b Export D pi 1a DR$SiteCode like(esitecode) D Value *------------------------------------------------------------------- * Local function variables and return value definition. *------------------------------------------------------------------- Dd$SiteName ds D d$RecordStatus 1a D d$Name like(esitename) C Open (e) MLTSITEL01 C If %Error C Eval d$RecordStatus = FileError C Eval d$Name = *Blanks C Return d$SiteName C Endif C R$SiteCode Chain (e) RMLTSITE C Close MLTSITEL01 C If %Error C Eval d$RecordStatus = Locked

Procedure Name and the beginning specification

Procedure Interface marks thebeginning of the parameter listand allows the definition of a return value

Method used to pass the parameter to the procedure

EXPORT keyword allows procedure to be used in other modules and programs

Page 8: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

8

Procedure

A procedure is a set of self-contained high-level language statements that performs a particular task and then returns to the caller.

Page 9: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

9

Procedure Definition ExampleProcedure begin

Local defined variables (inside the ‘P’ specifications (Procedure)

Calculation specifications begin

PgetMLTSITEL01sitename... P b Export *------------------------------------------------------------------- D pi 51a DR$SiteCode like(esitecode) D Value *------------------------------------------------------------------- * Work Variables Local Declaration *------------------------------------------------------------------- Dd$SiteName ds D d$RecordStatus 1a D d$Name like(esitename) *------------------------------------------------------------------- * File status constants *------------------------------------------------------------------- D FileError c '3' D Locked c '2' D NotFound c '1' D Found c '0' *------------------------------------------------------------------- C Open (e) MLTSITEL01 C If %Error C Eval d$RecordStatus = FileError C Eval d$Name = *Blanks

Page 10: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

10

Procedure DefinitionExample (continued)

Calculation specifications (continued)

Fill return value and pass back to calling program

Ending ‘P’ specification

C Return d$SiteName C Endif C R$SiteCode Chain (e) RMLTSITE C Close MLTSITEL01 C If %Error C Eval d$RecordStatus = Locked C Eval d$Name = *Blanks C Return d$SiteName C Endif C If NOT %Found C Eval d$RecordStatus = NotFound C Eval d$Name = *Blanks C Return d$SiteName C Endif C Eval d$RecordStatus = Found C Eval d$Name = SITENAME C Return d$SiteName *------------------------------------------------------------------- PgetMLTSITEL01sitename... P e

Page 11: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

11

Module Object Example

Control specifications (H Specs)

Input disk file definition

Prototype definitions copybook

Procedure (1) beginProcedure interface

Work variables

H NoMain AlwNull(*UsrCtl) H DatFmt(*iso) H Text(*srcmbrtxt) H Debug(*Yes) /If Defined(Dev) H Option(*NoDebugIO:*SrcStmt) H Optimize(*None) /Else H Option(*NoDebugIO:*NoSrcStmt) H Optimize(*Full) /EndIf FMLTSITEL01IF E K DISK USROPN *------------------------------------------------------------------- D/COPY Qrpglesrc,MLTSITL01H *------------------------------------------------------------------- PgetMLTSITEL01sitecode... P b Export *------------------------------------------------------------------- D pi 1a DR$SiteCode like(esitecode) Value *------------------------------------------------------------------- * Work Variables Local Declaration

Page 12: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

12

Module Object Example (continued)

Work variables (cont.)

C specs

Procedure (1) end

Procedure (2) begin

Procedure interface

Work variables

C specs

Procedure (2) end

Procedure (3) begin

*------------------------------------------------------------------- *------------------------------------------------------------------- C******* Calculation specifications go here *------------------------------------------------------------------- PgetMLTSITEL01sitecode... P e *------------------------------------------------------------------- PgetMLTSITEL01sitename... P b Export *------------------------------------------------------------------- D pi 51a DR$SiteCode like(esitecode) Value *------------------------------------------------------------------- Dd$SiteName ds D d$RecordStatus 1a D d$Name like(esitename) *------------------------------------------------------------------- C****** Calculation specifications go here *------------------------------------------------------------------- PgetMLTSITEL01sitename... P e *------------------------------------------------------------------- PgetMLTSITEL01siteaddr1... P b Export

Page 13: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

13

Control SpecificationsThe control-specification statements, identified by an H in position 6, provide information about generating and running programs.

The keywords listed below are a few that are presently being used within CSSD; these keywords allow the programmer to omit them as compiler options when promoting program source through Turnover or when a programmer simply wishes to compile the program for testing.

BNDDIR('binding-directory-name' {:'binding-directory-name'...}) COPYRIGHT('copyright string') FIXNBR(*{NO}ZONED *{NO}INPUTPACKED) NOMAIN OPTION(*{NO}XREF *{NO}GEN *{NO}SECLVL *{NO}SHOWCPY *{NO}EXPDDS *{NO}EXT *{NO}SHOWSKP) *{NO}SRCSTMT) *{NO}DEBUGIO)

Page 14: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

14

Service ProgramBinder Source Example

Start Program Export (STRPGMEXP) Command

Comments

Exported Procedure names

End Program Export (ENDPGMEXP) Command

Signature can not exceed 16 characters !

/* ************************************************************************** */ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('Vers 13JAug001') /*--------------------------------------------------------------------------- */ /* *MODULE MLTSITL01M MTGPRD4O 06/25/01 07:30:46 */ /*--------------------------------------------------------------------------- */ EXPORT SYMBOL('getMLTSITEL01sitecode') EXPORT SYMBOL('getMLTSITEL01sitename') EXPORT SYMBOL('getMLTSITEL01siteaddr1') EXPORT SYMBOL('getMLTSITEL01siteaddr2') EXPORT SYMBOL('getMLTSITEL01siteaddr3') EXPORT SYMBOL('getMLTSITEL01siteaddr4') EXPORT SYMBOL('getMLTSITEL01sitecity') EXPORT SYMBOL('getMLTSITEL01sitecnty') EXPORT SYMBOL('getMLTSITEL01sitectry') EXPORT SYMBOL('getMLTSITEL01sitepstcd') EXPORT SYMBOL('getMLTSITEL01sitetelno') EXPORT SYMBOL('getMLTSITEL01siteapprid') EXPORT SYMBOL('getMLTSITEL01siteappcd') EXPORT SYMBOL('getMLTSITEL01siteappnm') EXPORT SYMBOL('getMLTSITEL01CompleteAddress') EXPORT SYMBOL('getMLTSITEL01all') ENDPGMEXP

Page 15: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

15

Service Program Binder Source Example

(Making multiple signatures)

Start Program Export (STRPGMEXP) Command

End Program Export (ENDPGMEXP) Command

Unique signatures

Program levels used are *PRV (previous) and *CURRENT (current)

/* ************************************************************************** */ STRPGMEXP PGMLVL(*PRV) SIGNATURE('Vers 13JAug001') /*--------------------------------------------------------------------------- */ /* *MODULE MLTSITL01M MTGPRD4O 06/25/01 07:30:46 */ /*--------------------------------------------------------------------------- */ EXPORT SYMBOL('getMLTSITEL01sitecode') EXPORT SYMBOL('getMLTSITEL01sitename') ENDPGMEXP /* ************************************************************************** */ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('Vers 28Feb2002') /*--------------------------------------------------------------------------- */ /* *MODULE MLTSITL01M MTGPRD4O 02/20/02 10:14:52 */ /*--------------------------------------------------------------------------- */ EXPORT SYMBOL('getMLTSITEL01sitecode') EXPORT SYMBOL('getMLTSITEL01sitename') EXPORT SYMBOL('getMLTSITEL01all') ENDPGMEXP

Page 16: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

16

Binding Directory Example

Work with Binding Directory Entries (WRKBNDDIR) Command

Binding Directory Name

Library name where Binding Directory is located

Service program name

Options to add or remove an object

Types of *SRVPGM or *MODULE are allowed

Page 17: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

17

Bind by ReferenceProcedures

Module

CallingProgram

B ind ingD irectory

ServiceP rogram

Module

P rocedures

Page 18: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

18

Bind by Copy

Module

CallingProgram

Optional

Module

Procedure Procedure Procedure

Page 19: 1 ILE Component Programming Reference Presented By: Ric Slaten, Sr. Software Systems Engineer E-mail: richard_slaten@countrywide.com.

19

ConclusionPrototypes and parameters

Procedure Interfaces

Procedures

Modules

Control Specifications

Service Programs

Binder Source

Binding Directory