
RPGIV
Template Documentation
USER’S GUIDE
Version 2.0 Revised May 19, 2004
ProData Computer Services, Inc
2908 South 160th Street
Omaha, NE 68130
(402) 697-7575
(800) 228-6318
(402) 697-7576 Fax
Software License Agreement........................................................................................................................ 4
Before You Start.................................................................................................................................................... 5
Versions & Releases................................................................................................................................................ 5
How to get the most from templates....................................................................................................... 5
What about my standards?............................................................................................................................ 5
I don’t need all of the templates subroutines all of the time do I?.................................... 5
Installing, Saving, and Deleting Templates....................................................................................... 6
Installing Templates........................................................................................................................................... 6
Saving the Templates........................................................................................................................................... 7
Deleting the Templates....................................................................................................................................... 8
Templates.................................................................................................................................................................... 9
File Maintenance (Change).............................................................................................................................. 10
File Maintenance (Inquiry).............................................................................................................................. 11
File Maintenance (Add)...................................................................................................................................... 12
File Maintenance (Delete)................................................................................................................................ 13
Inquiry (Single Screen)........................................................................................................................................ 14
Inquiry (Multiple Screen).................................................................................................................................. 15
Subfile Selection.................................................................................................................................................... 16
Subfile Selection (Window)............................................................................................................................. 17
Work With Subfile................................................................................................................................................ 18
Work With Subfile (Window).......................................................................................................................... 19
Subfile Maintenance (Multiple Entry Add).......................................................................................... 20
Subfile Maintenance (Multiple Entry Add) Continued…............................................................. 21
Subfile Maintenance (Single Entry Add)................................................................................................ 22
Prompt & Submit Process (Window)........................................................................................................... 23
Simple Report Prompt & Submit.................................................................................................................... 24
Report Prompt & Submit (Window)............................................................................................................. 25
Template Standards......................................................................................................................................... 26
Program Naming Standards......................................................................................................................... 26
Program Headers.................................................................................................................................................. 26
Header/Modification Logs...................................................................................................................................... 26
File Naming Standards...................................................................................................................................... 27
Display File Naming Standards................................................................................................................... 27
Record Formats......................................................................................................................................................... 27
Subfile Formats......................................................................................................................................................... 29
Message Formats...................................................................................................................................................... 31
Subroutine Naming Standards.................................................................................................................... 32
Field Naming Standards................................................................................................................................... 34
Display File Field Naming Conventions.................................................................................................... 34
Template Fields......................................................................................................................................................... 34
User Defined Fields.................................................................................................................................................. 35
RPG Field Naming Conventions....................................................................................................................... 36
Template Fields......................................................................................................................................................... 36
User Defined Fields.................................................................................................................................................. 36
Internal Program Fields.......................................................................................................................................... 37
Parameter Field Naming Conventions................................................................................................................. 38
Subfile Options........................................................................................................................................................ 38
Command Keys......................................................................................................................................................... 39
Subroutines............................................................................................................................................................. 40
$DsplyScn#1 - Display Screen Number 1..................................................................................................... 40
$DsplyScn#1 - Display Screen Number 1 Continuation…................................................................ 41
$LoadScn#1 - Load Screen Number 1............................................................................................................ 42
$LoadScn#1 - Load Screen Number 1 Continuation…....................................................................... 43
$ValidScn#1 - Validate Screen Number 1.................................................................................................. 44
$ValidScn#1 - Validate Screen Number 1 Continuation…............................................................. 45
$UpDateScn#1 - Update Screen Number 1.................................................................................................. 46
$UpDateScn#1 - Update Screen Number 1 Continuation…............................................................. 47
$DeleteScn#1 - Delete Screen Number 1..................................................................................................... 48
$DeleteScn#1 - Delete Screen Number 1 Continuation…................................................................ 49
$InizScn#1 - Initialize Screen Number 1..................................................................................................... 50
$Reset- Reset Subroutine................................................................................................................................... 51
$ExitPgm - Exit ProgramSubroutine.......................................................................................................... 51
$List - List Subroutine......................................................................................................................................... 52
*InzSr - Initialization Routine...................................................................................................................... 53
Program Entry Parameters......................................................................................................................... 54
Program Mode......................................................................................................................................................... 54
Application Program Interfaces............................................................................................................ 54
Send Program Messages (QMHSNDPM)........................................................................................................ 54
Send Program Messages Parameters.................................................................................................................... 54
Send & Remove Program Messages Data Structures........................................................................................ 55
Remove Program Messages (QMHRMVPM)................................................................................................ 55
Remove Program Messages Parameters............................................................................................................... 55
Navigational Flag Processing.................................................................................................................. 56
Navigational Flag Processing Constants............................................................................................ 56
Program Main Line Routine............................................................................................................................. 57
Manipulation Of A Navigational Flag Program............................................................................. 57
Translation Table Constants.................................................................................................................. 58
*ENTRY Parameters Translation................................................................................................................ 58
DSPRCDLCK................................................................................................................................................................ 58
This software
system consists of computer software and documentation. It contains trade
secrets and confidential information which are proprietary to ProData Computer
Servces, Inc. ("ProData"). Its use or disclosure in whole or in part
without the express written permission of ProData is prohibited.
This software system is also an unpublished work protected under the
copyright laws of the United States of America. If this work
becomes published the following notice shall apply:
Copyright@ 1993 ProData Computer Services, Inc.
All Rights Reserved
The templates that are provided will cover many of your interactive programming needs but they may not cover them all. What they do provide is a structured programming base for standardizing your application programs. Templates are like any other tools if you use them for their designed purpose they will serve you well for many years. If you only use them from time to time the full benefits of structured template programming may not be achieved.
The templates are available on the iSeries 400 for operation system V4R2 and above. The templates have been developed utilizing RPG/ILE and CLP/ILE. Be sure you have the correct versions for your machine before you start.
Templates can save a company hundreds of programming hours over the span of a single project. Our suggestion is to start out small by creating a few programs using the templates. Learn how they function and what the differences are between them. Create a template library on your system where the templates can be stored. This will allow your custom templates and the original templates to be stored in one standard library.
If your standards are different than the ones used in the template programs what should you do? Create a library on your system to house the templates in the form they currently exist. Create your template library, and copy the original templates into that library. You can now modify the programs to reflect your shops standards and still get the benefit of using proven templates.
The templates offer many options that you may not use in you current applications. If you don’t want some of the functionality, remove those pieces when you create your program. Our suggestion is to leave the routines in the original programs so that in the future if you can take advantage of these built in functions.
Use the Restore Library (RSTLIB) command to perform an initial install of the Templates. Follow the four-step installation process.
1. Sign on the iSeries/400 system as security officer (QSECOFR)
2. Install the Templates library with the Load Run command. Type LODRUN and press the F4 to prompt the following options: (Note: Replace OPT01 with the name of the device containing the distribution media for Templates)

Use the Save Library (SAVLIB) command to save the Templates. Follow the four-step save process.
1. Sign on the iSeries 400 system as security officer (QSECOFR)
2. Use the Initialize Tape (INZTAP) command to initialize a tape to hold saved version of the Templates.
3. Save the Templates with the SAVLIB Command. Type SAVLIB and press F4 to prompt the following options:
(Note: Replace TAP01 with the name of the device containing the initialized tape)

4. Sign off the AS/400 System.
Use the Delete Library (DLTLIB) command to delete the Templates. Follow the Three-step process.
1. Sign on the AS/400 system as security officer (QSECOFR)
2. Delete the Templates with the DLTLIB command. Type DLTLIB and press F4 to prompt for
the following options:

3. Sign off the AS/400 System.
The template programs that are provided are not just source code that can be copied. The objects are also provided to allow the execution of the templates. This allows the programmer to run the templates in order to determine if it is the desired one to copy. The template menu can be executed by calling the “TEMPLATES” program in the templates library. The template programs can be run by entering the option and pressing enter. The templates menu is displayed below.
Command
CALL TEMPLATES/TEMPLATES

The file maintenance template program can run in 4 separate modes. The operation of the file maintenance program depends on the mode that is passed in on the entry parameters. The available modes are *ADD, *CHANGE, *DELETE, and *INQUIRY. The other parameters that can be passed in are the keys to the file that is being processed. This allows the maintenance program to position to the correct record for any of the available modes. Under the *CHANGE mode the file maintenance program allows the change of the record information contained in the file.
The file maintenance program also allows you to roll through the records in the file. The page up or page down keys allows the user to update several records without exiting out of change mode.
User edits can be placed in the file maintenance program to check the validity or requirements of fields that need to be populated. The coding for the user edits must be done by the programmer and are not contained in the template programs. An example of this is a field such as state code. The programmer would check the state code to ensure its validity.
|
Command Keys |
The command keys available in the File Maintenance program in *CHANGE mode, are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The file maintenance inquiry program runs the same program as the file maintenance change program. The operation of the file maintenance program depends on the mode that is passed on the entry parameters. The available modes are *ADD, *CHANGE, *DELETE, and *INQUIRY. The other parameters that can be passed are the keys to the file being processed. This allows the maintenance program to position to the correct record for any of the available modes. Under the *INQUIRY mode the file maintenance program allows the user to display the file data.
The file maintenance program also allows you to roll through the records in the file. The page up or page down keys allows the user to display several records without exiting out of inquiry mode.
|
Command Keys |
The command keys available in the File Maintenance program in *INQUIRY mode, are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The file maintenance add program runs the same program as the file maintenance change program. The operation of the file maintenance program depends on the mode that is passed on the entry parameters. The available modes are *ADD, *CHANGE, *DELETE, and *INQUIRY. The other parameters that can be passed are the keys to the file being processed. Under the *ADD mode the file maintenance program allows new records to be added to a file. If the record contains more fields than can be displayed on one screen the roll key can be press to displayed remaining fields.
If the roll keys are pressed in the *ADD mode the program will switch to *CHANGE mode and display the previous or next record.
User edits can be placed in the file maintenance program to check the validity or requirements of fields that need to be populated. The code for the user edits must be done by the programmer and are not contained in the template programs. An example of this is a field such as product number. The programmer would verify the validity of the product number to the product master file.
|
Command Keys |
The command keys available in the File Maintenance program in *ADD mode, are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The file maintenance add program runs through the same program as the file maintenance change program. The operation of the file maintenance program depends on the mode that is passed in on the entry parameters. The available modes are *ADD, *CHANGE, *DELETE, and *INQUIRY. The other parameters that can be passed in are the keys to the file that is being processed. This allows the maintenance to be positioned to the correct record at entry time. Under the *DELETE mode the file maintenance program allows the deletion of the record displayed. If the record contains more fields than can be displayed on one screen the roll key can be press to display remaining fields.
When the file maintenance program is running under the delete mode the record will be displayed with a message at the bottom of the screen instructing the user on how to perform the delete. The message that is displayed will appear as follows. “Press enter to delete record. Otherwise, press F12 to nullify.” If the enter key is pressed the record will physically be deleted from the file. If F12 is pressed the program will exit the program.
|
Command Keys |
The command keys available in the File Maintenance program in *DELETE mode, are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The single screen inquiry program is used only for inquiry purposes. The entry parameters to the program are the keys to the record that is being displayed. If the parameters passed into the program are populated the record that corresponds to that key will be displayed. If the parameters are not populated the program will display the error “Record was not found”. If the record being displayed contains more fields than can be displayed on one screen the roll key can be press to displayed the remaining fields.
The single screen inquiry program also allows you to roll through the records in the file. The roll forward or backwards allows the user to inquire several records without exiting the inquiry program.
|
Command Keys |
The command keys available in the Inquiry (Single Screen) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The multiple screen inquiry program is used only for inquiry purposes. The entry parametersto the program are the keys to the record that is being displayed. If the parameters passed into the program are populated the record that corresponds to that key will be displayed. If the parameters are not populated the program will display the error “Record was not found”. If the record being displayed contains more fields than can be displayed on one screen the roll key can be press to display the remaining fields. The difference between the single and multiple screen inquiry is the fact that the second screen is displayed in a separate window. This program functions the same as the single screen inquiry only the appearance is different.
|
Command Keys |
The command keys available in the Inquiry (Multiple Screen) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The subfile selection screen can be used as a prompt screen for returning values to a program or as an informational prompt screen. When the record that is desired is selected, the program will return a value to the calling program that you wish to be returned. For example this program could be used as a prompt from a calling program to select the correct Unique Id. After selection this program will return, to the calling program, the Unique Id in the parameter fields.
|
Program Options |
The options available in the Subfile Selection program are described below.
|
|
1=Select |
This option selects the record you have placed the option beside, then returns to the calling program, any fields you program to be returned. |
|
Command Keys |
The command keys available in the Subfile Selection program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The subfile selection window can be used as a prompt screen for returning values to a program or as an informational prompt screen. When the desired record is selected the program will return a value to the calling program. For example this program could be used as a prompt from a calling program to select the correct Unique Id. After selection this program will return the Unique Id to the calling program.
|
Program Options |
The options available in the Subfile Selection (Window) program are described below.
|
|
1=Select |
This option selects the record you have placed the option beside, then returns to the calling program, any fields you program to be returned. |
|
Command Keys |
The command keys available in the Subfile Selection (Window) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The Work with Subfile program can be used as a prompt screen for returning values to a program or as a interface to the File Maintenance & Inquiry programs.
|
Program Options |
The options available in the Work with Subfile Process program are described below.
|
|
1=Select |
This option selects the record you have placed the option beside, then returns to the calling program, any fields you program to be returned. |
|
2=Change |
The change option will call the File Maintenance program with a parameter of *CHANGE and the key values for the record being processed. |
|
4=Remove |
The remove option will call the File Maintenance program with a parameter of *DELETE and the key values for the record being processed. |
|
5=Display Details |
The display details options will call the File Maintenance program with a parameter of *INQUIRY and the key values for the record being processed. |
|
6=Print Details |
The print details options will call your report program. |
|
Command Keys |
The command keys available in the Work with Subfile Process program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application. |
|
F3=Exit |
The exit command key exits the user from the program. |
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key. |
|
F6=Add |
The add command key call the File Maintenance program with a parameter of *ADD and the key values for the record being processed. |
|
F12=Cancel |
The cancel command key exits the user from the program. |

