IBC233

37
IBC233 Calling Programs Updated Winter 2009

description

IBC233. Calling Programs Updated Winter 2009. Agenda. Calling Programs Lab 11. OPM (static) Call. CALL Parameters: PGM PARM. How it works. When the call statement is executed: Your authority to the program object is checked Do you have access to all the resources required? - PowerPoint PPT Presentation

Transcript of IBC233

Page 1: IBC233

IBC233

Calling Programs

Updated Winter 2009

Page 2: IBC233

Agenda

• Calling Programs

• Lab 11

Page 3: IBC233

OPM (static) Call

• CALL– Parameters:

PGM

PARM

Page 4: IBC233

How it works

• When the call statement is executed:Your authority to the program object is checked

Do you have access to all the resources required?

Gather resources

Program opened

Page 5: IBC233

Passing Parameters in CL (OPM)

Call program1 (‘test’ ‘new’)

then program 1must have a pgm statement that looks like this:

pgm (&parm1 &parm2)

dcl &parm1 *char 10

dcl &parm2 *char 5

Page 6: IBC233

Passing Parameters in CL (OPM)

pgm

dcl &var1 *char 6 value ‘IBC233’

call pgm2 &var1

call pgm(pgm3) parm(&var1)

endpgm

Pgm2 and pgm3 must have a pgm statement similar to this:

pgm parm(&parm1)

Page 7: IBC233

Passing Parameters CL to RPG (OPM)

pgm

call pgm2 (‘RPG’)

endpgm

RPG program must have the fixed format C spec code:

F1 Operation F2 Result

*entry plist

parmvarName

Page 8: IBC233

ILE (dynamic) Call

• CALLPRC

Parameters:

PRC

PARM

RTNVAL

Page 9: IBC233

How it works

• When the application is created, authority to modules is checked and entire application is bound

• When application is called

all resources are allocated

entire application is opened

Page 10: IBC233

Passing Parameters in CL (ILE)

Call appl1 (‘test’ ‘new’)

then the first *module in the application must must have a pgm statement like this:

pgm (&parm1 &parm2)

dcl &parm1 *char 10

dcl &parm2 *char 5

Page 11: IBC233

Passing Parameters in CL (ILE)

pgm

dcl &var1 *char 6 value ‘IBC233’

call pgm2 &var1

callprc (mod3) parm(&var1)

endpgm

mod2 and mod3 must have a pgm statement similar to this:

pgm &parm1

Page 12: IBC233

Passing Parameters CL to RPG (ILE)

pgm

callprc pgm2 (‘RPG’)

endpgm

RPG procedure must have the fixed format C spec code:

F1 Operation F2 Result

*entry plist

parmvarName

Page 13: IBC233

Advantages of OPM

• Don’t have to have all parts of the application done to test.

• Parts of the application can be changed without affecting the entire application

Page 14: IBC233

Disadvantages of OPM

• Integrated Language not supported

Page 15: IBC233

Advantages of ILE

• Integrated Language Support– Best language for the task

• You don’t have to pass all parameters to the program – previous values will be used

Page 16: IBC233

Disadvantages of ILE

• All modules must be in place to test application

• Version Control

Page 17: IBC233

What you need to know for Lab 11

Page 18: IBC233

SQL and RPG

• When defining a table, SQL doesn’t follow the rules that the record format name must be different than the table name.

• RPG needs the two to be different

Page 19: IBC233

Solve the SQL problem – F Spec change

Filename: This is where you type the pf or table name

FT (File Type): I O U C

FD (File Designation): P R S T F

(we use blank or F)

FF (File Format): F E

Record Length: blank or a number

RAT (Record Address Type): A D F K P D Z

( we use blank or K)

DEVICE: Printer, Disk, WorkStn

Page 20: IBC233

Solve the SQL problem – F Spec change

KEYWORDS:

RENAME(fileName:newRecName)

Page 21: IBC233

Defining a Spooled File

Filename: qprint or qsysprt

FT (File Type): O

FD (File Designation): blank

FF (File Format): F

Record Length: 132 (width of the FileName)

RAT (Record Address Type): blank

DEVICE: Printer

KEYWORDS: OFLIND(*INOF)

Page 22: IBC233

Output Specs

• Defines the report layout.

• Type E is the name of the group of record formats

• EXCEPT prints a group of record formats

eg. EXCEPT totals

prints all of the lines belonging to the

group totals

Page 23: IBC233

Logic for an RPG program that creates a report for all of the

records in a file

Page 24: IBC233

Report Logic

Initialize Variables

Page 25: IBC233

Report Logic

Initialize Variables

Print the report heading

Page 26: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Page 27: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

Page 28: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

Page 29: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

Page 30: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

print the detail line

Page 31: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

print the detail line

read the next record

Page 32: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

print the detail line

read the next record

End of loop

Page 33: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

print the detail line

read the next record

End of loop

Print the totals

Page 34: IBC233

Report Logic

Initialize Variables

Print the report heading

Read the first record and check for EOF

Loop until EOF

format the detail line

update the totals

print the detail line

read the next record

End of loop

Print the totals

End of program logic

Page 35: IBC233

Lab 11 – CLLE new commands

Page 36: IBC233

OVRDBF

• Allows you to use a different file instead of the one that is defined by the RPG program

Page 37: IBC233

OVRPRTF

• Changes attributes about the spool file.