Now let us look at an example of a multiple procedures module. In this ’mini-application’ we are writing a program ARRSRPT to produce a report of all customers whose accounts are in arrears. We will create the basic report as a module, so that it can be bound to other modules, if necessary. There are two main tasks that are required for this module:
We have decided to code each task as a subprocedure. Conceptually, the module will look something like that shown below.
Components of the ARRSRPT Module
Now consider the first subprocedure, InArrears, which is shown in Figure. InArrears is called by the main procedure to determine if the current record is in arrears. TIP When coding sub procedures that use global fields, you may want to establish a naming convention that shows the item to be global. In this example, the uppercase field names indicate DDS fields. Another option would be to prefix ’g_’, or some other string to indicate global scope. If the record is in arrears, the sub procedure returns ’1’ to the main procedure.
Source for Subprocedure InArrears
This shows the main elements that are common to all subprocedures.
For all subprocedures, and also for a main procedure with prototyped entry parameters, you need to define a procedure interface. A procedure interface definition is a repeat of the proto type information within the definition of a procedure. It is used to define the entry parameters for the procedure. The procedure interface definition is also used to ensure that the internal definition of the procedure is consistent with the external definition (the prototype). In the case of InArrears, there are no entry parameters.
Consider next the subprocedure FmtCust, which is shown. FmtCust is called by ARRSRPT to format the relevant fields of a record into an output record for the final report. (The record represents an account that is in arrears.) FmtCust uses global data, and so does not have any input parameters. It formats the data into two output fields: one for the name, and one for the address.
Source for Subprocedure FmtCust
Finally, consider the last subprocedure of this application, FmtAddr. Notice that FmtAddr does not appear in the ARRSRPT module, that is shown. We decided to place FmtAddr inside another module called FMTPROCS. FMTPROCS is a utility module that will contain any conversion procedures that other modules might need to use.
This shows the source of the module FMTPROCS. Since this is a prototyped procedure, it needs the proto type to be available. So that the prototype can be shared, we have placed the prototype into a /COPY file.
Source for module FMTPROCS, containing subprocedure FmtAddr.
FMTPROCS is a NOMAIN module, meaning that it consists only of subprocedures; there is no main procedure. A NOMAIN module compiles faster and requires less storage because there is no cycle code that is created for the module. You specify a NOMAIN module, by coding the NOMAIN keyword on the control specification.
The Entire ARRSRPT Program
The ARRSRPT program consists of two modules: ARRSRPT and FMTPROCS.This shows the different pieces of our mini-application.
The ARRSRPT Application
This shows the source for the entire ARRSRPT module.
ILE RPG Complete Source for ARRSRPT Module
Note the following about ARRSRPT:
Sample output for the program ARRSRPT is shown.
Output for ARRSRPT
This show the DDS source for the files CUSTFILE and CUSTRPT respectively.
DDS for CUSTFILE
DDS for CUSTRPT
IBM - RPG Related Interview Questions
|IBM-ILE Interview Questions||IBM Informix Interview Questions|
|IBM DB2 Interview Questions||SQL Database Interview Questions|
|IBM AIX Interview Questions||SQL Interview Questions|
|AS400 Interview Questions||DB2 SQL Programming Interview Questions|
|IBM Integration Bus Interview Questions||Synopsys Interview Questions|
|Rpgle Interview Questions|
Ibm - Rpg Tutorial
Overview Of The Rpg Iv Programming Language
Rpg Programming In Ile
Program Creation Strategies
Creating An Application Using Multiple Procedures
Using Source Files
Creating A Program With The Crtbndrpg Command
Creating A Program With The Crtrpgmod And Crtpgm
Creating A Service Program
Running A Program
Calling Programs And Procedures
Rpg And The Ebusiness World
Obtaining A Dump
General File Considerations
Accessing Database Files
Accessing Externally Attached Devices
Using Workstn Files
Example Of An Interactive Application
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.