The subfile selection screen can be used as a prompt screen for returning values to a program or as a interface to the file maintenance and inquiry programs. The only difference between this program and the previously described work with subfile program is that the screen is wrapped with a window border.
|
Program Options |
The options available in the Work with Subfile Process (Window) program are described below.
|
|
1=Select |
This option selects the record you have placed the option beside, then returns to the calling program, any fields you program to be returned. |
|
2=Change |
The change option will call the File Maintenance program with a parameter of *CHANGE and the key values for the record being processed. |
|
4=Remove |
The remove option will call the File Maintenance program with a parameter of *DELETE and the key values for the record being processed. |
|
5=Display Details |
The display details options will call the File Maintenance program with a parameter of *INQUIRY and the key values for the record being processed. |
|
6=Print Details |
The print details options will call your report program. |
|
Command Keys |
The command keys available in the Work with Subfile Process (Window) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application. |
|
F3=Exit |
The exit command key exits the user from the program. |
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key. |
|
F6=Add |
The add command key call the File Maintenance program with a parameter of *ADD and the key values for the record being processed. |
|
F12=Cancel |
The cancel command key exits the user from the program. |

The Subfile Maintenance (Multiple Entry Add) screen is designed to allow maintenance to file records without the need of calling an additional maintenance program. The records can be updated directly from the initial subfile screen. The Subfile Maintenance (Multiple Entry Add) program allows the addition of new records by pressing a F6. The F6 key will display a blank subfile for the new record addition.
|
Program Options |
The options available in the Subfile Maintenance (Multiple Entry Add) program are described below.
|
|
4=Remove |
The remove option will call the File Maintenance program with a parameter of *DELETE and the key values for the record being processed. |
|
Command Keys |
The command keys available in the Subfile Maintenance (Multiple Entry Add) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key refreshes the contents of the screen.
|
|
F6=Add |
The add command key switches the program into a full screen add mode. A blank subfile is displayed, which will allow new record additions.
|
|
F12=Cancel |
The cancel command key will cancel the Add or Delete action being processed. Otherwise, the cancel command key will exits the user from the program. |

The following screen is an example of the Subfile Maintenance (Multiple Entry Add) program allowing additions of new records.

The Subfile Maintenance (Single Entry Add) screen is designed to allow maintenance to file records without the need of calling an additional maintenance program. The records can be updated directly from the initial subfile screen. The difference between the Multiple Entry Add and the Single Entry Add is the procedure used to add additional records. The Single Entry Add allows additions of new records from the initial subfile screen.
|
Program Options |
The options available in the Subfile Maintenance (Single Entry Add) program are described below.
|
|
4=Remove |
The remove option will call the File Maintenance program with a parameter of *DELETE and the key values for the record being processed. |
|
Command Keys |
The command keys available in the Subfile Maintenance (Single Entry Add) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The Prompt & Submit Process (Window) program is an example of a method to prompt users for report or program run information.
|
Command Keys |
The command keys available in the Prompt & Submit Process (Window) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F4=List |
The list command key can be used to prompt and select valid information.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The Simple Report Prompt & Submit program is an example of a method to prompt users for report or program run information.
|
Command Keys |
The command keys available in the Simple Report Prompt & Submit program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F4=List |
The list command key can be used to prompt and select valid information.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The Report Prompt & Submit (Window) program is an example of a method to prompt users for report or program run information. The only difference between this prompt & submit program and the previous is this one is wrapped in a window boarder.
|
Command Keys |
The command keys available in the Report Prompt & Submit (Window) program are described below.
|
|
F1=Help |
The help command key appears only for your help text implementation. The templates provide a simple window that appears when the Help key is pressed. You would have to modify the display file to include any help information you desire for your application.
|
|
F3=Exit |
The exit command key exits the user from the program.
|
|
F4=List |
The list command key can be used to prompt and select valid information.
|
|
F5=Refresh |
The refresh command key clears the screen and allows entry of a new key.
|
|
F12=Cancel |
The cancel command key exits the user from the program. |

The template programs allow you to use any naming standards that you have developed for programs. It is highly recommended that some type of naming standards for programs be followed.
The header section provided in the template programs is used for information purposes only. Contained within the program header is the modification log. The modification log is used to track the genealogy of changes made to a program.
|
H copyright('(C)Copyright ProData Computer Services, Inc. 2002') |
The template programs allow you to use any naming standards that you have developed for files. It is highly recommended that some type of naming standards for files be followed.
The template programs allow you to use any naming standards that you have developed for display file naming standards. It is highly recommended that some type of naming standards for display file naming be followed.
The standard record format for a screen is SCNREC#1. The breakdown of the record format naming convention described below.
|
SCNREC |
The first part of the record format name identifies it as a screen record. |
|
#1 |
Identifies this as screen format number 1. |
If multiple screen formats are used the screen number will
increment by one.
The following is an example of a display file with 3 screen record formats.
SCNREC#1 - Screen record number 1
SCNREC#2 - Screen record number 2
SCNREC#3 - Screen record number 3
The following is an example of the screen record.
|
A*/
----------------------------------------------------------- */ |