Manta alt

YOUR IBM i TRAINING SOURCE

You must allow the browser to execute JavaScript programs if you want to view product information. If your browser is set up to execute JavaScript programs, the problem is that the product ID was incorrect. Use the menu bar above to find the desired product.

Overview

Audio

This course covers how to code and call procedures and subprograms in RPG.

The course first describes the concepts related to procedures and subprograms, including how they share data. Next, the course describes how to code and to call a subprocedure. User-defined functions are covered next, followed by external procedures and subprograms.

You will then see how to make data items and files available to other procedures by making them global. The course also describes how the difference between automatic and static storage determines what happens to data items and files when a procedure is called repeatedly. Included in this topic is a discussion of RPG facilities for keeping such resources in static storage.

Finally, the course covers advanced topics related to procedures and subprograms. You will see how to accept parameters in a main program, how to code a procedure that accepts a variable number of parameters or a variable-length parameter, and how to pass a file to a procedure.

Approximate Study Time: 3 hours

Objectives

After completing this course, you should be able to:

  • Identify the advantages of modularizing an application
  • Identify and describe the methods that can be used to modularize an application
  • Describe the techniques that can be used to allow a calling program or procedure to communicate with a subprogram or called procedure
  • Describe the requirements of a prototyped call
  • Code a prototype definition
  • Code a subprocedure, external procedure, or subprogram
  • Call a subprocedure, external procedure, or subprogram
  • Code a user-defined function
  • Invoke a user-defined function
  • Distinguish between local and global files and data items
  • Export and import data items
  • Distinguish between static and automatic storage
  • Define a local variable that is kept in static storage
  • Describe how an RPG program or procedure controls whether the value of a data item is retained between calls
  • Define a file whose control information is kept in static storage
  • Code a main program that accepts parameters
  • Code a procedure that accepts a variable number of parameters, including no parameters
  • Code the keywords to trim and adjust parameter values
  • Code a procedure that accepts a variable-length parameter
  • Pass a file to a procedure

Topic Outline

Developing a Modular Application

Coding and Using a Procedure

User-Defined Functions

External Procedures and Subprograms

Scope of Definitions

Advanced Parameter Considerations

Audience

This course is intended for programmers new to the RPG programming language. It can also be taken by RPG III programmers who want to learn RPG IV and by RPG IV programmers who want to learn the free-form syntax.

Prerequisites

This course assumes that you are familiar with computer programming concepts. In order to satisfy this prerequisite, you should have some programming experience with another programming language.

This course also assumes that you have a working knowledge of basic IBM i concepts and facilities. You can satisfy this prerequisite by successfully completing the courses in the following series:

In addition, the course also assumes you familiar with IBM i programming concepts and facilities. You can satisfy this prerequisite by successfully completing the courses in the following series:

Finally, the course assumes that you have a basic understanding of free-form RPG programming concepts. You can satisfy this prerequisite by successfully completing the previous courses in this series: