LANSA for iSeries Tutorials

LANSA for iSeries Tutorials V11.0

  • Before you Begin
  • LFA_010 LANSA Application Development
  • LFA_A10 Creating New Fields
  • LFA_A20 Help Text Objectives
  • LFA_A30 Validation Rules
  • LFA_A40 System Variables
  • LFA_B10 Manually Created File Definitions
  • LFA_B20 Create Logical Files/Views
  • LFA_B30 Validation Rules
  • LFA_B40 Virtual Fields
  • LFA_C10 Access Routes
  • LFA_C20 Predetermined Join Fields (PJF)
  • LFA_C30 Referential Integrity
  • LFA_D10 Repository Summary
  • LFA_E10 Creating Processes
  • LFA_E20 Process Characteristics
  • LFA_E30 Creating Functions
  • LFA_E40 Function Editor
  • LFA_E50 Screen Painter
  • LFA_E60 LANSA Debug
  • LFA_F10 A Simple Add Function
  • LFA_F20 Create a Maintenance Function
  • LFA_F30 Create a POPUP Function
  • LFA_F40 Create a Header / Detail Function
  • LFA_F50 Create a Report Function
  • LFA_F60 Create a Trigger Function
  • LFA_G10 RDML Application
  • Appendix A. Application Summary

Edition Date August 30, 2010

© 2010 LANSA

Before You Begin
Prerequisites
How do I use the Tutorials?
Recommendations for the LANSA System Administrator
Repository Tutorials
LFA_010 LANSA Application Development
Step 1. Sign on to the iSeries
Step 2. Start LANSA Using CUA Menus
Step 3. Start LANSA Using the Work with Menus
Step 4. Use LANSA Online Help
Step 5. Using Extended Help
Step 6. Review the Personnel System Case Study and Database Model
Case Study: Personnel System Application
Physical Database Map of Personnel Application
Step 7. Execute an Application Created in LANSA
Step 8. Create a Simple Application in LANSA
Step 9. Review Online LANSA Guides (Optional)
LFA_A10 Creating New Fields
Step 1. Copying Fields
Step 2. Manually Defining Fields
Step 3. Reference Fields
Step 4. System Fields
Step 5. Create a Test Process/Function
Step 6. Test your Field Definitions
Step 7. Changing Your Fields Definitions
Summary
LFA_A20 Help Text
Step 1. Field Level Help Text
Step 2. Using Substitution/Control Values in Help Text
Step 3. Copying Help Text
Step 4. Using Standard Forms
Step 5. Add Help Text For iiiDATE
Summary
LFA_A30 Validation Rules
Step 1. Review Existing Rule for iiiDEPT Field
Step 2. Add a Range of Values Rule to the iiiSECT Field
Step 3. Add Two Rules to the iiiAMOUNT Field
Step 4. Add Rules to the iiiDATE Field
Step 5. Add a List of Values Rule to the iiiDSC, iiiDEPDSC and iiiSECDSC Fields
Step 6. Create a Test File for Your Validation Rules
Step 7. Create and Execute a Test Function
Summary
LFA_A40 System Variables
Step 1. Review an Existing System Variable
Step 2. Create a New System Variable
Step 3. Assign the System Variable as a Default Value
Step 4. Test Your System Variable
Summary
LFA_B10 Manually Created File Definitions
Step 1. Create New File Definition
Step 2. Add Fields to the File
Step 3. Commit Amendments and Make the File Operational
Step 4. Modify the iiiDATE Field Definition
Step 5. Create the Section File
Step 6. Create Functions to Add Data to Files
Step 7. Review the iiiFIL02 Database Attributes
Step 8. File Maintenance Utility
Step 9. Add Data to the New Files
Summary
LFA_B20 Create Logical Files/Views
Step 1. Create a Logical View on Department File iiiFIL02
Step 2. Create a Select/Omit Logical View on Section File iiiFIL03
Step 3. Create a Test Function for the Logical View iiiVEW02
Step 4. Create Test Function for the Logical View iiiVEW03
Step 5. Edit the Prompting Functions for iiiDEPT and iiiSECT Fields
Step 6. Execute Your Test Functions
Summary
LFA_B30 Validation Rules
Step 1. Add a Rule to the iiiFIL02 Department File
Step 2. Add File Lookup Rule to the iiiFIL03 Section File
Step 3. Add More Rules to the iiiFIL03 Section File
Step 4. Test the New Validation Rules
Summary
LFA_B40 Virtual Fields
Step 1. Create a New Field in the LANSA Repository
Step 2. Date Virtual Fields
Step 3. Calculation Virtual Fields
Step 4. Substring Virtual Fields
Step 5. Concatenation
Step 6. Add a File Validation Check
Step 7. Make the iiFIL03 File Operational
Step 8. Create a New Test Function for the iiiFIL03 Section File
Step 9. Test Your Virtual Fields
Step 10. Update the iiiFIL03 File Validation Rules
Summary
LFA_C10 Access Routes
Step 1. Understanding the Database Relationship
Step 2. Create the Access Route from Section File
Step 3. Create the Access Route from Department File
Step 4. Test the Access Route
Summary
LFA_C20 Predetermined Join Fields (PJF)
Step 1. Create New Fields in the LANSA Repository
Step 2. Create File Lookup Predetermined Join Field in the iiiFIL03 Section File
Step 3. Modify the Access Route Characteristics
Step 4. Modify the iiiFULDSC Virtual Field to include the PJF
Step 5. Create Calculated Predetermined Join Field in the iiiFIL02 Department File
Step 6. Test the Predetermined Join Field
Summary
LFA_C30 Referential Integrity
Step 1. Review Rules for the iiiFIL03 Section File
Step 2. Add Rules to the iiiFIL02 Department File
Step 3. Test Your Database Integrity
Summary
LFA_D10 Repository Summary
Step 1. Create New Fields
Step 2. Create the File Definition
Step 3. Create Logical Views
Step 4. Create Access Routes for Employee File
Step 5. Create Referential Integrity Rules for Employee File
Step 6. Create Virtual Fields for Employee File
Step 7. Create Predetermined Join Fields for Employee File
Step 8. Create Validation Rules for Employee File
Step 9. Make Employee File Operational
Step 10. Create Test Functions
Step 11. Test Your New File
Step 12. Create Access Routes for Department & Section Files
Step 13. Create Referential Integrity Rules for Section File
Step 14. Make the File Operational & Test
Summary
RDML Tutorials
LFA_E10 Creating Processes
Step 1. Create a New Process
Step 2. Add Process Help Text by Copying
Step 3. Add a Function to Process iiiPRO03
Step 4. Copy a Process
Step 5. Delete a Process
Summary
LFA_E20 Process Characteristics
Step 1. Function Control Table
Step 2. Attached Processes/Functions
Step 3. Special Entries
Step 4. Review Process Parameters
Step 5. Miscellaneous Details
Summary
LFA_E30 Creating Functions
Step 1. Create a Function By Copying
Step 2. Create a Function Manually
Step 3. Compile and Test Functions
Step 4. Add Function Help Text
LFA_E40 Function Editor
Step 1. Edit the iiiFN11 Function
Step 2. Editor Facilities for Viewing RDML
Step 3. Editing RDML Commands using Prompts
Summary
LFA_E50 Screen Painter
Step 1. Accessing the Screen Painter
Step 2. Painting a Screen
Step 3. Compile the Function and Test
Summary
LFA_E60 LANSA Debug
Step 1. Turn on Debug mode
Step 2. Execute the Function
Step 3. Set Breakpoints and Variables to Display
Step 4. View Variables at Breakpoints
Step 5. Use Edit Services to Change Breakpoints
Summary
LFA_F10 A Simple Add Function
Step 1. Create a Simple Add Function
Step 2. Add More than One Record
Step 3. Function Level Validations
Step 4. Reset the Data in the Entry Panel
Step 5. Hide the iiiAMOUNT Field
Step 6. Compare to iiiFN11
Summary
LFA_F20 Create a Maintenance Function
Step 1. Create a Simple Display Function
Step 2. File Error Checking
Step 3. Allow Data Entry Using a Subroutine
Step 4. Allow Add, Change and Delete
Step 5. Correct the Modes in the Maintenance Function
Step 6. Compare to iiiFN05
LFA_F30 Create a POPUP Function
Step 1. Execute a Popup Prompt
Step 2. Create a New Field in the Repository
Step 3. Create a Simple Popup Function
Step 4. Select Data and Add to the List
Step 5. Exchanging Information
Step 6. Retrieve the Selected Record
Step 7. Loop Until a Selection is Made
Step 8. Compare to iiiFN07
LFA_F40 Create a Header / Detail Function
Step 1. Design Specification
Step 2. Create Your Function
Step 3. Test Your Function
Step 4. Compare Your Function to the Solution
Step 5. Include a Detailed Display Screen (Optional)
Step 6. Allow More Than One Record to be Selected (Optional)
Summary
LFA_F50 Create a Report Function
Step 1. Create a Simple List Style Report Using a Template
Step 2. Manually Create a Reporting Function
Step 3. Add a Header and Footer
Step 4. Keep Statistics and Print
Step 5. Add a Grand Total Line
Step 6. Allow the Report to Execute in Batch (Optional)
Step 7. Paint the Report (Optional)
LFA_F60 Create a Trigger Function
Step 1. Update the Trigger Definition in the Repository
Step 2. Create Trigger Function Using a Template
Step 3. Code the Trigger Logic
Step 4. Test The Trigger Function
Step 5. Remove the Trigger
Summary
LFA_G10 RDML Application
Step 1. Design Specification
Step 2. Create Your Function
Step 3. Test Your Function
Step 4. Compare Your Function to the Solution
Summary
Appendix A. Application Summary


Before You Begin

Introduction

  • The LANSA for iSeries Tutorials have been designed to introduce you to the LANSA Repository and the RDML programming language. These tutorials provide a simple introduction to developing applications with LANSA. They are not a replacement for the instructor-based training workshops in the LANSA Training Program.
  • The tutorials are designed to be completed in sequence. Each tutorial has been divided into exercises. The naming convention for the tutorials and exercises within them are:
  • LFA_x90 where, x is a complete Tutorial, and 90 represents the exercise number within the tutorial.
  • To complete the course, you must be familiar with:
  • the basic operations of an iSeries terminal.
  • the IBM Source Edit Utility (SEU).
  • Familiarity with high-level programming languages and integrated development environments will be an asset but is not essential.

Course Feedback

To create the highest quality training materials possible, please send your comments or feedback to lansatraining@lansa.com

If you have any problems, questions or comments, please direct them to lansatraining@lansa.com allowing up to one week for a response.

Copyright

  • All materials in this course are copyrighted by LANSA. Unauthorized reproduction or distribution of this material, in whole or in part, is prohibited. This course material may not be used to provide public training without the express written permission of LANSA.


Prerequisites

  • You will require access to a fully licensed and installed LANSA for iSeries development environment.
  • You will require a set of LANSA documents, either loaded onto a PC, on a server or directly from the LANSA Windows CD.
  • The tutorials use the repository created for the Personnel System in the DEM partition.


How do I use the Tutorials?

To allow for more than one developer to use the same LANSA for iSeries training environment, all LANSA objects will be prefixed with iii, which represents a unique three character code. You may choose any three characters, such as the initials of your name. For example, if your name is John David Smith and your chosen three characters are JDS, when asked to create a file named iiiFIL01, you will create a file named JDSFIL01.

For simplicity, it is recommended that you do not use task tracking in the training environment.


Recommendations for the LANSA System Administrator

Installing a Training Environment on your iSeries

Following are some recommendations when you are setting up an environment to complete the self-study LANSA training materials.

Option 1: Use the DEM Partition which was installed with LANSA.

When LANSA is first installed, a DEM partition will be created. This partition contains the Personnel System and is ready for use as a training partition. If you have deleted the DEM partition or you have deleted the Personnel System application, you must use option 2.

Option 2: Install the Personnel System into a Partition.

You can create a new partition for training and import the Personnel System into this new partition. To do this, use the Initialize Partition option on the Review System Settings window. Open the Review System Settings window from the Administration menu on the Main System Menu.

User Profiles for Training

You will require a user profile to access your iSeries and the LANSA System. Following are some general recommendations for creating user profiles:

    All training objects are owned by a user profile named PCXUSER. You may wish to create this as your training user profile.

    After you create an OS/400 user profile for the student to use for training, be sure to:

  • use the LANSA Housekeeping options to enable the user profile to access the training partition and to have authority to create fields, files, process/functions.
  • check that correct job description (in particular the library list) is used for the user profile.
  • test that the user profile can access SEU in order to create help text.
  • test the user profile in LANSA by creating a simple test function and compiling it.

Reset the Training Environment

If you wish to reset the training environment so that another developer can use this material, choose one of these options:

1. Assign a different 3 character identifier (iii) to the developer. Make sure the identifier has not already been used.

or

2. Delete all processes/functions, files, fields and system variables created by the last developer, i.e. delete all objects using the iii identifier. By deleting the created objects, the repository is manually reset for the next developer.

Note: Be sure to delete the objects in this order: processes/functions, files, fields, and then system variables. (Recommended if students used iii=DEM.)

or

3. Delete and recreate the training partition.


Repository Tutorials

LFA_010 LANSA Application Development

LFA_A10 Creating New Fields

LFA_A20 Help Text

LFA_A30 Validation Rules

LFA_A40 System Variables

LFA_B10 Manually Created File Definitions

LFA_B20 Create Logical Files/Views

LFA_B30 Validation Rules

LFA_B40 Virtual Fields

LFA_C10 Access Routes

LFA_C20 Predetermined Join Fields (PJF)

LFA_C30 Referential Integrity

LFA_D10 Repository Summary

Note: Edit Code in LANSA for iSeries is the same as Edit Mask in Visual LANSA


LFA_010 LANSA Application Development

Objectives

  • To allow you to become more familiar with the LANSA development environment. The tasks may seem fairly simple, but they are an important part of the foundation skills you will need to complete the tutorials. You will also become familiar with how to use the online help facilities whenever a problem is encountered or more information is needed.
  • To create a simple process menu and a data entry function. Processes and functions will be covered in more detail in a later section of the tutorials. These basic skills are introduced now so that you can test your LANSA repository.
  • To introduce the personnel system application.

To achieve these objectives you must complete the following:

  • Step 1. Sign on to the iSeries
  • Step 2. Start LANSA Using CUA Menus
  • Step 3. Start LANSA Using the Work with Menus
  • Step 4. Use LANSA Online Help
  • Step 5. Using Extended Help
  • Step 6. Review the Personnel System Case Study and Database Model
  • Step 7. Execute an Application Created in LANSA
  • Step 8. Create a Simple Application in LANSA
  • Step 9. Review Online LANSA Guides (Optional)


Step 1. Sign on to the iSeries

LFA_010 LANSA Application Development

1. Sign on to the iSeries using the user profile and password assigned to you for the tutorials. Record this information. Also record the 3 character identifier (iii) you will be using when creating objects in LANSA.

User Profile:

Password:

Identifier (iii):

If you are not familiar with OS/400 operations, take time out now to get an overview.


Step 2. Start LANSA Using CUA Menus

LFA_010 LANSA Application Development

1. From an OS/400 command line, enter the LANSA command, substituting the program library name (and optionally, the Partition name) you will be using for these exercises:

<pgmlib>/LANSA PARTITION(DEM) DEVELOPER(Y)

Once the LANSA command has been entered, you will see the LANSA Main System Menu. You will see a list of options based on your authority within the LANSA system.

3. Select the File Control Menu. You can do this by positioning the cursor on the option line and pressing Enter, or by using the option number in the entry field or on the Command line.

Notice how each option is listed in the menu but you do not see a list of the files in the partition. Press F12 to return to the Main Menu. Press F3 to exit LANSA and return to an OS/400 command line.

Note: We will be using the "Work with" menus for the remainder of the tutorials.


Step 3. Start LANSA Using the Work with Menus

LFA_010 LANSA Application Development

1. From an OS/400 command line, enter the LANSA command but specify DEVELOPER(A) so that the "work with" style menus are displayed.

<pgmlib>/LANSA PARTITION(DEM) DEVELOPER(A)

2. From the Main System Menu (Advanced), select Work with Files. You can do this by positioning the cursor on the option line and pressing Enter or by using the option number.

Notice how the list of files are shown and options appear at the top of the work with screen.

3. Press F23=More Options to view the complete list of options.

4. Press F12=Cancel to return to the LANSA Main System Menu (Advanced).


Step 4. Use LANSA Online Help

LFA_010 LANSA Application Development

1. From the LANSA Main System Menu, press the F1 or Help Key to display the LANSA online help text.

2. Use option 1 to display the help text for Introduction to LANSA. Scroll through and review the help text.

3. Press F23 to display the Contents. Scroll through the list of contents.


Step 5. Using Extended Help

LFA_010 LANSA Application Development

1. Once you have pressed F23 to display the contents help, press F2=Extended Help to display the extended help screen.

2. The top portion of the screen provides a field search capability. Enter the word DATE and press Enter to search the data dictionary for fields with DATE in their description. You will see a number of fields in the repository listed.

3. Press F23 to review the contents again.

4. Press F2 to access extended help again.

5. Using the bottom portion of the screen, search the online guide for topics about ACCESS ROUTE.

6. Press F3 function key to exit help and return to the main menu.


Step 6. Review the Personnel System Case Study and Database Model

LFA_010 LANSA Application Development

1. Review the Case Study: Personnel System Application.

2. Review the Physical Database Map of Personnel Application so that you become familiar with the structure of the application database.


Case Study: Personnel System Application

A business has a very simple Personnel System. The Personnel System allows the company to identify the employees in the company based on the part of the company where the employee works. The Personnel System lists details about the employees and details about their specific skills.

The company has a simple organizational structure. The company is divided into departments such as Administration, Audit, Information Services, Legal, Travel, etc. Each of these departments may have one or more sections such as Accounting, Purchasing, Sales, etc. The Department table (DEPTAB) stores the list of departments. The Section table (SECTAB) is used to store the sections within each department.

The Personnel Master file (PSLMST) stores details about each employee. For example, the employee's name, address, and telephone number are stored in this master file. As each employee works in a section of a department, this information is also stored in the Personnel Master file.

Each employee also has a list of skills. For example, an employee might have Cobol, C and C++ programming skills or management and administration skills. A Skills table (SKLTAB) is used to store the skill codes. A Personnel Skills file (PSLSKL) stores the specific skills of each employee.

The Personnel System is a very simple system. It has 5 files as described above. The physical database layout is shown below.

Historical Note: This system was created in 1987 as one of the very first LANSA demonstration and training systems. The LANSA repository and RDML functions created for this original system have been used on a System 38, AS/400, iSeries, Windows, AIX, HPUX and other platforms. This original system has been left virtually unchanged to show how LANSA has been able to protect your investment in your application systems.


Physical Database Map of Personnel Application

(Includes Virtual and Predetermined Join Fields)

Physical Database Map of Modified Personnel System

This database, including Virtual and Predetermined Join Fields, is created during these tutorials.

Note:

  • The Personnel System is designed to be a very simple example. The shipped demonstration files in the Personnel System do not have a complete set of database referential integrity rules implemented.
  • You will construct three of the five files in the Personnel System. There are some minor differences between the files you will construct and the demonstration files used in the Personnel System. These differences have been included to highlight specific repository features. You will add a complete set of referential integrity rules to your files.


Step 7. Execute an Application Created in LANSA

LFA_010 LANSA Application Development

1. From the Main System Menu, select the option to Work with Processes.

2. Scroll down or use the Position To option and locate the PSLSYS process.

3. Use option 10=Use to execute the PSLSYS Personnel System Main Menu.

4. The Personnel System Main Menu will appear. Perform the following tasks with the application:

5. Execute the Browse/Maintain Employee Skills function.

6. When asked for Employee Number, press F4 to prompt for a list of employees.

7. When the Search for Employee by name appears, enter BROWN.

8. Position the cursor on Veronica Anne Brown and press Enter. Her employee number will appear back in the first panel.

9. Press Enter to review Veronica's skills.

10. Press F12 to exit and return to the Personnel System Main Menu.

11. Execute the Enrol a New Employee function.

12. Display the Employee Number application help text by pressing F1 while the cursor is positioned in that field. Press F3 to exit the application help text.

13. Press Enter to see a list of all the validation rules for a new employee. Remember to scroll through the complete list of messages. Do not add any new data to the file.

14. Press F3 to completely exit the application. You will be returned to the LANSA Main System Menu.


Step 8. Create a Simple Application in LANSA

LFA_010 LANSA Application Development

In this step, you will create a simple data entry application similar to the one you executed in the previous step. You will create a new process (menu) and then you will create a new function (data entry program) by using a LANSA application template.

1. From the Main System Menu, select the option to Work with Processes.

2. Press F6 to create a new process. Enter the following:

Process Name: | iiiPRO01 where iii=your tutorial-assigned ID
Process Description: | Test Process

Use the defaults for all other values.

3. The Work with Processes menu will appear showing your newly-defined process. Use option 2=Review/Change Functions to work with your iiiPRO01 process.

4. From the Work with Functions menu, press F6 to create a new function. Enter the following:

Function Name: | iiiFN01 where iii=your tutorial assigned ID
Function Description: | Enroll a New Employee
Function Type: | 1 (Generate from an Application Template)

5. When the Application Template Selection panel appears, scroll down and select the FRADD01 Flat Screen Data Entry template. The template will ask a series of questions in order to create the RDML code for your function. You are not required to do any coding.

6. Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question.

TEMPLATE QUESTION | ANSWER
Supply a word that describes WHAT this data entry program works with | employee
Do you want this function to be part of an action-bar style process? | N
Enter the name of the PHYSICAL file to be used by this template | PSLMST
Fields to appear on entry panel | Select ALL fields except STARTDTER, TERMDATER and MNTHSAL. (See Note 1 below.)
Fields to work with in the program | Select the EMPNO field. (See Note 2 below.)
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN

Note 1: To remove or not select a field from a number sequence list, simply delete the sequence number beside the field, i.e. leave it blank.

Note 2: To select a field, enter any non-blank character in the selection field.

The RDML code for your function has now been created by LANSA. The required RDML was automatically generated by the template.

7. Press F12 to exit Work with Functions. The status of your RDML functions will be displayed. Simply press Enter or F12 to return to the Work with Processes menu.

8. Use option 7=Compile to compile your iiiPRO01 process and your newly created function. Use the default options on the Compile/Recompile a Process panel. Press Enter to submit the job.

9. Once your function has compiled successfully, test your new function. Be sure to review the help text for some fields and try the prompts for Departments and Sections. These features are automatically provided by the repository.

Note: You may wish to complete Step 9 while waiting for your function to compile.


Step 9. Review Online LANSA Guides (Optional)

LFA_010 LANSA Application Development

If you have access to the online LANSA guides on a PC, you may complete this step.

1. Open the online documentation from:

  • the documentation icon on the PCs desktop
  • from a Visual LANSA product CD.

The directory of all LANSA Online Guides will be displayed so that you can select the guide or group of guides you might wish to view.

2. Click on the Global iSeries Guide to open a window showing all the iSeries-specific LANSA Guides.

3. Select the LANSA iSeries User Guide using either the front page list or from the list in the Content tab.

4. Note the toolbar within the topic window. From this toolbar, you can open the SET (Samples, Examples and Templates) documentation as well as access the lists of other LANSA tutorials.

5. Using the Search tab, you can locate specific information in the all the iSeries-specific guides. For example, you can enter the words "physical file" as the keyword in a search. If you enter two or more words, you must use double quotes:

6. Press the Refresh button to remove the highlighting before you print the page or copy and paste the text into another document.

7. Now search just in the LANSA for iSeries User Guide. To do this, press the Content button in the in-page toolbar. A separate copy of the guide opens.

8. Re- do the "physical file" search. Note that now only found items within the iSeries User Guide are displayed in the list. Double click on topic 3.1 What is a File and What is a File Definition? to display the topic.

9. Switch to the Contents Tab. You will the topic you displayed, 3.1 What is a File and What is a File Definition? highlighted.

10.If you have a printer available, print that page or all pages within the topic.

To do this, press the Print icon in the main toolbar and select the option you desire, to either print the selected topic, or all the subtopics of the selected topic (if there are any) in the resulting dialog box.

Note that when you print a page, it will look slightly different to the online version. The online guide's font is designed for viewing, the printed copies font is designed for reading from paper.

To print all the pages within a main topic or even a whole guide, highlight the main topic or guide's name in the Contents list, select the Print icon, and select the Print the selected heading and all subtopics option in the Print Topics dialog. The printed result will look different to a single printed page. This is because Internet Explorer ignores the Cascading Style Sheet used to control the printing.

Note: To limit the search to just one guide, open a new occurrence of that guide by pressing the Contents button on any page toolbar of the guide you wish to search.

. You will be using the LANSA Guides throughout the training tutorials.

11. Exit the online Guide(s) and the Directory.


LFA_A10 Creating New Fields

Objectives

  • To create new fields in the repository by using three different techniques:
  • copying an existing field
  • manually defining the field
  • using reference fields.
  • To create signed, packed and alphanumeric fields. You will create the following fields:
iiiDEPT | Department Code
iiiSECT | Section Code
iiiDSC | Description
iiiDEPDSC | Department Description
iiiSECDSC | Section Description
iiiDATE | Date
iiiAMOUNT | Amount

To achieve these objectives you must complete the following:

  • Step 1. Copying Fields
  • Step 2. Manually Defining Fields
  • Step 3. Reference Fields
  • Step 4. System Fields
  • Step 5. Create a Test Process/Function
  • Step 6. Test your Field Definitions
  • Step 7. Changing Your Fields Definitions
  • Summary


Step 1. Copying Fields

LFA_A10 Creating New Fields

In this step, you will create two new fields called iiiDEPT and iiiSECT by copying the DEPTMENT and SECTION fields already defined in the repository.

1. From the LANSA Main System Menu, select the option to Work with Fields.

2. From the Work with Fields menu, press F15=SortByDesc to display the list of fields by Description. Press F15 again to display the fields sorted by field name.

3. Press F6=Add/Create to add a new field to the repository.

4. When the Create Field Copy Option panel appears, specify that the field will be created by copying the DEPTMENT field.

5. Notice that almost all of the field characteristics have been copied from the DEPTMENT field. Enter the following field characteristics:

Field Name:

iiiDEPT where iii=your tutorial assigned ID

6. Press Enter to save the field definition. Because you are copying a field, the Copy Field Extended Options prompt appears, select the Copy help text and Copy all rules/triggers options. Select Perform selected copy requests to finish adding the field. You have now created your first field in the repository.

7. Repeat this procedure to create a field called iiiSECT by copying the SECTION field. When the Copy Field Extended Options prompt appears, do NOT copy help text or rules/triggers. Select Go to next screen without copying.

8. Press F12 to exit the Create Field Copy Option panel.

9. From the Work With Fields menu, use option 2=Review to display the iiiDEPT field.

10. Press F21 to change the field as follows:

Label:

 Dept Code

11. Press Enter to save the definition. Notice that the Copy Field Extended Options panel does NOT appear. This panel appears when the field is first copied. Copying does not link the DEPTMENT field to the iiiDEPT field.


Step 2. Manually Defining Fields

LFA_A10 Creating New Fields

In this step, you will manually create three new fields called iiiDSC, iiiDATE and iiiAMOUNT.

1. Press F6 to create a new field in the repository. When the Create Field Copy Option panel appears, simply press Enter.

2. Create an alphanumeric field. Enter the following field characteristics:

Field name: | iiiDSC
Type: | A
Length: | 20
Description: | Description

Remember to use the online help if you have questions about any of these characteristics.

3. Press Enter to save the field definition. Notice that the screen is redisplayed and the defaults are now displayed. The Label, Column Heading, Default Values, and Input Attributes are now set. Check these values and press Enter to save the field definition.

4. Create a signed field to store 8-digit dates. Enter the following field characteristics:

Field name: | iiiDATE
Type: | S
Length: | 8
Description: | Date

5. Save the field definition.

6. Create a packed field to store a dollar amount between –9,999.99 and 9,999.99. Enter the following field characteristics:

Field name: | iiiAMOUNT
Type: | P
Length: | 6
Number of decimals: | 2
Description: | Amount
Edit code: | A
Default value: | 1234.56

7. You will want to set an edit code for this field so that its value will be displayed properly. Review the online help text for Edit code by placing the cursor in the field and pressing Help or F1. The edit code of A will have commas displayed, CR for negative, a decimal point and leading zeros suppressed.

8. Save the field definition.

9. Review the iiiDSC, iiiDATE and iiiAMOUNT fields you have just created. Notice that the input attributes for the fields have been set based on the field type (alphanumeric, signed or packed).


Step 3. Reference Fields

LFA_A10 Creating New Fields

In this step, you will manually create two new fields called iiiDEPDSC and iiiSECDSC. These fields will use the reference field feature of the LANSA Repository so that field characteristics will be inherited from one field to the next. In this example, the reference field will be iiiDSC.

1. Manually create the iiiDEPDSC field by entering the following field characteristics:

Field name: | iiiDEPDSC
Reference Field: | iiiDSC
Description: | Department Description
Label: | Department Desc
Column Heading: | Department Description

2. Press Enter to save the field in the repository. Because you are using a reference field, the Copy Field Extended Options panel will appear to allow you to copy the help text, rules and triggers for this field. Select Go to next screen without copying.

3. Create the iiiSECDSC field by entering the following field characteristics:

Field name: | iiiSECDSC
Reference Field: | iiiDSC
Description: | Section Description
Label: | Section Desc
Column Heading: | Section Description

4. Press Enter to save the field in the repository. Again, when the Copy Field Extended Options panel appears, select Go to next screen without copying.

5. Review the field definition for the iiiDEPDSC and press F21 to change the field definition. Notice that you cannot change the inherited fields from the reference field iiiDSC.

6. Press Enter to save the definition. Notice that the Copy Field Extended Options panel appears again. This panel will always appear when a change is made because the iiiDEPDSC field is linked to the reference field iiiDSC. Select Go to next screen without copying.

7. Review the field definition for iiiDSC and make the following change:

Default value:

'Hello'

8. Review the field definitions for the iiiDEPDSC and iiiSECDSC fields. Notice the new value of the default.

9. Use option 4=Delete and try to delete the iiiDSC field. Type Yes to confirm the delete and press Enter. An error message dialog will appear. Review the extended help for this message.


Step 4. System Fields

LFA_A10 Creating New Fields

This step will highlight how LANSA system fields are used. You will designate iiiDATE as a system field.

1. Review the definition of the iiiDATE field and change the system field value to be YES.

2. Save the change to the field definition.

3. Try to delete the iiiDATE field. Review the validation messages to see why this field cannot be deleted.

4. Review the field definition of any of the STD_xxxxxx fields such as STD_DATE. Notice that all of these standard fields are system fields.


Step 5. Create a Test Process/Function

LFA_A10 Creating New Fields

In this step, you will create a very simple test function using a LANSA template. This function will simply display fields on a screen to allow you to test your field definitions.

1. From the Main System Menu, select the option to Work with Processes.

2. Press function key F6 to create a new process. Enter the following details:

Process Name: | iiiPRO02 where iii=your tutorial assigned ID
Process Description: | Repository Testing

3. The Work with Processes menu will appear showing your newly defined process. Use option 2=Review/Change Functions to work with your iiiPRO02 process.

4. From the Work with Functions menu, press F6 to create a new function. Enter the following details:

Function Name: | iiiFN02 where iii=your tutorial assigned ID
Function Description: | Test Fields
Function Type: | 1 (Generate from an Application Template)

5. When the Application Template Selection panel appears, scroll down and select the FLDTEST Test Fields template. Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question. (Be very careful entering the field names as the function cannot compile if the wrong field name is used.)

TEMPLATE QUESTION | ANSWER
Enter the name of the field to display. | iiiDEPT where iii=your tutorial assigned ID
Enter the name of the field to display. | iiiDEPDSC
Enter the name of the field to display. | iiiSECT
Enter the name of the field to display. | iiiSECDSC
Enter the name of the field to display. | iiiDSC
Enter the name of the field to display. | iiiDATE
Enter the name of the field to display. | iiiAMOUNT
Enter the name of the field to display. | Do not enter a field name

6. Your function is now created and saved. It is ready for compilation. Note: It is NOT necessary to edit the RDML.

7. Press F12 to exit Work with Functions. The status of your RDML functions will be displayed. Simply press Enter or F12 to return to the Work with Processes menu.

8. Use option 7=Compile to compile your iiiPRO02 process and its function. Use the default options on the Compile/Recompile a Process panel, and press Enter to submit the compile.


Step 6. Test your Field Definitions

LFA_A10 Creating New Fields

1. Once your function has compiled successfully, test your field definitions by executing the iiiPRO02 process.

2. Be sure to test the following:

a. Try prompting the Department field. (The prompt will appear but the value will not be returned to your screen as you have created a different field name for DEPTMENT. This will be explained later in the tutorial.)

b. View the help text for the Department field that was copied from DEPTMENT to your iiiDEPT.

c View the help text for the Department Description that is autogenerated by LANSA.

d. Enter some text into the Department Description field. Notice your data is all in uppercase letters.

e. Enter the number 1234 in the Date field and then press Enter. Notice how the number is formatted when it is redisplayed.

f. Enter the number 1234.56- in the Amount field and then press Enter. Notice how the number is formatted when it is redisplayed.

g. Press F12 to terminate the function.

h. Exit from the process menu.

Following are some important things you should have noted:

  • The screen was designed using the information from the repository.
  • Default values are displayed based on the information from the repository.
  • Input and output characteristics are based on the information from the repository.


Step 7. Changing Your Fields Definitions

LFA_A10 Creating New Fields

In this step, you will make some minor changes to the field definitions based on the results of your test.

1. Change the field definition for the iiiDEPDSC and iiiSECDSC fields. Use the LC Input Attribute to allow Lower Case characters to be entered. Also change the default to be *BLANKS. (Tip: Use the reference field.)

2. Review the definition of the iiiDATE field. Change the edit code to 3 so that leading zeros are suppressed and no comma is displayed and no negative sign is displayed.

3. From Work with Processes, use option 7=Compile to compile your iiiPRO02 process. Be sure to select your iiiFN02 test function for compile (lower portion of the screen). It will not be selected automatically since no change was made to the RDML code in the function.

4. Once the function has been recompiled, test your field changes.


Summary

What You Should Know

  • How to define a field by copying, manually defining, and using a reference field.
  • How copying a field is different from using a reference field.
  • What reference fields are and how they are used.
  • How input attributes affect screens.
  • How default values can be used by functions.
  • When you change a default value, you must recompile the function.
  • What system fields are and how they are used.


LFA_A20 Help Text

Objectives

  • To show the different help text features supported by LANSA.
  • To create field level help text for the new fields created in the last exercise.

To achieve these objectives you must complete the following:

  • Step 1. Field Level Help Text
  • Step 2. Using Substitution/Control Values in Help Text
  • Step 3. Copying Help Text
  • Step 4. Using Standard Forms
  • Step 5. Add Help Text For iiiDATE
  • Summary


Step 1. Field Level Help Text

LFA_A20 Help Text

1. From the Work with Fields menu, use option 5=Help text to review the help text for the iiiDEPT field. You will be taken directly into the IBM Source Edit Utility (SEU) editor.

2. If you are unfamiliar with the SEU editor please ask your instructor or mentor before continuing.

3. Scroll down and locate the following text. Insert the line shown in bold text.

$$LANGUAGE=ENG

This is the department code. It is 4 characters long and is

alphanumeric. Generally, if you are asked to specify a department

code and do not know what it is, you can use the prompt key on

the department code. A full list of all the departments will

then be displayed to you in a pop-up window and the one required

can be chosen from the list.

This is a new line of help text.

4. Press F3 to exit the editor. Notice that the Change/create member is automatically set to Y. Press Enter to save the changes made to the help text.

5. Execute your iiiPRO02 process and iiiFN02 function to test your changes to the field help text. Note: You do not need to recompile your process or function.


Step 2. Using Substitution/Control Values in Help Text

LFA_A20 Help Text

1. Edit the help text for your iiiDEPT field again.

2. Add the following lines of text immediately after the line you added in the previous step:

This is help text for the $$FLDNAM field.

%This line is highlighted.}

This word is{underlined.}

3. Exit the editor and save the changes.

4. Test your changes to the field help text by using the test function.


Step 3. Copying Help Text

LFA_A20 Help Text

1. Use the test function to display the help for the iiiDEPDSC and the iiiSECDSC fields. You should see the default help text generated by LANSA.

2. Edit the help text for your iiiDEPDSC field.

3. Since no help text exists for this field, the Create Help Text by Copy panel will appear. Copy the help text from the field DEPTDESC.

4. The SEU editor will appear and will show you the help text for the DEPTDESC field.

5. Press F3 to exit the SEU editor. Be sure to save the help text when exiting the SEU editor by specifying Change/create member as Y.

6. Create some help text for the iiiSECDSC field by copying the help text from SECDESC.

7. Add the following line as the very first line in the help text file:

$$NOAUTO

8. Exit the editor and save the changes.

9. Test your changes to the field help text. Notice the difference between the Department Description and Section Description help text once $$NOAUTO was specified.


Step 4. Using Standard Forms

LFA_A20 Help Text

1. Edit the help text for your iiiAMOUNT field.

2. Since no help text exists for this field, the Create Help Text by Copy dialog will appear. Specify YES to set up the help text using a standard form.

3. When the editor appears, a standard help text form will appear. It should have text something like the following:

$$LANGUAGE=ENG

$$USER

$$TITLE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

%{Field:}

$$FLDNAM $$FLDDES

%{Description:}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

%{Comments:}

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

$$NEWPAGE

$LANGUAGE=FRA

4. Enter some help text in place of all of the xxxxxx characters.

5. Exit the editor and save the changes.

6. Test your changes to the field help text.


Step 5. Add Help Text For iiiDATE

LFA_A20 Help Text

1. Add some help text for the iiiDATE field. You may copy an existing field or use the standard form.

2. Test your help text.


Summary

What You Should Know

  • How to define field level help text by copying or by using a standard form.
  • How help text works with LANSA's Active Repository.
  • What special characters are supported in LANSA help text.
  • What substitution values are supported in LANSA help text.
  • How to use the standard help text form in LANSA.


LFA_A30 Validation Rules

Objectives

  • To show the types of validation rules which can be defined in the repository.
  • To add the following business rules to the repository:
iiiDEPT | Cannot be blank
iiiAMOUNT | Must be in range –5000.00 to 5000.00 and it cannot be 0
iiiDATE | Can be 0, else must be YYYYMMDD format and cannot be in the future
iiiDSC | Cannot be blank
iiiDEPDSC | Cannot be blank
iiiSECDSC | Cannot be blank
iiiSECT | Must be in range 00 to 99.

To achieve these objectives you must complete the following:

  • Step 1. Review Existing Rule for iiiDEPT Field
  • Step 2. Add a Range of Values Rule to the iiiSECT Field
  • Step 3. Add Two Rules to the iiiAMOUNT Field
  • Step 4. Add Rules to the iiiDATE Field
  • Step 5. Add a List of Values Rule to the iiiDSC, iiiDEPDSC and iiiSECDSC Fields
  • Step 6. Create a Test File for Your Validation Rules
  • Step 7. Create and Execute a Test Function
  • Summary


Step 1. Review Existing Rule for iiiDEPT Field

LFA_A30 Validation Rules

1. From the Work with Fields menu, use option 12=Rules/Triggers to review the validation rule for the iiiDEPT field. When you created the iiiDEPT field, you should have copied the validation rules from the DEPTMENT field.

2. The Select Rule/Trigger panel will be displayed. (Note: If the rule does not appear, then you did not copy it when you created the field. To correct this problem, review the iiiDEPT field and add DEPTMENT as the reference field. When you save the changes, you will be able to copy the validation rules from DEPTMENT to iiiDEPT.)

3. Select the existing rule Department cannot be blank by entering a non-blank character and pressing Enter.

4. Each different type of validation rule has its own set of parameters. The simple logic check requires that you enter the boolean expression for the rule. Position the cursor to the appropriate area of the panel and review the online help for information about specifying conditions for the simple logic check.

5. Press Enter to exit the rule.


Step 2. Add a Range of Values Rule to the iiiSECT Field

LFA_A30 Validation Rules

1. Review the rules and triggers for the iiiSECT field. There should be no rules for this field. (Note: If any rules were copied by accident, delete the rules from the field.)

2. Press F6 to create a new rule. A prompt will appear to allow you to select the type of rule to be added to the iiiSECT field.

3. Select the Range of Values rule. Define the rule as follows:

User description of rule | Valid range for section code.
Check if field is in range | '01' to '99'
If field is in range of values above | NEXT
Else field is NOT in the range of values above | ERROR
Specify error message... Or text | Section must be in range of 01 to 99.

4. Press Enter to save the new rule.


Step 3. Add Two Rules to the iiiAMOUNT Field

LFA_A30 Validation Rules

Think about how you can create a rule where iiiAMOUNT must be in range –5000.00 to 5000.00 and it cannot be 0. One option would be to create a range check from ‑5000.00 to ‑0.01 and 0.01 to 5000.00. The better option is to create two rules. In this step, you will create two validation checks on the iiiAMOUNT field. The first rule will be a simple logic check and the second will be a range check. Using two rules will highlight how the validation hierarchy is performed.

1. Work with the rules/triggers for the iiiAMOUNT field. There should be no rules for this field.

2. Add an Evaluate an Expression for Rule to the iiiAMOUNT field as follows:

User description of rule | Amount cannot be zero.
Check the field by evaluating the truth of … | #iiiAMOUNT *EQ 0
If the condition above is found to be true | ERROR
Else the condition above is found to be false | NEXT
Specify error message... Or text | Amount cannot be zero.

3. The Order to Process is important when you create more than one rule.

4. Press Enter to save the new rule information.

5. Now that the first rule has been successfully added, you will create the next rule.

6. Add a Range of Values Rule to the iiiAMOUNT field as follows:

Order to process | 20
User description of rule | Amount must be –5000 to 5000.
Check if field is in range | -5000 to 5000
If field is in range of values above | NEXT
Else field is NOT in the range of values above | ERROR
Specify error message... Or text | Amount must be in range –5000 to 5000.

7. Press Enter to save the new rule information. You will now see two rules listed. The rules will be processed in the order listed. This order is very important as it relates to the NEXT and ERROR instructions specified on the Validation Rules dialog.


Step 4. Add Rules to the iiiDATE Field

LFA_A30 Validation Rules

Think about how you can create a rule where iiiDATE can be left as 0, but if a value is entered, it must be in a valid format (YYYYMMDD) and not in the future. Obviously, you will need more than one rule. In this step, you will create two validation checks on the iiiDATE field. The first rule will be a simple logic check and the second rule will be a date check. You will use the *ACCEPT instruction to control how the rules are processed.

1. Review the rules and triggers for the iiiDATE field. There should be no rules for this field.

2. Add an Evaluate Expression for Rule to the iiiDATE field as follows:

User description of rule | Accept if date is 0.
Check the field by evaluating the truth of … | #iiiDATE *EQ 0
If the condition above is found to be true | ACCEPT
Else the condition above is found to be false | NEXT

The If /Else conditions are very important. When the amount is 0, no error occurs and no further validations should be performed, i.e. ACCEPT this condition and do no more checks. When the amount is not 0, you will want to perform the NEXT check.

3. Press Enter to save the new rule information.

4. Next, add a Date Format/Range Rule to the iiiDATE field as follows.

User description of rule | Date must be past & YYYYMMDD.
Validate date in format | YYYYMMDD
Number of days allowed into the past | 9999999
Number of days allowed into the future | 0
If field passes date format/range rule | NEXT
Else field fails date format/range rule | ERROR

5. Press Enter to save the new rule information.


Step 5. Add a List of Values Rule to the iiiDSC, iiiDEPDSC and iiiSECDSC Fields

LFA_A30 Validation Rules

This step will highlight how reference fields and validation rules work together. You will see that validation rules are NOT automatically transferred from the reference field but can be copied when you edit the field definition.

1. Review the rules and triggers for the iiiDSC field. There should be no rules for this field.

2. Add a List of Values Rule to the iiiDSC field as follows.

User description of rule | Description cannot be blank
Check if field is in list | *BLANKS
If field is in the list specified above | ERROR
Else field is NOT in the list specified above | NEXT

3. Press Enter to save the new rule information.

4. Review the Rules/Triggers for the iiiSECDSC field. Notice that there are no rules. Also notice that the iiiSECDSC field references iiiDSC.

5. Review the field definition of the iiiSECDSC field. Press F21 to allow changes to be made to the field definition. Press Enter to save the change. When the Copy Field Extended Options panel appears, select the Copy all rules/triggers option and then select Perform selected copy requests to finish updating the field.

6. Now go back and review the Rules/Triggers for the iiiSECDSC field. The rule has been copied from the reference field.

7. Use this same technique to update rules for the iiiDEPDSC field.


Step 6. Create a Test File for Your Validation Rules

LFA_A30 Validation Rules

In order to test the field validation rules in the repository, you will need a test function and a test or dummy file. In this step, you will create a dummy file. This set of steps only provides basic file information so that you may test your fields. File definitions will be explained in more detail in an upcoming exercise.

1. From the LANSA Main System Menu, select the option to Work with Files.

2. Press F6 to create a new file. Enter the following details:

File name: | iiiFIL01
Description: | Test File

3. Press Enter to create the file definition. The new file iiiFIL01 will now appear in the file list.

4. Use option 2=Review/Change Fields to add the fields to the iiiFIL01 file. The Display Fields in the File Definition panel will appear.

5. Press F6 to add the following fields to the file:

Seq | Name | Primary Key Order
 | iiiDEPT | 1
 | iiiDEPDSC |
 | iiiSECT |
 | iiiSECDSC |
 | iiiDSC |
 | iiiDATE |
 | iiiAMOUNT |

6. Press Enter to save the file definition.

7. Use option 7=Make Operational to create the iiFIL01 file and its I/O Module.

8. When the Commit Amendments to File prompt appears, be sure to specify YES to save the changes made to iiFIL01.

9. When the Create/Recreate a File from its Definition panel appears, simply press Enter to submit the job using its defaults.


Step 7. Create and Execute a Test Function

LFA_A30 Validation Rules

1. Check that your iiiFIL01 test file has been made operational, i.e. the job completed successfully. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. From the Work with Processes menu, use option 2=Review/Change Functions to add a new function to your test process, iiiPRO02.

3. From the Work with Functions menu, press F6 to create a new function. Enter the following details:

Function Name: | iiiFN03 where iii=your tutorial assigned ID
Function Description: | Test Fields Rules
Function Type: | 1 (Generate from an Application Template)

4. Select the FRADD01 Flat Screen Data Entry template and answer the template questions as shown below.

TEMPLATE QUESTION | ANSWER
Supply a word that describes WHAT this data entry program works with | test
Do you want this function to be part of an action-bar style process? | N
Enter the name of the PHYSICAL file to be used by this template | iiiFIL01
Fields to appear on entry panel | Select ALL fields.
Fields to work with in the program | Do not select any fields.
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN

Your function is now created and saved. It is ready for compilation. Note: It is NOT necessary to edit the RDML.

5. Exit the Work with Function menus.

6. Compile your process iiiPRO02.

7. Once the compile has completed successfully, execute your function.

8. Be sure to test each of the rules you added to the fields. Include the following in your tests.

iiiDEPT | is blank, is not blank
iiiAMOUNT | is 0, is –5001, is 5001, is 1
iiiDATE | is 0, is invalid format 12311989, is valid format 19891231, is in future 20101231, is today's date, is tomorrow's date
iiiDSC | is blank, is not blank
iiiDEPDSC | is blank, is not blank
iiiSECDSC | is blank, is not blank
iiiSECT | is 00, is 99, is blank, is XX

Compare the error message displayed for the iiiDSC field to the error message displayed for the iiiSECT field. Which is more helpful to the user? Remember that the iiiDSC field uses a generic message from the message file since you did not add a specific message.

9. If you have made any errors in your validation rules, go back and correct the rules in the repository. Once you have corrected a rule, you will need to make the file operational again. You do not need to recompile your test function.


Summary

What You Should Know

  • What are the different types of validation rules.
  • How is the validation rule hierarchy performed.
  • How is *NEXT, *ERROR and *ACCEPT used.
  • What are the choices when displaying error messages.
  • How the same business rules can be defined by using different types of validation checks.


LFA_A40 System Variables

Objectives

  • To highlight some of the system variables in LANSA.
  • To create a new system variable which will automatically keep track of the next available number for determining section codes. Note: This is just an example to highlight how system variables work.

To achieve these objectives you must complete the following:

  • Step 1. Review an Existing System Variable
  • Step 2. Create a New System Variable
  • Step 3. Assign the System Variable as a Default Value
  • Step 4. Test Your System Variable
  • Summary


Step 1. Review an Existing System Variable

LFA_A40 System Variables

1. From the LANSA Main System Menu, select the option to Work with System Variables. The list displayed is NOT partition dependent. It is a system-level list; i.e. it will be the same in each partition.

2. Press F15=SortByDesc to display the list of variables by Description. Press F15 again to display the variables sorted by name.

3. Scroll down or use the Position to in order to locate the *DATE system variable. If you use the Position to, check whether the list is sorted by description or name. If sorted by name, you must position to *DATE. If sorted by description, you must position to NUMERIC DATE.

4. Use option 2=Review/Change to display the system variable. Do NOT change the system variable.

5. Press F12 to return to the Work with System Variables menu.


Step 2. Create a New System Variable

LFA_A40 System Variables

1. Use the online help text search facilities (extended help) and review System Variables. Scroll to the end of the help to review the information on the *AUTOALPnnxxxxxxxxx system variable. This is a special "data area" system variable layout which is used in conjunction with a LANSA shipped evaluation program M@SYSNUM. The system variable retrieves a number nn (in this case 2) long from data area xxxxxxxxxx, increments it, updates the data area and returns it as an alphanumeric value.

2. Press F6 to create a new system variable as follows:

System Variable Name: | *AUTOALP02iiiNUM
Description: | Next Available Number
Method of Derivation: | DYNAMIC
Data Type: | ALPHA
Length: | 2
Name: | M@SYSNUM
Type: | 3GL

3. Press Enter to save the system variable definition.

4. Press F12 to exit the Add System Variable Definition panel.

Note: The data area and the value of the system variable will automatically be defined when the system variable is first accessed.


Step 3. Assign the System Variable as a Default Value

LFA_A40 System Variables

1. Review the field definition for the iiiSECT field and make the following change:

Default value:

 *AUTOALP02iiiNUM

By using the system variable, the default value will actually change each time the field is used.

2. Review the field definitions for iiiDSC and iiiDATE. Note the other LANSA system variables being used as the default values for these fields.


Step 4. Test Your System Variable

LFA_A40 System Variables

1. To test your change to the default value of the iiiSECT field, you must force the recompile of your test process/function iiiPRO02/iiiFN02 or iiiPRO02/iiiFN03.

2. Once your function has compiled successfully, execute your function to test your system variable.

  • Notice the default value which appears when the screen first displays. This value was assigned by accessing the system variable and determining the next available number. The system variable was automatically created (stores the value 0) and set to 1 when it was first accessed.
  • Exit the function and then execute the function again. Note the new default value. The value has been incremented by one. The system variable automatically updates to the next available number each time it is accessed (by your function or any other function in any partition in the system).
  • If 50 people were executing your test function, each person would see a different default value. After the 50th access, you would see value 51. Remember that the variable is systemwide and not program or partition specific.
  • When the section code reaches 99, it will be reset to 1.

Important Note: This is just an example.
You would not use a system variable to generate the section code because section codes depend on the department. For example department ABC will have section 01 and department XYZ will have a section 01. You would normally use this type of system variable to generate unique numbers such as a next available customer number or the next available order number.


Summary

What You Should Know

  • How to create a system variable.
  • What are some of the special system variables supported by LANSA.
  • What are some of the shipped system variables.
  • Where can LANSA system variables be used.


LFA_B10 Manually Created File Definitions

Objectives

  • To create the Department File and the Section File. (These files are very similar to the ones used in the Personnel System.)
  • To review the database file attributes which can be defined in the LANSA Repository.
  • The file definitions will be as follows:

To achieve these objectives you must complete the following:

  • Step 1. Create New File Definition
  • Step 2. Add Fields to the File
  • Step 3. Commit Amendments and Make the File Operational
  • Step 4. Modify the iiiDATE Field Definition
  • Step 5. Create the Section File
  • Step 6. Create Functions to Add Data to Files
  • Step 7. Review the iiiFIL02 Database Attributes
  • Step 8. File Maintenance Utility
  • Step 9. Add Data to the New Files
  • Summary


Step 1. Create New File Definition

LFA_B10 Manually Created File Definitions

1. From the LANSA Main System Menu, select the option to Work with Files.

2. From the Work with Files menu, press F6 to create a new file definition as follows:

Name: | iiiFIL02 where iii=your tutorial assigned ID
Description: | Department
Maintained by: | LANSA

3. Press Enter to save the file definition. The new file iiiFIL02 will now appear in the file list.


Step 2. Add Fields to the File

LFA_B10 Manually Created File Definitions

1. Use option 2=Review/Change Fields to add the fields to the iiiFIL02Department file. The Display Fields in the File Definition panel will appear.

2. Press F6 to add the following fields to the file:

Seq | Name | Primary Key Order
 | iiiDEPT | 1
 | iiiDEPDSC |

Sequence does not have to be entered. It will default to the order of the fields.

3. Press Enter to add the fields to the file.

4. Press Enter to save the file definition.


Step 3. Commit Amendments and Make the File Operational

LFA_B10 Manually Created File Definitions

1. From the Work with Files menu, use option 7=Make Operational to make the iiiFIL02 file operational. This will create the physical file and I/O Module for the file.

2. When the Commit Amendments to File prompt appears, be sure to specify YES to save the changes made to iiFIL02.

When you have finished working with a file (i.e. attempt to work with another file, make it operational, or exit the file menu), LANSA will ask if you wish to commit the amendments to the file. Answer YES to save your changes. If you answer NO, all work will be discarded.

3. When the Create/Recreate a File from its Definition panel appears, simply press Enter to submit the job using its defaults.


Step 4. Modify the iiiDATE Field Definition

LFA_B10 Manually Created File Definitions

In this step, you will update the definition of the iiiDATE field so that it uses a date stamping output attribute. The date stamping (CYDX) will automatically update the iiiDATE field with the date that the field was created and it will also automatically update the iiiDATE field with the date that the field was last updated.

1. Review the field definition of the iiiDATE field and make the following change:

Output attributes list:

 CYDX

2. Review the Output Attribute help text, in particular the information about the CYDX attribute.

3. Press Enter to save the field definition.

4. Delete the two field level validation rules on the iiiDATE field (created in exercise LFA_A30) as these rules are no longer required.


Step 5. Create the Section File

LFA_B10 Manually Created File Definitions

1. Create a new file definition as follows:

Name: | iiiFIL03 where iii=your tutorial assigned ID
Description: | Section
Maintained by: | LANSA

2. Add the fields to the Section file as follows:

Seq | Name | Primary Key Order
 | iiiDEPT | 1
 | iiiSECT | 2
 | iiiSECDSC |
 | SECADDR1 |
 | SECADDR2 |
 | SECADDR3 |
 | SECPCODE |
 | SECPHBUS |
 | iiiDATE |
 | iiiAMOUNT |

Note: Fields SECADDR1, SECADDR2, SECADDR3, SECPCODE and SECPHBUS already exist in the repository. You did not create these fields.

TIP: A fast way to add multiple fields to a file is to enter a partial name to search the LANSA Repository. By entering SEC and then pressing Enter, you can get a list of fields starting with the characters SEC. Then you can select multiple fields to be added to the file definition.

3. Commit the file amendments and make the file operational.


Step 6. Create Functions to Add Data to Files

LFA_B10 Manually Created File Definitions

1. Check if the make operational job for the iiiFIL02 file has completed successfully.

2. Add a new function to your iiiPRO02 process. Enter the following details:

Function Name: | iiiFN04 where iii=your tutorial assigned ID
Function Description: | Department Maintenance
Function Type: | 1

3. Select the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question.

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL02
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Select the iiiDEPT field.
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | department
Fields to appear on the Add Panel | Select ALL fields.

4. Check if the make operational job for the iiiFIL03Section file has completed successfully.

5. Add a new function to your iiiPRO02 process. Enter the following details:

Function Name: | iiiFN05 where iii=your tutorial assigned ID
Function Description: | Section Maintenance
Function Type: | 1

6. Use the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL03
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Check the iiiDEPT and iiiSECT fields.
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | section
Fields to appear on the Add Panel | Select ALL fields.

7. Compile the two newly defined functions.


Step 7. Review the iiiFIL02 Database Attributes

LFA_B10 Manually Created File Definitions

1. From the Work with Files menu, use option 27=Data Base Attributes to review the Data Base Attributes of the iiiFIL02 Department file.

2. Press Help to review the online help text for various topics such as the CRTPF & CHGPF Parameters.

3. Do NOT update any of the database attributes. Exit the Data Base Attributes panel.


Step 8. File Maintenance Utility

LFA_B10 Manually Created File Definitions

1. From the Work with Files menu, use option 31=FMU to view the iiiFIL02 Department file.

2. On the Select Maintenance File to Use panel, select the iiiFIL02 Department file from the list of physical and logical files for accessing the file.

3. On the Select Type of Maintenance panel, select Add new record(s) to the file.

4. On the resulting Add File Record display, do NOT enter any data. Press Enter to see the error messages provided by the LANSA Object Access Module.

5. Enter a Department Code of iii and enter your name for the Department Description. Press Enter to add the record.

6. Press F12 to exit the Add File Record panel.

7. On the Select Maintenance File to Use panel, select the iiiFIL02 Department file.

8. On the Select Type of Maintenance panel, select Display, change or delete individual file record(s).

9. Enter a Department Code of iii to display the record you added.

10. Press F22 and type YES to delete the record.

11. Press F3 to exit to the Main Menu.


Step 9. Add Data to the New Files

LFA_B10 Manually Created File Definitions

1. Once the compile has completed successfully, execute your iiiFN04 Department Maintenance test function.

a. Add the following data to the file:

Department | Description
ADM | Administration
LGL | Legal
MRK | Marketing
TRN | Company Training
TRVL | Business Travel

You should notice that the field level validation rules created for the iiiDEPT and iiiDEPDSC fields are enforced.

2. Execute your iiiFN05 Section Maintenance test function.

a. Add the following data to your file. For the fields such as Address, Phone, etc. which are not listed in the table below, simply leave the fields blank.

Dept. | Section | Description | Date | Amount
ADM | 01 | Internal | 0 | 1234.56
ADM | 02 | Purchasing | 0 | 1234.56-
ADM | 03 | Accounting | 0 | 1234.56
ADM | 04 | Sales | 0 | 1234.56-
LGL | 01 | Contract | 0 | 1234.56
LGL | 02 | Foreign | 0 | 1234.56-
LGL | 03 | Domestic | 0 | 1234.56
TRN | 01 | Internal | 0 | 1234.56
TRN | 02 | External | 0 | 1234.56-
TRVL | 01 | Local | 0 | 1234.56
TRVL | 02 | International | 0 | 1234.56

b. Try adding some data for a department ZZZZ which does not exist. Do you think that the user should be able to do this, (i.e. add section data when the department does not exist) ?

  • You should notice that the field level validation rules you created are enforced.
  • Notice how the field Output Attributes impact the data and validation rules. In this exercise, you modified the iiiDATE field with an output attribute of CYDX which means that the field would store the creation date and update date. If you display any of the records you created, you will notice that the field has a value of the current date.
  • If you enter a date (valid or invalid) into the field, it will be ignored and replaced by the output attribute. The update is performed by the OAM or I/O Module.
  • Fields that use these types of stamping output attributes should not be used on the data entry panel. The fields are updated automatically so the user does not have to enter a value.


Summary

What You Should Know

  • How to define a file in the LANSA repository.
  • How to add fields to a file definition.
  • How to specify file keys.
  • What committing file amendments does.
  • How to compile a file to make it operational.
  • What is created when the file is compiled.
  • What are some of the attributes which can be specified for database files.
  • How to access attributes for physical and logical files.


LFA_B20 Create Logical Files/Views

Objectives

  • To add a logical view over iiiFIL02 Department which sorts the file by Department Description.
  • To add a logical view over iiiFIL03 Section selecting records where iiiAMOUNT is greater than 0.

To achieve these objectives you must complete the following:

  • Step 1. Create a Logical View on Department File iiiFIL02
  • Step 2. Create a Select/Omit Logical View on Section File iiiFIL03
  • Step 3. Create a Test Function for the Logical View iiiVEW02
  • Step 4. Create Test Function for the Logical View iiiVEW03
  • Step 5. Edit the Prompting Functions for iiiDEPT and iiiSECT Fields
  • Step 6. Execute Your Test Functions
  • Summary


Step 1. Create a Logical View on Department File iiiFIL02

LFA_B20 Create Logical Files/Views

To begin, you will create a very simple logical file over the iiiFIL02Department file created in the last exercise. This logical view will sort all records in the file by the iiiDEPDSCDepartmentDescription field.

1. From the Work with Files menu, use option 19=Logicals to review the logical files for the iiiFIL02 Department file.

2. Press F6 to create a new logical view. Enter the following details:

Logical view name: | iiiVEW02 where iii=your tutorial assigned ID
Description of logical view: | Department by Description
Key Field Details (Field): | iiiDEPDSC

3. Press Enter to save the logical view definition.

4. Press Enter to return to the Work with Files menu.

5. Commit the amendments to iiiFIL02 and make the file operational.


Step 2. Create a Select/Omit Logical View on Section File iiiFIL03

LFA_B20 Create Logical Files/Views

In this step, you will create a logical view which will select records from the iiiFIL03Section file where the amount is greater than 0.

1. Work with the iiiFIL03Section file and add a logical view to the iiiFIL03Section file as follows:

Logical view name: | iiiVEW03 where iii=your tutorial assigned ID
Description of logical view: | Section Amount Greater Than 0
Key Field Details (Field) : | iiiDEPTiiiSECT

2. Enter the following information for the Select/Omit Criteria:

SELECT/OMIT | Field | Operation(s)
SELECT | iiiAMOUNT | COMP(GT 0)

3. Press Enter to save the logical view definition

4. Commit the amendments to iiiFIL03 and make the file operational.


Step 3. Create a Test Function for the Logical View iiiVEW02

LFA_B20 Create Logical Files/Views

In order to test the new logical view over the Department file, you will create a prompt function which accesses this file using the logical view. A prompt function reads the file and displays a list of records for the user. The prompt function will also have a search capability which will take advantage of your logical view.

1. Check that file iiiFIL02 Department was successfully made operational.

2. Add a new function to your iiiPRO02 process. Enter the following details:

Function Name: | iiiFN06 where iii=your tutorial assigned ID
Function Description: | Department Prompt
Function Type: | 1

3. Use the FRPOP02 Pop Up Prompter (Requests Search Values) template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Enter a 1 to 4 character prefix. | iii (where iii=tutorial assigned ID)
Enter title of the POP UP window. | Department
Specify the name of the file to be displayed. | iiiVEW02
Fields to be displayed? Fields to be returned? | Select iiiDEPT and iiiDEPDSC. Select the iiiDEPT field.


Step 4. Create Test Function for the Logical View iiiVEW03

LFA_B20 Create Logical Files/Views

In order to test the new logical view over the Section file, you will create another prompt function which accesses this file using the new logical view. This prompt function will simply provide a full file listing of all selected records using the logical view.

1. Add a new function to your iiiPRO02 process. Enter the following details:

Function Name: | iiiFN07 where iii=your tutorial assigned ID
Function Description: | Section Prompt
Function Type: | 1

2. Use the FRPOP01 Pop Up Prompter (Full File) template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Enter title of the POP UP window. | Section Amount > 0
Specify the name of the file to be displayed. | iiiVEW03
Fields to be displayed? Fields to be returned? | Select iiiDEPT,iiiSECT, iiiSECDSC, iiiAMOUNT fields. Select iiiDEPT,iiSECT fields.

3. Compile the process and its functions.


Step 5. Edit the Prompting Functions for iiiDEPT and iiiSECT Fields

LFA_B20 Create Logical Files/Views

1. From the Work with Fields menu, review the iiiDEPT field and make the following change:

Prompting process/function:

 *DIRECT / iiiFN06

2. Review the iiiSECT field and make the following change:

Prompting process/function:

 *DIRECT / iiiFN07


Step 6. Execute Your Test Functions

LFA_B20 Create Logical Files/Views

1. Check that the files were made operational and that your test functions have compiled successfully. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. Execute your iiiFN04 Department Maintenance function.

a. Prompt on the Department Code field. Your iiiFN06 Department Prompt function will be displayed and allows you to search by the department description.

b. Leave the Department Description blank and press Enter. The departments should be listed in order of their descriptions.

c. Select a Department. The value should be returned to your iiiFN04 Maintenance function.

d. Exit the function.

3. Execute your iiiFN05 Section Maintenance function.

a. Prompt on the Department Code field. Again, your iiiFN06 Department Prompt function will be displayed. The repository links the prompt to any panel with the Department Code field.

b. Prompt on the Section Code field. Your iiiFN07 Section Prompt function will be displayed. Only the sections which have amounts greater than 0 should be listed.

c. Change the Amount for department/section ADM/02 to be 1234.56.

d. Execute your prompt again. You should now see this record in the list.


Summary

What You Should Know

  • How to create a new logical file.
  • How to define the keys to the logical file.
  • How to add select/omit criteria to a logical file.


LFA_B30 Validation Rules

Objectives

  • To highlight the difference between field and file level validation rules and the hierarchy which exists between these rules.
  • To introduce the Code File/Table Lookup rule.
  • To reinforce how the OAM relates to validation rules in the repository and how the OAM relates to your functions.

To achieve these objectives you must complete the following:

  • Step 1. Add a Rule to the iiiFIL02 Department File
  • Step 2. Add File Lookup Rule to the iiiFIL03 Section File
  • Step 3. Add More Rules to the iiiFIL03 Section File
  • Step 4. Test the New Validation Rules
  • Summary


Step 1. Add a Rule to the iiiFIL02 Department File

LFA_B30 Validation Rules

In this step, you will create a rule which says that the Department Code must be in the range A to ZZZZ so that the Department Code in iiiFIL02 will start with an alphabetic character.

1. From the Work with Files menu, use option 12=Rules/Triggers to review the rules for the iiiFIL02 Department file.

2. Select the iiiDEPT field to view a list of all existing validation rules. You should see a field level validation rule that iiiDEPT cannot be blank.

3. Select the existing rule. The field level validation rule will be displayed but you cannot update the rule. You can only update field level rules from the LANSA Field Control window.

4. Press F6 to add a new validation rule at the file level.

5. Add a Range of Values rule to iiiDEPT field as follows:

User description of rule | Dept must be A to ZZZZ
Check if field is in range | 'A' to 'ZZZZ'
If field is in range of values above | NEXT
Else field is NOT in the range of values above | ERROR
Specify error message... Or text | Department Code must be in range A to ZZZZ.

6. Press Enter to save the new rule information.

7. Commit the amendments to iiiFIL02 and make the file operational. Your test functions do not need to be recompiled.


Step 2. Add File Lookup Rule to the iiiFIL03 Section File

LFA_B30 Validation Rules

In this step, you will add a Code File/Table Lookup rule. This rule allows you to validate data in one file based on data in another file. (More information about the Code File/Table Lookup rule is presented in the Referential Integrity exercise.)

1. Review the Rules/Triggers for the iiiFIL03 Section file

2. Add a File Entry Lookup rule to the iiiDEPT field as follows:

User description of rule | Dept must exist in iiiFIL02.
Lookup code table / file | iiiFIL02
Using key field(s) | iiiDEPT
If a "key match" is found in code file | NEXT
Else a "key match" is NOT found in code file | ERROR
Specify error message... Or text | Department Code must exist in iiiFIL02.

3. Press Enter to save the new rule information.


Step 3. Add More Rules to the iiiFIL03 Section File

LFA_B30 Validation Rules

In this step, you will also add a simple logic check to highlight how rules can use more than one field in a file. You will add a new rule which involves more than one field. You will add a rule which checks that the SECADDR2 field has a value when the SECADDR1 field has a value.

1. Using file iiiFIL03Section, select the SECADDR2 field to define new rules/triggers for the field. There should be no rules defined for the SECADDR2 field.

2. Add an Evaluate an Expression rule to the SECADDR2 field as follows:

User description of rule | Not blank if Address entered.
Use rule when performing | ADDUSE CHGUSE
Check the field by evaluating the truth of … | (#SECADDR1 *NE *BLANKS) *AND (#SECADDR2 *EQ *BLANKS)
If the condition above is found to be true | ERROR
Else the condition above is found to be false | NEXT
Specify error message... Or text | Suburb/Town required if street entered.

Changing the Use rule when performing to be ADDUSE CHGUSE means that the rule will only be checked when the SECADDR2 field is specifically being added or changed. For example, if a function is just updating the Section Description, the rules for SECADDR2 are not checked.

3. Press Enter to save the new rule information.

4. Commit the amendments to iiiFIL03 and make the file operational.


Step 4. Test the New Validation Rules

LFA_B30 Validation Rules

1. Check that the iiiFIL02 file was successfully made operational. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. Execute your iiiFN04 Department Maintenance function.

a. Try to add a blank department code. Note the validation messages which appear and their order. You will see both the field and file level messages.

b. Try to add a department code of 1111. Note the error messages stating Dept must be in range A to ZZZZ.

3. Check that the iiiFIL03 file was successfully made operational.

4. Execute the iiiFN05 Section Maintenance function.

a. Try to add a section with a department code of 1111. You should see an error message that Department Code must exist in iiiFIL02, BUT there is no error stating Dept must be in range A to ZZZZ. Because this second rule was only added to the iiiDEPT field in file iiiFIL02, the rule does not apply to the iiiDEPT field in file iiiFIL03.

b. Try to add a new section for a department which does not exist.

c. Enter data into the SECADDR1Street but do not enter data into SECADDR2 Suburb/Town. Notice that only SECADDR2 is highlighted in error even though the check involves more than one field.


Summary

What You Should Know

  • Where validation rules are performed in the LANSA architecture.
  • Which rules are supported at the file level.
  • At which level should you specify most of your rules.
  • What is the difference between defining a rule at the field level and the file level.
  • In what order are the field and file validation rules performed.
  • What does a code file/table lookup rule do.


LFA_B40 Virtual Fields

Objectives

  • To highlight the different types of virtual fields which can be defined using the LANSA Repository.
  • To add virtual fields to the Section file which will be used to:
  • format the date as DD/MM/YY on input from the file
  • calculate a tax amount using iiiAMOUNT on input from the file
  • create local and area code numbers from telephone number on input & output from file
  • concatenate the department and section codes into one field on input from the file.

To achieve these objectives you must complete the following:

  • Step 1. Create a New Field in the LANSA Repository
  • Step 2. Date Virtual Fields
  • Step 3. Calculation Virtual Fields
  • Step 4. Substring Virtual Fields
  • Step 5. Concatenation
  • Step 6. Add a File Validation Check
  • Step 7. Make the iiFIL03 File Operational
  • Step 8. Create a New Test Function for the iiiFIL03 Section File
  • Step 9. Test Your Virtual Fields
  • Step 10. Update the iiiFIL03 File Validation Rules
  • Summary


Step 1. Create a New Field in the LANSA Repository

LFA_B40 Virtual Fields

1. Create a new field in the LANSA Repository called iiiDATEDM. This field will be used to display the contents of iiiDATE as a 6-digit date in DD/MM/YY format. Enter the following characteristics for the field:

Field name: | iiiDATEDM
Type: | S
Length: | 6
Description: | Date (D/M/Y)
Edit Code: | Y
Default: | *ZERO


Step 2. Date Virtual Fields

LFA_B40 Virtual Fields

1. From the Work with Files menu, use option 23=Virtual Fields to review the virtual fields for the iiiFIL03 Section file.

2. Press F6 and add the iiiDATEDM field to the list of virtual fields.

3. Press Enter to save the field as part of the file definition.

4. Press F21=Change to review/change the extended definitions. Select the iiiDATEDM field and press Enter.

5. When the Virtual Field Extended Definitions prompt appears, select the Date conversion option and then select Perform selected request.

6. Using the Date conversion of field panel, set up the virtual field as follows:

Derive "virtual" field on input from file | YES
Setup "real" field before output to file | No
"Real" field to convert from | iiiDATE
"Virtual" field date format | DDMMYY
"Real" field date format | YYYYMMDD

7. Press Enter to add the virtual definition. Note: LANSA will ask you to verify the real field to convert from because there is more than one field which matches your entry. Simply select the iiiDATE field.


Step 3. Calculation Virtual Fields

LFA_B40 Virtual Fields

1. Create a new field in the LANSA Repository called iiiTAXAMT. This field will be used as a calculated virtual field based on the iiiAMOUNT field. The iiiTAXAMT will be calculated as 10% of the iiiAMOUNT field.

2. Enter the following characteristics for the field:

Field name: | iiiTAXAMT
Type: | P
Length: | 6
Decimals: | 2
Description: | Tax Amount
Edit Code: | A
Default: | *ZERO

3. Add the iiiTAXAMT as a virtual field in the iiiFIL03 Section file. Change the extended field definition and select the Mathematical calculations option from the Virtual Field Extended Definition prompt.

4. Using the Mathematical calculation of a field panel, set up the virtual field as follows:

Derive "virtual" field on input from file | YES
Value 1 | iiiAMOUNT
Operation | *
Value 2 | 0.10
Result | iiiTAXAMT

5. Press Enter to add the virtual field definition to the file.


Step 4. Substring Virtual Fields

LFA_B40 Virtual Fields

1. Create two new fields in the LANSA Repository, iiiAREAC and iiiLOCAL. These two fields will be used as substring virtual fields based on the SECPHBUSBusiness Phone Number field. The iiiAREAC will represent the telephone area code and will be the first 7 characters of the SECPHBUS field. The iiiLOCAL will represent the local telephone number and will be the last 8 characters of the SECPHBUS field.

2. Enter the following characteristics for the fields:

Field name: | iiiAREAC
Type: | A
Length: | 7
Description: | Area Code
Default: | *BLANK

Field name: | iiiLOCAL
Type: | A
Length: | 8
Description: | Local Phone
Default: | *BLANK

3. Add the iiiAREAC and iiiLOCAL fields as virtual fields in the iiiFIL03 Section file. Change the extended field definition and select the Substring option.

4. Using the Substring of a field panel, set up the virtual field as follows:

Derive "virtual" field on input from file | YES
Setup "real" field before output to file | YES
Field to substring from | SECPHBUS
Start position | 1

The telephone area code will be the first 7 digits (1 to 7) of the SECPHBUS field and starts at position 1.

5. Press Enter to add the virtual field definition.

6. Now add iiiLOCAL as another substring virtual field in the iiiFIL03 Section file using the procedure described above. Remember that the local telephone number will be the last 8 digits (8 to 15) of the SECPHBUS field and will start at position 8.


Step 5. Concatenation

LFA_B40 Virtual Fields

1. Create a new field in the LANSA Repository called iiiFULDSC. This field will be derived by concatenating the iiiDEPT and iiiSECT fields into one field. (Note: In an upcoming exercise, you will modify this virtual field to include the department description which is why the field is defined as 27 characters long.) Enter the following characteristics for the field:

Field name: | iiiFULDSC
Type: | Alphanumeric
Length: | 27
Description: | Full Dept/Sect
Input Attribute: | LC
Default: | *BLANK

2. Add iiiFULDSC as a virtual field in the iiiFIL03 Section file. Change the extended field definition and select the Concatenation option.

3. Using the Concatenation of a field(s) panel, set up the virtual field as follows:

Derive "virtual" field on input from file | YES
Setup "real" field before output to file | NO
Using fields | iiiDEPTiiiSECT

4. Press Enter to add the virtual field definition.


Step 6. Add a File Validation Check

LFA_B40 Virtual Fields

In order to highlight how virtual fields and validation rules interact, you will add a new validation rule to the SECPHBUS field. Remember that this field has two virtual fields based on it, iiiAREAC and iiiLOCAL. These fields are used for both input and output.

1. Add a file level Range of Values rule to the SECPHBUS field. Notice that all of the virtual fields now appear when displaying a list of fields in the file. Validation rules can be added to the virtual fields in the file.

2. Check if the SECPHBUS field is in the range A to ZZZZZZZZZZZZZZZ. If the field is in this range, an error should occur since phone numbers should start with a numeric value.


Step 7. Make the iiFIL03 File Operational

LFA_B40 Virtual Fields

1. Commit the amendments to iiiFIL03 and make the file operational. Notice that the make operational job only recreates the I/O Module. The physical file is not recreated.


Step 8. Create a New Test Function for the iiiFIL03 Section File

LFA_B40 Virtual Fields

1. Check that the iiiFIL03 file was successfully made operational. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. Work with the functions in your iiiPRO02 process and delete your iiiFN05 Section Maintenance function.

3. Create a new iiiFN05Section Maintenance function using the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL03
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Select the iiiDEPT, iiiSECT, iiiDATE, iiiTAXAMT, iiiDATEDM, iiiFULDSC fields.
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | section
Fields to appear on the Add Panel | Select ALL fields except for the following: SECPHBUS, iiiDATE, iiiDATEDM, iiiTAXAMT, iiiFULDSC.

Note: To unselect a field, simply delete the sequence number. (Notice that the fields which are not updated or used on the add panel are the fields which do not require user input. These fields are simply used for output purposes.)

4. Compile your newly created function.


Step 9. Test Your Virtual Fields

LFA_B40 Virtual Fields

1. Execute your iiiFN05 Section Maintenance function.

a. Display the Department/Section ADM/01. Notice the date, string and calculation virtual fields.

b. Change the record by entering a value of 1234567890 into the SECPHBUS field.

c. Display the Department/Section ADM/01. Notice that the SECPHBUS does not have a value because you did not enter the data in the virtual fields iiiAREAC and iiiLOCAL. The value of the SECPHBUS is based on iiiAREAC and iiiLOCAL, so your entry was ignored.

d. Change the record again. This time enter a value of A into the iiiAREAC field. An error will occur and the SECPHBUS field will be highlighted. When you display the messages, you will see that the validation error refers to the SECPHBUS field. To correct this problem, the validation rules should be placed on the iiiAREAC and iiiLOCAL virtual fields.

e. Enter some valid data in the iiiAREAC and iiiLOCAL fields.

f. Display the changes.


Step 10. Update the iiiFIL03 File Validation Rules

LFA_B40 Virtual Fields

1. Delete the file level Range of Values rule on the SECPHBUS field.

2. Add the appropriate file level Range of Values rules to the iiiAREAC and iiiLOCAL fields.

3. Commit amendments and make the file operational.

4. Test your changes.


Summary

What You Should Know

  • What are the four types of extended definition virtual fields.
  • What is the purpose of the Derive virtual field on input from file and Setup virtual field before output to file options.
  • When should validation rules be added to virtual fields.


LFA_C10 Access Routes

Objectives

  • To create an access route to define a relationship between the department and section files.

To achieve these objectives you must complete the following:

  • Step 1. Understanding the Database Relationship
  • Step 2. Create the Access Route from Section File
  • Step 3. Create the Access Route from Department File
  • Step 4. Test the Access Route
  • Summary


Step 1. Understanding the Database Relationship

LFA_C10 Access Routes

Before creating the access route, you must clearly understand the relationship between the Department (iiiFIL02) and the Section (iiiFIL03) files you have created. The company structure is a hierarchy of departments and sections.

Each department is divided into sections. A section cannot exist without the department. Stated another way, the department is the parent or owner of its sections. For a given department, such as Administration, there can be many sections (Accounting, Purchasing, Sales, etc.).

To summarize:

  • Department (iiiFIL02) is the parent of the Section (iiiFIL03).
  • A Department may have many different Sections.
  • A Section belongs to just one Department.


Step 2. Create the Access Route from Section File

LFA_C10 Access Routes

1. From the Work with Files menu, use option 21=Access Routes with the iiiFIL03 Section file.

2. Press F6 to add an access route from the Section file to the Department file.

Access route name | iiiFIL0301
Access route description | Section belongs to a department.
File to be accessed by this route | iiiFIL02
Maximum number of records expected | 1
Action to take if no records found | IGNORE
Key fields/values for access | iiiDEPT

3. Press Enter to add the access route definition.

4. Commit amendments and make the iiiFIL03Section file operational


Step 3. Create the Access Route from Department File

LFA_C10 Access Routes

1. Work with the iiiFIL02 Department file and add an access route to the Section file as follows:

Access route name | iiiFIL0201
Access route description | Department contains many sections.
File to be accessed by this route | iiiFIL03
Maximum number of records expected | 999
Action to take if no records found | IGNORE
Key fields/values for access | iiiDEPT

2. Press Enter to add the access route definition. After the access route is added, you will notice a warning message. This message is displayed because you have specified a partial key to the iiiFIL03 Section file. The full key is based on iiiDEPT and iiiSECT. The partial key is correct. You may ignore the warning.

3. Commit amendments and make the iiiFIL02Department file operational.


Step 4. Test the Access Route

LFA_C10 Access Routes

In this step, you will delete your existing Section Maintenance function and recreate it using a template to test whether the access routes have been properly defined.

1. Check that the iiiFIL03Section file was successfully made operational.

2. Work with your test process iiiPRO02.

3. Delete your iiiFN05 Section Maintenance function.

4. Create a new iiiFN05Section Maintenance using the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below:

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL03
Select related file(s) to be used | Select the iiiFIL02 Department file.
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Select the iiiDEPT, iiiSECT, iiiDATE, iiiDATEDM, iiiTAXAMT, iiiFULDSC fields..
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Additional fields to appear | Select the iiiDEPDSC field.
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | section
Fields to appear on the Add Panel | Select ALL fields except for the following: SECPHBUS, iiiDATE, iiiDATEDM, iiiTAXAMT, iiiFULDSC.

Because of the access route you defined from the Section file to the Department file, the template knows that there is information in a related file. It allows the developer to link to that related file and include fields from that file in the function. When you first executed this template using iiiFIL03, there were no access routes defined so you were not able to access fields from another file. Also, the template allows you to select additional fields to appear based on the related file.

5. Compile and test your function.

a. Display an existing record.

  • Notice that the Department Description now appears on the display. The function used the information in the access route to generate additional code to extract this information. Remember, the access route is just information. It is not used when the function executes. The access route information was used when the template generated the code for the function.


Summary

What You Should Know

  • What an access route is.
  • Why access routes are important to the database.
  • How an access route is defined.
  • How LANSA uses access routes.
  • Where access routes are used.


LFA_C20 Predetermined Join Fields (PJF)

Objectives

  • To add a file lookup Predetermined Join Field to the Section File based on a field in the Department file.
  • To add calculated Predetermined Join Fields to the Department File based on the fields in the Section file.
  • To use a Predetermined Join Field to define another Virtual Field to help understand how these fields can be used together.

To achieve these objectives you must complete the following:

  • Step 1. Create a New Field in the LANSA Repository
  • Step 2. Create File Lookup Predetermined Join Field in the iiiFIL03 Section File
  • Step 3. Modify the Access Route Characteristics
  • Step 4. Modify the iiiFULDSC Virtual Field to include the PJF
  • Step 5. Create Calculated Predetermined Join Field in the iiiFIL02 Department File
  • Step 6. Test the Predetermined Join Field
  • Summary


Step 1. Create New Fields in the LANSA Repository

LFA_C20 Predetermined Join Fields (PJF)

1. You will create six new fields in the LANSA Repository called iiiTOTPJF, iiiMAXPJF, iiiMINPJF, iiiAVEPJF, iiiCNTPJF and iiiDEPPJF. The iiiTOTPJF, iiiMAXPJF, iiiMINPJF, iiiCNTPJF and iiiAVEPJF fields will store the total, maximum, minimum, count and average values based on the iiiAMOUNT field. The iiiDEPPJF will be the Department Description based on the iiiDEPDSC field.

2. Using the most efficient means possible, create the following fields with the basic characteristics listed below. Assign appropriate values for edit codes, input attributes, default values, etc.

Field name: | iiiDEPPJF
Description: | Department
Type: | A
Length: | 20

Field name: | iiiTOTPJF
Description: | Total Amount
Type: | P
Length: | 11
Decimals: | 2
Edit code: | A

Field name: | iiiMAXPJF
Description: | Maximum Amount
Type: | P
Length: | 6
Decimals: | 2
Edit code: | A

Field name: | iiiMINPJF
Description: | Minimum Amount
Type: | P
Length: | 6
Decimals: | 2
Edit Code | A

Field name: | iiiAVEPJF
Description: | Average Amount
Type: | P
Length: | 6
Decimals: | 2
Edit code: | A

Field name: | iiiCNTPJF
Description: | Section Count
Type: | S
Length: | 3
Decimals: | 0
Edit code | 3


Step 2. Create File Lookup Predetermined Join Field in the iiiFIL03 Section File

LFA_C20 Predetermined Join Fields (PJF)

In this step, you will add the Department Description field from the iiiFIL02 Department file to the iiiFIL03 Section file using field iiiDEPPJF.

1. From the Work with Files menu, use option 23=Virtual Fields to review the virtual fields in the iiiFIL03 Section file. Make note of the fields listed. Exit this option.

2. From the Work with File menu, use option 21=Access Routes to review the access routes for the iiiFIL03 Section file.

3. Use option 23=Predetermined Join Fields to review the iiiFIL0301 access route to the Department file.

4. Select the iiiDEPDSC field as the source field. This is the field which will be used to derive the new virtual field in the Section file.

5. When the Nominate Join Fields prompt appears, press F21 to change the entries.

a. Enter the iiiDEPPJF in the Look Up field. The iiiDEPDSC field from the Department file will now be mapped to your iiiDEPPJF in the Section file.

b. Press Enter to save the definition.

6. From the Work with Files menu, use option 23=Virtual Fields to review the virtual fields in the Section file. You should now see the iiiDEPPJF field listed. It is important to remember that you do NOT add or work with PJFs from this option.


Step 3. Modify the Access Route Characteristics

LFA_C20 Predetermined Join Fields (PJF)

1. Work with the access routes for the iiiFIL03 Section file.

2. Select the iiiFIL0301 access route to the Department file.

3. Change the PJF before/after virtual fld derivation to B for "before". This value will mean that the PJF fields can be used by virtual fields because they are derived before the virtual fields are derived.

4. Set the Keep Last value to be 10 so that the last 10 departments are saved in memory. In order to improve performance, these memory values will be checked before accessing the file again.


Step 4. Modify the iiiFULDSC Virtual Field to include the PJF

LFA_C20 Predetermined Join Fields (PJF)

In the virtual field exercise, you created a virtual field named iiiFULDSC which was the concatenation of the department and section codes. Now that you have added the PJF iiiDEPPJF, it can be added to the iiiFULDSC virtual field. This step will highlight the importance of deriving the PJF before the virtual fields.

1. Work with the virtual fields for the iiiFIL03 Section file.

2. Press F21 to change the virtual fields. (Notice that the iiiDEPPJF field is displayed in the list of virtual fields but it cannot be updated. You must update the PJF definition from the access route definition.) Select the iiiFULDSC field's Extended Definition.

3. Press F21 to change the iiiFULDSC field definition. Add the iiiDEPPJF field to the list of fields to be concatenated to form the iiiFULDSC virtual field. iiiFULDSC should now be created by concatenating iiiDEPT, iiiSECT and iiiDEPPJF.

4. Commit amendments and make the iiiFIL03Section file operational


Step 5. Create Calculated Predetermined Join Field in the iiiFIL02 Department File

LFA_C20 Predetermined Join Fields (PJF)

1. From the Work with File menu, use option 21=Access Routes to review the access routes for the iiiFIL02 Department file.

2. Use option 23=Predetermined Join Fields to review the iiiFIL0201 access route to the Section file.

3. Select the iiiAMOUNT field from the list.

4. When the Nominate Join Fields prompt appears, press F21 to change the entries. Enter the appropriate field as shown in the table below:

Type | Field
Total | iiiTOTPJF
Maximum | iiiMAXPJF
Minimum | iiiMINPJF
Average | iiiAVEPJF
Count | iiiCNTPJF

5. Press Enter once you have added all five Predetermined Join Fields.

6. Review the Virtual Fields defined for the iiiFIL02Department file. Notice that the Predetermined Join Fields appear but they cannot be maintained from the virtual field dialog.

7. Commit amendments and make the iiiFIL02Department file operational


Step 6. Test the Predetermined Join Field

LFA_C20 Predetermined Join Fields (PJF)

In this step, you will delete your existing Section Maintenance function and then recreate it so that the new Predetermined Join Field can be included in the function.

1. Check that the iiiFIL03 file was successfully made operational. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. Work with your test process iiiPRO02 and delete your iiiFN05 Section Maintenance function.

3. Create a new iiiFN05Section Maintenance using the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL03
Related files | Do not select any files.
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Select the iiiDEPT, iiiSECT, iiiDATE, iiiTAXAMT, iiiDATEDM, iiiFULDSC, iiiDEPPJF fields.
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | section
Fields to appear on the Add Panel | Select ALL fields except for the following: SECPHBUS, iiiDATE, iiiDATEDM, iiiTAXAMT, iiiFULDSC, iiiDEPPJF.

Note: To unselect a field, simply delete the sequence number. (Notice that the fields which are not updated or used on the add panel are the fields which do not require user input or are simply used for output purposes.)

4. Delete your iiiFN04 Department Maintenance function.

5. Create a new iiiFN04Department Maintenance using the FRMNT01 Flat Screen Maintenance template. Answer the template questions as shown in the table below.

TEMPLATE QUESTION | ANSWER
Name of the primary file | iiiFIL02
Do you want this function to be part of an action-bar style process? | N
Fields to appear on display | Select ALL fields.
Is the change function key to be enabled? | Y
Fields that cannot be updated | Select ALL fields except iiiDEPDSC.
Is the add function key to be enabled? | Y
Is the delete function key to be enabled? | Y
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN
Supply a word that describes WHAT this maintenance program works with | department
Fields to appear on the Add Panel | Select only iiiDEPT and iiiDEPDSC.

6. Compile your two new functions.

7. Execute the iiiFN05 Section Maintenance function to test your changes.

a. Display a record. You should see the Department Description displayed and you should also see the Department Description as part of the iiiFULDSC virtual field.

8. Execute the iiiFN04 Department Maintenance function to test your changes.

a. Display a department. You should see the calculated Predetermined Join Fields displayed.


Summary

What You Should Know

  • What a Predetermined Join Field is.
  • What operations can be performed by a PJF.
  • How to add and maintain PJF definitions.


LFA_C30 Referential Integrity

Objectives

  • To create rules in the repository to ensure that proper referential integrity is defined for the Department and Section files in the Personnel System Application database.

To achieve these objectives you must complete the following:

  • Step 1. Review Rules for the iiiFIL03 Section File
  • Step 2. Add Rules to the iiiFIL02 Department File
  • Step 3. Test Your Database Integrity
  • Summary


Step 1. Review Rules for the iiiFIL03 Section File

LFA_C30 Referential Integrity

1. Review the Rules/Triggers for the iiiDEPT field in the iiiFIL03Section file.

2. Display the details of the Code File /Table Lookup check created in an earlier exercise. This rule is used to define the referential integrity from the Section file to the Department file. It makes sure that any Department Code used in the Section file already exists in the Department file.


Step 2. Add Rules to the iiiFIL02 Department File

LFA_C30 Referential Integrity

1. Create a new File Entry Lookup rule for the iiiDEPT field in the iiiFIL02Department file.

2. Enter a Description of Cannot delete if section exists.

3. Specify the appropriate information to complete the rule. This rule specifies that you cannot delete a record if the department code exists in the Section file. Notice that this rule should ONLY be used when deleting a record from the file. Remember to update the If/Else conditions. An error exists when the department code is found in the Section file.

4. Commit amendments and make the iiiFIL02Department file operational.


Step 3. Test Your Database Integrity

LFA_C30 Referential Integrity

1. Check that the iiiFIL02 file was successfully made operational. Depending upon the iSeries compile times, you may wish to complete this step at the start of the next exercise.

2. Execute your iiiFN04 Department Maintenance function.

a. Try to delete the ADM department. You should not be able to delete this department.

b. Add a new department XYZ. Try to delete this department. You should be able to delete this department since no sections exist.


Summary

What You Should Know

  • What is referential integrity and why is it important to a database.
  • What type of validation check is used to create referential integrity.
  • What is the advantage of using the LANSA Repository to enter referential integrity rules, as opposed to using the database management system.


LFA_D10 Repository Summary

Objectives

  • To create a new file, the employee master file, which is part of your Personnel System application database. As an overview, you will complete the following tasks:
  • Create any new fields required for the file.
  • Create logical views over the file.
  • Create access routes to your existing files.
  • Create referential integrity rules to your existing files.
  • Create virtual fields and predetermined join fields.
  • Create validation rules for the file.
  • Create functions to test your repository definitions.
  • To update the database definitions and referential integrity once the employee file is added.
  • The Employee File definition will be as follows:

iiiFIL04

iiiEMPNO*

SURNAME

GIVENAME

ADDRESS1

ADDRESS2

ADDRESS3

POSTCODE

PHONEHME

PHONEBUS

STARTDTER

TERMDATER

iiiDEPT

iiiSECT

SALARY

mnthsal

startdte

termdate

iiideppjf

* indicates the file key(s)

lowercase italics indicate virtual fields/PJF

This exercise summarizes all of the skills you have acquired in completing the previous repository exercises. In the earlier exercises, it was important to provide step-by-step instructions since it was your first exposure to LANSA. In this tutorial, you will simply be asked to complete a set of developer tasks with LANSA. Detailed instructions are not provided. This exercise will test how well you know the LANSA repository.

Tips

  • If you need additional help completing any of these steps, refer back to previous tutorials.
  • Remember to use the online Help and the LANSA User Guides.
  • Review the physical database map for the application to help understand how the employee file relates to the department and section files.

To achieve the objectives of this tutorial, you must complete the following:

Step 1. Create New Fields

Step 2. Create the File Definition

Step 3. Create Logical Views

Step 4. Create Access Routes for Employee File

Step 5. Create Referential Integrity Rules for Employee File

Step 6. Create Virtual Fields for Employee File

Step 7. Create Predetermined Join Fields for Employee File

Step 8. Create Validation Rules for Employee File

Step 9. Make Employee File Operational

Step 10. Create Test Functions

Step 11. Test Your New File

Step 12. Create Access Routes for Department & Section Files

Step 13. Create Referential Integrity Rules for Section File

Step 14. Make the File Operational & Test

Summary


Step 1. Create New Fields

LFA_D10 Repository Summary

Most of the fields you will use in this exercise have already been defined in the repository. These fields were imported with the demonstration system. You should NOT make any changes to these fields! The only fields which you should change are the ones which you have created and have your iii prefix.

1. Using the most efficient means possible, create the following field with the basic characteristics listed. Assign appropriate values for edit codes, input attributes, default values, etc.

Field name: | iiiEMPNO
Description: | Employee Number
Type: | A
Length: | 5

Note: The iiiEMPNO should be exactly the same as the existing EMPNO field. The Employee Number is used to uniquely identify an employee. It is the key to the file.

2. Add help text to these new fields. TIP: Add the help text when you add/define the field.


Step 2. Create the File Definition

LFA_D10 Repository Summary

1. Create a new file called iiiFIL04 Employee.

The file definition should be as follows:

iiiEMPNO

SURNAME

GIVENAME

ADDRESS1

ADDRESS2

ADDRESS3

POSTCODE

PHONEHME

PHONEBUS

STARTDTER

TERMDATER

iiiDEPT

iiiSECT

SALARY

The key to the file should be the iiiEMPNO field.


Step 3. Create Logical Views

LFA_D10 Repository Summary

1. Create a logical view called iiiVEW04 which sorts the file by SURNAME.

2. Create a second logical view called iiiVEW05 which sorts the file by iiiDEPT and iiiSECT.


Step 4. Create Access Routes for Employee File

LFA_D10 Repository Summary

1. Before creating the access routes, consider the database model carefully.

2. Create access routes from the iiiFIL04Employee file to the iiiFIL02Department file.

3. Create access routes from the iiiFIL04Employee file to the iiiFIL03Section file.


Step 5. Create Referential Integrity Rules for Employee File

LFA_D10 Repository Summary

1. Create the required validation rules so that referential integrity is maintained.

You cannot add an Employee to a Section unless the Section exists.

Note: It is not necessary to add a referential integrity check to the Department file because referential integrity is already maintained by the relationship between Department and Section. When you validate the Section, you are using a key of iiiDEPT and iiiSECT to access the Section file.


Step 6. Create Virtual Fields for Employee File

LFA_D10 Repository Summary

Reminder: The virtual fields used in this step already exist in the repository and do not have to be created.

1. Create a date format virtual field that the real field STARTDTER (YYMMDD) is displayed in DDMMYY format using a new virtual field STARTDTE. This virtual field should be used on input and before output to the file.

2. Create a date format virtual field so that the real field TERMDATER (YYMMDD) is displayed in DDMMYY format using a new virtual field TERMDATE. This virtual field should be used on input and before output to the file.

3. Create a calculation virtual field so that the real field SALARY is displayed as a monthly salary (SALARY / 12) using the new virtual field MNTHSAL.


Step 7. Create Predetermined Join Fields for Employee File

LFA_D10 Repository Summary

1. Create a lookup PJF to the iiiFIL02Department file so that the Department Description iiiDEPDSC is displayed using the iiiDEPPJF Predetermined Join Field in file iiiFIL04.


Step 8. Create Validation Rules for Employee File

LFA_D10 Repository Summary

1. Many validation rules already exist for the fields. Review the fields in the file to view the rules which will impact the employee file.

2. Add a rule that checks that the iiiEMPNO is in the range A0000 to A9999.


Step 9. Make Employee File Operational

LFA_D10 Repository Summary

1. Make the employee file operational.


Step 10. Create Test Functions

LFA_D10 Repository Summary

1. Create a new function iiiFN08 Employee Prompt. Use the FRPOP02 Pop Up Prompter (Requests Search Values) template to create a prompt function which uses the logical view iiiVEW04.

2. Remember to change the prompt function link for the iiiEMPNO field to use your new function.

3. Create a new function iiiFN09 Employee Maintenance. Use the FRMNT01 template. Think carefully about which fields you will display, add and change. Remember, if you do not like the results of the template, simply delete the function and execute the template again.


Step 11. Test Your New File

LFA_D10 Repository Summary

1. Execute your iiiFN08 Employee Maintenance function.

a. Leave the entry screen blank and press Enter to see a list of field and file rules.

b. Add some test data to the file. Be sure to check your validation rules as you add your data.

c. Try adding an employee to a Department or Section that does not exist.

d. Try changing the Termination Date to a date before the Start Date.

e. Display an employee record and check that your virtual fields and Predetermined Join Fields are correct.


Step 12. Create Access Routes for Department & Section Files

LFA_D10 Repository Summary

1. Before creating the access routes, consider the database model carefully.

2. Create access routes from the iiiFIL02 Department file to the iiiFIL04 Employee file.

3. Create access routes from the iiiFIL03 Section file to the iiiFIL04 Employee file.


Step 13. Create Referential Integrity Rules for Section File

LFA_D10 Repository Summary

1. Create the required validation rule so that referential integrity is maintained.

You cannot delete a Section if an employee exists in that section.


Step 14. Make the File Operational & Test

LFA_D10 Repository Summary

1. Make the Department and Section files operational.

2. Use your Section Maintenance function to test the referential integrity to the employee file.


Summary

What You Should Know

  • How to use the features in the LANSA Repository to create an application database.


RDML Tutorials

LFA_E10 Creating Processes

LFA_E20 Process Characteristics

LFA_E30 Creating Functions

LFA_E40 Function Editor

LFA_E50 Screen Painter

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function

LFA_G10 RDML Application


LFA_E10 Creating Processes

Objectives

  • To show how LANSA processes can be created, both manually and by copying an existing process.
  • To understand how a process relates to its functions.

To achieve these objectives, you must complete the following:

  • Step 1. Create a New Process
  • Step 2. Add Process Help Text by Copying
  • Step 3. Add a Function to Process iiiPRO03
  • Step 4. Copy a Process
  • Step 5. Delete a Process
  • Summary


Step 1. Create a New Process

LFA_E10 Creating Processes

1. From the LANSA Main System Menu, select the option to Work with Processes. The Work with Processes menu will display a list of all processes defined within the partition.

2. Press F6 to create a new process definition as follows:

Process Name: | iiiPRO03 where iii = your tutorial assigned ID
Process Description: | Test Process Menu

Use the defaults for all other values.

3. Press Enter to create the process definition.

4. Use option 10=Use and execute your newly created iiiPRO03 Test Process Menu. When the process executes, you will see only two options (display help text and exit) since no functions exist within the process. These are standard options for all process menus.

5. Press F12 to exit the process menu.


Step 2. Add Process Help Text by Copying

LFA_E10 Creating Processes

1. Use option 5=Help Text to create some help text for process iiiPRO03.

2. Enter YES on the Maintain Process Help Text panel in order to define help text at the process level.

3. When the Create Help Text by Copy panel appears, copy the process help text from the PSLSYS process.

4. The IBM SEU editor will display the help text from PSLSYS. Press F3 to exit the SEU editor. Be sure to save the help text when exiting the SEU editor by specifying Change/create member as Y before you press Enter.

5. Execute the iiiPRO03 process again and display your newly created help text.

6. Press F12 to exit the process.


Step 3. Add a Function to Process iiiPRO03

LFA_E10 Creating Processes

1. Use option 2=Review/Change Functions to work with the functions in the iiiPRO03 process.

2. From the Work with Functions menu, press F6 to create a new function. When the Define New Function panel appears, enter the following:

Function Name: | iiiFN10 where iii=your tutorial assigned ID
Function Description: | Add Department
Function Type: | 1 (Generate from an Application Template)

3. Press Enter to create the new function. When the Application Template Selection prompt appears, scroll down and select the FRADD01 Flat Screen Data Entry template. Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question.

TEMPLATE QUESTION | ANSWER
Supply a word that describes WHAT this data entry program works with | department
Do you want this function to be part of an action-bar style process? | N
Enter the name of the PHYSICAL file to be used by this template | iiiFIL02
Fields to appear on entry panel | Select iiiDEPT and iiiDEPDSC.
Fields to work with in the program | Select the iiiDEPT field.
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN

4. Your function is now created and saved. The template has generated the required RDML based on the answers to the template questions. The function is ready for compilation.

5. Press F12 to exit the Work with Functions menu. The Status of RDML Functions panel will be displayed. Notice that iiiFN10 is not currently usable.

6. Press F12 or Enter to return to the Work with Processes menu.

7. Use option 7=Compile to compile the functions within process iiiPRO03. When the Compile/Recompile Process panel is displayed, the iiiFN10 function will automatically be selected for compile. Simply press Enter, accepting the defaults to submit the process for compilation.


Step 4. Copy a Process

LFA_E10 Creating Processes

1. Create a new process as follows:

Process Name: | iiiPRO04 where iii=your tutorial assigned ID
Process Description: | Copy Process
Copy from process: | iiiPRO03

2. Press Enter to create the new process. Copying a process will create an exact duplicate process definition.

3. Review the Help Text for the iiiPRO04 process. Notice that the help text was copied from iiiPRO03.

4. Work with the functions within the process iiiPRO04. Notice that the new process contains the iiiFN10 function.

5. Return to the Work with Processes menu but do not compile the process.


Step 5. Delete a Process

LFA_E10 Creating Processes

1. Delete the iiiPRO04 process from the repository. The functions are automatically deleted when you delete the process.


Summary

What You Should Know

  • What a process is.
  • How to create a new process manually and by copying an existing process.
  • How to define help text for a process.
  • How to compile a process.
  • How to delete a process.

Other Tutorials

LFA_E20 Process Characteristics

LFA_E30 Creating Functions

LFA_E40 Function Editor

LFA_E50 Screen Painter

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_E20 Process Characteristics

Objectives:

  • To identify what can be modified using the Function Control Table.
  • To show how processes and functions can be attached to another process.
  • To identify some special entries which can be added to a process menu.
  • To review the process details and parameters.
  • To understand how these details and parameters impact the process and its functions.

To achieve these objectives you must complete the following:

  • Step 1. Function Control Table
  • Step 2. Attached Processes/Functions
  • Step 3. Special Entries
  • Step 4. Review Process Parameters
  • Step 5. Miscellaneous Details
  • Summary


Step 1. Function Control Table

LFA_E20 Process Characteristics

In this step, you will modify the iiiPRO02 Repository Test Process. You will hide the prompt functions on the menu since these functions are designed to be accessed from a field prompt. You will also update the function descriptions as they appear on the menu. Finally, you will control the next allowable action after a function executes.

1. From the Work with Processes menu, press F23 to display more options on the Work with Processes menu. You should see options 18 through 30.

2. Use option 20=Function control table to modify the iiiPRO02 process menu.

3. When the Function Control Table panel appears, press F21 and then make the following changes to the process definition:

a. Change the Allowable next functions for iiiFN02 Test Fields to be EXIT.

b. Change the Allowable next functions for iiiFN03 Test Rules to be iiiFN04 and iiiFN05.

c. Change the Description of iiiFN04 Department Maintenance to be Add/Chg/Dlt Department and change the Menu Sequence to be 20.

d. Change the Menu Sequence number for iiiFN05 Section Maintenance to be 30.

e. Set the Display on Process to NO for iiiFN06 Department Prompt so that the function is not displayed on the process menu.

f. Set the Display on Process to NO for iiiFN07 Section Greater Than 0 Prompt.

g. Set the Display on Process to NO for iiiFN08 Employee Prompt.

h. Change the Menu Sequence number for iiiFN09 Employee Maintenance to be 10.

4. Press Enter to save the changes to the Function Control.

5. Execute the process to test your changes.

  • Notice that the prompt functions are not displayed on the menus.
  • Notice the new description for the iiFN04 function.
  • Notice the order/sequence of the functions.
  • Be sure to test the next allowable functions after executing iiiFN02 Test Fields (exit) and iiiFN03 Test Rules (iiiFN04 or iiiFN05).

6. Exit the process menu.


Step 2. Attached Processes/Functions

LFA_E20 Process Characteristics

In this step, you will include a process menu and a function from another process on your menu.

1. From the Work with Processes menu, use option 24=Other Processes to modify the iiiPRO02 process menu.

2. When the Processes on Process Menu panel appears, press F21 and then make the following changes to the process definition:

a. Enter an Attached Process of iiiPRO01 and Attached Function of iiiFN01 to create a link to a single function from another process.

b. Enter an Attached Process of iiiPRO03 and Attached Function of *ALL so that the process menu is linked to the iiiPRO02 menu.

3. Press Enter once you have made both additions to the process menu.

4. Use the Function Control Table to change the function description of the iiiFN01 function in the iiiPRO01 process to be Enroll a New Employee (PSLMST), so that you can identify this function on the process menu.

5. Execute the iiiPRO02 process to test your changes. (Reminder: The Enroll A New Employee(PSLMST) function adds records to the PSLMST file and not to your iiiFIL04Employee file.)


Step 3. Special Entries

LFA_E20 Process Characteristics

In this step, you will allow the user to execute the OS/400 work with submitted jobs from the process menu.

1. Use option 22=Special entries to modify the iiiPRO02 process menu.

2. When the Additional Menu Entries panel appears, press F21 and then make the following changes to the process definition:

a. Enter a Description to display on menu of Work Submitted Job.

b. Enter a Command to be executed of WRKSBMJOB so that the all of the jobs submitted from the workstation will be listed.

3. Press Enter to add the entry.

4. Execute the process to test your changes.


Step 4. Review Process Parameters

LFA_E20 Process Characteristics

In this step, you will simply review the process parameters. No changes will be made.

1. Use option 26=Parameter to view the iiiPRO02 process parameters.

2. Press Enter to return to the LANSA Process Control Window.

3. If you need to pass a parameter to a process, be sure to review the iSeries Technical Reference Guide – Passing Parameters into LANSA Processes / Batch Processing.


Step 5. Miscellaneous Details

LFA_E20 Process Characteristics

In this step, you will simply review the process details. No changes will be made.

1. Use option 28=Miscellaneous to view the iiiPRO02 process details. If you wish to change the process description, you can do so from this panel. Notice that you can web or XML enable your LANSA applications simply by changing the flag from N to Y.

2. Press Enter to return to the LANSA Process Control Window.


Summary

What You Should Know

  • How you control the order in which options appear on the menu.
  • What are some of the options for the next available function.
  • How you add a process menu to another process menu.
  • How you add a single function from one process to the menu of another process.
  • How you create special entries on the process menu.
  • What is an important consideration when you add special entries to a process.
  • What is the purpose of the process parameters.
  • How many parameters can be passed to the process.
  • What are the different styles of processes supported by LANSA.

Other Tutorials

LFA_E30 Creating Functions

LFA_E40 Function Editor

LFA_E50 Screen Painter

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_E30 Creating Functions

Objectives:

  • To show how LANSA functions can be created automatically using templates, created manually, or created by copying an existing function.

Note: The focus of this exercise is not the RDML created in the function.

To achieve these objectives you must complete the following:

  • Step 1. Create a Function By Copying
  • Step 2. Create a Function Manually
  • Step 3. Compile and Test Functions
  • Step 4. Add Function Help Text
  • Summary


Step 1. Create a Function By Copying

LFA_E30 Creating Functions

In this step, you will copy the iiiFN10 Add Department function which you created using the FRADD01 template. In the next exercise, youwill manually change the RDML code so that this function is used to add data to the Section file instead of to the Department file.

1. Work with the functions of the iiiPRO03 Test Process Menu.

2. Press F6 to create a new function. When the Define New Function panel appears, enter the following information:

Function Name: | iiiFN11 where iii=your tutorial assigned ID
Function Description: | Add Section
Function Type: | 2 (Copy existing process/function)
Process / function: | iiiPRO03 / iiiFN10

3. Press Enter to create the new function by copying the existing iiiPRO03/iiiFN10 process/function.

4. When the function has been copied, the LANSA function editor will be displayed. Simply press F12 to exit the editor. In the next exercise, youwill review the editor features in detail.


Step 2. Create a Function Manually

LFA_E30 Creating Functions

1. Create a new function as follows:

Function Name: | iiiFN12 where iii=your tutorial assigned ID
Function Description: | Add Employee
Function Type: | 3 (Manually define function)

2. The LANSA Function Editor will appear. There will be no RDML code in the editor. You could begin to insert new commands to code your RDML for the function. In this step, you will create the RDML by using a template from within the editor.

3. Press F21 to change the RDML commands in the editor.

4. To execute a template in the function editor, enter ET in the Action (Act) column and press Enter. (The cursor should automatically position to the Act column when you press F21 to edit the RDML in the function.)

5. When the Application Template Selection prompt appears, scroll down and select the FRADD01 Flat Screen Data Entry template. Answer the template questions as shown below.

TEMPLATE QUESTION | ANSWER
Supply a word that describes WHAT this data entry program works with | employee
Do you want this function to be part of an action-bar style process? | N
Enter the name of the PHYSICAL file to be used by this template | iiiFIL04
Fields to appear on entry panel | Select ALL fields except for STARTDTER, TERMDATER, MNTHSAL, iiiDEPPJF, as these fields are used only for output purposes.
Fields to work with in the program | Select the iiiEMPNO field.
Design fields on the data entry panel DOWN the screen or ACROSS the screen | DOWN

6. The RDML will be automatically generated and will appear in the RDML editor. You have now created a function by executing a template from within the editor. This code could have also been created by manually entering each line.

7. Press Enter to save the RDML commands.

When the Update iiiFN12 function from LANSA workspace? message appears, specify Yes and press Enter to update the RDML.

8. Enter NO in the Invoke function checker field and press Enter to exit the function editor.


Step 3. Compile and Test Functions

LFA_E30 Creating Functions

1. Use option 7=Compile to compile the two new functions in your iiiPRO03 process. Use the defaults provided and press Enter to submit the job.

2. Check that your compiles complete successfully.

3. Execute and test your two new functions. Reminder: The Add Section function is a copy of the Add Department function. In the next exercise, you will manually change the RDML so that the Add Section function adds data to the Section file.


Step 4. Add Function Help Text

LFA_E30 Creating Functions

1. From the Work with Processes menu, use option 5=Help Text to create some help text for process iiiPRO03.

2. Select the iiiFN12 Add Employee function.

3. When the Create Help Text by Copy panel appears, copy the process help text from the PSLSYS process and ENROL function.

4. The SEU editor will display the help text from the ENROL function. Press F3 to exit the SEU editor. Be sure to save the help text when exiting the SEU editor by specifying Change/create member as Y before you press Enter.

5. Execute the iiiPRO03 process again and use the help text option from the process menu.

6. When the process help text is displayed, use F11=Index and then select the iiiFN12 Add Employee function to review the help text.

7. Exit the process.

  • Summary

What You Should Know

  • How to create a function by copying an existing function.
  • How to create a function manually and how to use a template within the function editor.
  • How to create function level help text.

Other Tutorials

LFA_E40 Function Editor

LFA_E50 Screen Painter

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_E40 Function Editor

Objectives:

  • To highlight the features of the LANSA function editor. (Reminder: The focus of this exercise is not the RDML created in the function but how to use the editor features.)
  • To modify the RDML code in the iiiFN11 Add Section function which was copied from the iiiFN10 Add Department function. You must manually update the fields and files used in the RDML commands in the function so that the proper file is updated.

To achieve these objectives you must complete the following:

  • Step 1. Edit the iiiFN11 Function
  • Step 2. Editor Facilities for Viewing RDML
  • Step 3. Editing RDML Commands using Prompts
  • Summary


Step 1. Edit the iiiFN11 Function

LFA_E40 Function Editor

Work with the functions of process iiiPRO03.

1. Use option 2=Review/Change RDML to edit the RDML commands in function iiiFN11 Add Section. This function was copied from the Add Department function. You must manually change the RDML to use the correct fields and files to update the Section file.

2. The LANSA function editor will display the RDML commands in the iiiFN11 function.


Step 2. Editor Facilities for Viewing RDML

LFA_E40 Function Editor

In this step, you will quickly review some of the editor features which can be used when viewing RDML.

1. Scroll through the RDML commands using page up and page down.

2. Press F7 to move to the end of the function.

3. Press F20 to indent the RDML commands.

4. Press F19 to color the indent levels.

5. Press F23 to zoom in and F24 to zoom out. Notice how the RDML levels become either hidden or expanded.

6. Press F19 and F20 to turn indent and color off.


Step 3. Editing RDML Commands using Prompts

LFA_E40 Function Editor

Following is a listing of the RDML statements in the iiiFN11 Add Section Function:

********** | =======================================================
********** | Copyright .....: (C) ASPECT COMPUTING PTY LTD, 1991
********** | Process .......: iiiPRO03
********** | Function ......: iiiFN10
********** | Created by ....: PCXUSER
********** | Created on ....: 00/00/00 at 00:00:00
********** | Description ...: Add Department
********** | =======================================================
********** | Function control options
FUNCTION | OPTIONS(*NOMESSAGES *DEFERWRITE *DIRECT)
********** | Group and field declarations
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiDEPDSC)
********** | Issue initial data entry message
MESSAGE | MSGID(DCU0010) MSGF(DC@M01) MSGDTA('department')
********** | Do data entry until terminated by EXIT or CANCEL
BEGIN_LOOP |
********** | Request user inputs or corrects details
REQUEST | FIELDS(#PANELDATA) DESIGN(*DOWN) IDENTIFY(*DESC)
********** | Perform any program level validation here
BEGINCHECK |
ENDCHECK |
********** | Attempt to insert data into the data base
INSERT | FIELDS(#PANELDATA) TO_FILE(iiiFIL02)
********** | If okay, reset fields and issue accepted message
CHANGE | FIELD(#PANELDATA) TO(*DEFAULT)
MESSAGE | MSGID(DCU0011) MSGF(DC@M01) MSGDTA('department')
END_LOOP |

Following is a list of the required RDML with the changes highlighted:

********** | =======================================================
********** | Copyright .....: (C) ASPECT COMPUTING PTY LTD, 1991
********** | Process .......: iiiPRO03
********** | Function ......: iiiFN11
********** | This function created with FRADD01 template.
********** | Created by ....: PCXUSER
********** | Created on ....: 00/00/00 at 00:00:00
********** | Description ...: Add Section
********** | This function was manually edited.
********** | =======================================================
********** | Function control options
FUNCTION | OPTIONS(*NOMESSAGES *DEFERWRITE *DIRECT)
********** | Group and field declarations
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #SECPHBUS #iiiAMOUNT #iiiAREAC #iiiLOCAL)
********** | Issue initial data entry message
MESSAGE | MSGID(DCU0010) MSGF(DC@M01) MSGDTA('section')
********** | Do data entry until terminated by EXIT or CANCEL
BEGIN_LOOP |
********** | Request user inputs or corrects details
REQUEST | FIELDS(#PANELDATA) DESIGN(*DOWN) IDENTIFY(*DESC)
********** | Perform any program level validation here
BEGINCHECK |
ENDCHECK |
********** | Attempt to insert data into the data base
INSERT | FIELDS(#PANELDATA) TO_FILE(iiiFIL03)
********** | If okay, reset fields and issue accepted message
CHANGE | FIELD(#PANELDATA) TO(*DEFAULT)
MESSAGE | MSGID(DCU0011) MSGF(DC@M01) MSGDTA('section')
END_LOOP |

Please be sure to follow these steps exactly. Though there may be more efficient means of updating the RDML code, this exercise is designed to show the various editor features.

1. Press F21 to change the RDML commands so you can begin to edit the code.

2. Press F8 Jump and then select START OF FUNCTION to go to the top of the function.

3. For the comment at line 4, simply type over the function name iiiFN10 on the screen so that the proper function name iiiFN11 appears.

4. Insert a new command after line 4 by typing an I (Insert) in the Act column on line 4. Press Enter and a new line will be inserted. Add a comment to the RDML:

********** This function was created with FRADD01 template.

5. Copy this comment by typing a C (Copy) in the Act column of the line and typing an A (After) beside line 8. Press Enter to copy the line. After the line is copied, change the text to read:

This function was manually edited.

Note: If wish to copy code from another RDML function, you can enter EF in the Act column.

6. You will now use the find and change facility. At the top of the screen, enter DEPARTMENT in the Find field. Enter SECTION in the Change field. (Leave the change type as N for Next.) Press F16 to Find Forward and change the value of DEPARTMENT to SECTION. Press F16 until no more changes are found. There should be 3 changes made.

7. Press F7 to go to the end the function. Position the cursor anywhere on line 25. Press F4 to prompt the INSERT command. (You could also use the P action code.) All parameters for the INSERT command will be displayed. Change iiiFIL02 to iiiFIL03. Press Enter to return to normal editing.

8. You will now add fields to the GROUP_BY command using a field insert. Type an F in the Act column of the GROUP_BY command and press Enter. Type iiiFIL03 as the name of the file from which the fields are to be chosen and press Enter. When the list of fields appears, select the #iiiSECT #iiiSECDSC, #SECADDR1, #SECADDR2, #SECADDR3, #SECPCODE, #SECPHBUS, #iiiAMOUNT, #iiiAREAC, and #iiiLOCAL fields. Press Enter to add these fields to the GROUP_BY. Press Enter to return to normal editing.

9. Next you will remove the unnecessary fields from the GROUP_BY. Notice that the GROUP_BY uses more than one line in the editor. You cannot simply delete the #iiiDEPDSC from the GROUP_BY. View the GROUP_BY command using an unformatted prompt by typing a U in the Act column and pressing Enter. Now delete the #iiiDEPDSC field from the GROUP_BY. Press Enter to return to normal editing.

10. Press Enter (after no changes) again, so that the prompt for updating (saving the RDML) appears. Accept the default YES and press Enter.

11. Because this is a very small function, you will perform a full function check by entering YES in the Invoke function checker field and pressing Enter.

12. If any errors are found in your RDML, make the necessary corrections.

13. Press F9 and view the audit information for the function. You will be able to see which lines of RDML code were changed.

14. You have now completed editing your RDML function.


Summary

What You Should Know

  • How you prompt a command in the editor.
  • How you copy code in the LANSA editor.
  • How you find all occurrences of #iiiDEPT and change it to #iiiSECT.
  • How you check your RDML code in the editor.

Other Tutorials

LFA_E50 Screen Painter

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_E50 Screen Painter

Objectives:

  • To introduce the basic features of the LANSA screen painter.
  • To modify the Add Section screen to appear something like the following:

To achieve these objectives you must complete the following:

  • Step 1. Accessing the Screen Painter
  • Step 2. Painting a Screen
  • Step 3. Compile the Function and Test
  • Summary


Step 1. Accessing the Screen Painter

LFA_E50 Screen Painter

1. If you have not already done so, open the iiiFN11 Add Section function which was used in the last exercise.

2. Review the RDML GROUP_BY command. It should appear as follows:

GROUP_BY

NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #SECPHBUS #iiiAMOUNT #iiiAREAC #iiiLOCAL)

3. Also review the RDML REQUEST command. You will see a change in this command as a result of the changes made in the screen painter.

4. Invoke a design check by typing DESIGN in the Invoke function checker field and then press Enter.

5. If no errors are found, you can invoke the screen design aid by typing SCREEN in the Invoke the design facility field and then press Enter.

6. The Screen Design Facility panel will appear. It will list all screens which can be painted.

7. Select the REQUEST command. The Screen Editor will be displayed.


Step 2. Painting a Screen

LFA_E50 Screen Painter

1. With the cursor positioned in the Act field, press Help to review the list of valid action codes.

2. First delete the SECPHBUS field from the screen as this field is maintained using the iiiAREAC and iiiLOCAL virtual fields. Type an action code of FD and press Enter. (You can also use F22.) Following the instructions, position the cursor anywhere on the Business Phone Number field and press Enter. The field will be deleted.

3. Next move the Amount field. Position the cursor on the Amount field and press F16. (You can also use an action code of M.) Move the cursor down a few lines (below the Local Phone) and press Enter again. The field will move to the cursor location provided no conflict exists.

4. Next youwill add some text to the screen by painting a "+" beside the Department Code to indicate that it can be prompted. Type an action code of TI and press Enter. (You can also use F6.) Read the warning and press Enter. Type the character + as the text to be added. Press Enter. Now move the cursor to a few characters to the right of the Department Code field and press Enter. The text will be inserted at the cursor position. You can move the text in a similar fashion to moving the fields.

5. Repeat this procedure to add a + beside the Section Code field.

6. Next, change the field identification used for the Area Code field. Position the cursor anywhere on the Area Code field and press F17. (You can also use an action code of ID.) When the Change Identification prompt appears, select the No Identification is required option. The field description from the repository will no longer be displayed.

7. Repeat this procedure for the Local Phone field.

8. Move these two fields so that they are side by side and in line with the other entry fields.

9. Finally, add some text beside these fields which reads Telephone (Area Code/Local Phone).

10. Press F3 to exit the screen painter. When the Exit from Painter prompt appears, select the Exit and update design option.

11. From the Screen Design Facility Panel, press F12 to return to the LANSA function editor.

12. Review the RDML GROUP_BY statement. The command will now appear something like this:

GROUP_BY

NAME(#PANELDATA) FIELDS((#iiiDEPT *L3 *P2)(#iiiSECT *L4 *P2)(#iiiSECDSC *L5 *P2)(#SECADDR1 *L6 *P2)(#SECADDR2 *L7 *P2)(#SECADDR3 *L8 *P2)(#SECPCODE *L9 *P2)(#iiiAMOUNT *L13 *P2)(#iiiAREAC *L11 *P41 *NOID)(#iiiLOCAL *L11 *P50 *NOID))

The changes to the design of the screen are reflected in the GROUP_BY command. Notice how the SECPHBUS field has been removed.

13. Also review the REQUEST command. Notice the change which results from the text added to the panel.

14. Exit the function editor.


Step 3. Compile the Function and Test

LFA_E50 Screen Painter

1. Compile your newly edited function.

2. Execute the function to test your changes.


Summary

What You Should Know

  • How you access the screen painter.
  • What types of changes can be made using the screen painter.
  • What are some considerations when adding text to your screens.
  • What RDML commands are affected by the screen painter.
  • What are the exit options provided by the editor.

Other Tutorials

LFA_E60 LANSA Debug

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_E60 LANSA Debug

Objectives:

  • To demonstrate how to use the LANSA interactive debugger.
  • To debug the code in the iiiFN11Add Section function.

To achieve these objectives you must complete the following:

  • Step 1. Turn on Debug mode
  • Step 2. Execute the Function
  • Step 3. Set Breakpoints and Variables to Display
  • Step 4. View Variables at Breakpoints
  • Step 5. Use Edit Services to Change Breakpoints
  • Summary


Step 1. Turn on Debug mode

LFA_E60 LANSA Debug

1. From the Work with Processes menu, press F10=Other and then select Turn LANSA debugging mode on.

2. Specify the iiiPRO03 process and iiiFN11 function to be debugged.


Step 2. Execute the Function

LFA_E60 LANSA Debug

1. Use iiiPRO03 and execute the iiiFN11 Add Section function.

2. When the function begins to execute, you will be asked to select the debug mode. Type 1 for interactive debug and press Enter.


Step 3. Set Breakpoints and Variables to Display

LFA_E60 LANSA Debug

1. Add breakpoints at line 20 (REQUEST) and 25 (INSERT) in the RDML function. Press Enter.

2. Select the iiiAMOUNT, iiiDEPT and IO$STS variables for display. Press Enter.


Step 4. View Variables at Breakpoints

LFA_E60 LANSA Debug

1. Once the first breakpoint is reached at line 20 (REQUEST), the function will halt and the selected variables will be displayed. If you position the cursor on the RMDL commands at the top of the screen, you can scroll through the RDML code in the function.

2. Press Enter to proceed to the next breakpoint.

3. The Add Section screen will appear. Enter the following data:

Department Code: | ADM
Section Code: | 99
Amount: | 1234.56

4. Press Enter to add the record.

5. Once the breakpoint is reached at line 25, the RDML code will be displayed.

6. Use action C=Change for the iiiDEPT field and press Enter.

7. Change the code from ADM to blanks and press Enter. This change will cause the function to return to the REQUEST panel since a blank department code is not valid.


Step 5. Use Edit Services to Change Breakpoints

LFA_E60 LANSA Debug

1. Press F10=Services.

a. Select option 1 to Review/Change Debug statements.

b. Press Enter.

c. Scroll down and remove the breakpoint at line 20 (REQUEST).

d. Press Enter.

e. Press F3=Exit Services to return to the debugger.

2. Press Enter to allow the function to execute.

3. The function will return to the Add Section screen and the Department Code will be highlighted as being in error since a blank Department Code is not valid.

4. Press F12 to exit the function.

5. Press F12 to exit the process.

6. From the Work with Processes menu, press F10=Other and turn LANSA debugging mode off.


Summary

What You Should Know

  • How you invoke the LANSA debugger.
  • What must be done before you can execute a function in debug mode.
  • How you set breakpoints in the RDML function.
  • How you display and change field values using the debugger.
  • How you set breakpoints and change variables after the function is already executing in debug mode.

Other Tutorials

LFA_F10 A Simple Add Function

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_F10 A Simple Add Function

Objectives:

  • To create a simple data entry function (similar to the code from FRADD01 template).
  • To introduce the structure of a LANSA function.
  • To highlight some of the benefits of using 4GL constructs.
  • To introduce the following RDML commands:
  • FUNCTION
  • MESSAGE
  • REQUEST
  • INSERT
  • CHANGE
  • BEGINCHECK/ENDCHECK
  • xxxxxCHECK (CALLCHECK, CONDCHECK, DATECHECK, FILECHECK, RANGECHECK, VALUECHECK), ON_ERROR and SET_ERROR
  • IF
  • BEGIN_LOOP/END_LOOP
  • GROUP_BY

Please refer to the iSeries Technical Reference Guide for detailed descriptions of each RDML command. You will be referring to the iSeries Technical Reference Guide to learn more about each RDML command.

To achieve these objectives you must complete the following:

  • Step 1. Create a Simple Add Function
  • Step 2. Add More than One Record
  • Step 3. Function Level Validations
  • Step 4. Reset the Data in the Entry Panel
  • Step 5. Hide the iiiAMOUNT Field
  • Step 6. Compare to iiiFN11
  • Summary

Very Important Note:
Depending upon the response time for your iSeries, you may wish to only compile the final version of the function. If your iSeries takes 5 or 10 minutes to compile a function, do not compile the function at the end of each step.


Step 1. Create a Simple Add Function

LFA_F10 A Simple Add Function

In this step, you will create one of the simplest functions possible. This function will simply present a data entry screen with a message for the user to enter data. The entered data will be inserted into the Section file. If there are any validation errors, the data entry screen will automatically be displayed with the fields in error highlighted and the appropriate messages displayed. The function ends after a single record is added.

You will create the function by completing the following tasks:

  • Use a building block template to create a standard function header.
  • Request that iiiDEPT, iiiSECT, iiiSECDSC, iiiAMOUNT and STD_AMNT fields be entered.
  • Insert the data into the iiiFIL03 section file.
  • Display a message that the data was entered.

1. Create a new process as follows:

Process Name: | iiiPRO04 where iii=your tutorial assigned ID
Process Description: | RDML Applications

2. Create a new function in process iiiPRO04 as follows:

Function Name: | iiiFN13 where iii=your tutorial assigned ID
Function Description: | Add Section Data
Function Type: | 3 (Manually define function)

3. Create a function header by executing the BBPGM template. This template will insert a standard block of comments in your function (as shown below). The template will also include a FUNCTION OPTIONS(*DIRECT) command.

4. In addition to the function header, create the following three lines of RDML which are highlighted at the bottom of the following listing:

********** | =======================================================
********** | Copyright .....: (C) ASPECT COMPUTING PTY LTD, 1989
********** | Process .......: iiiPRO04
********** | Function ......: iiiFN13
********** | Created by ....: PCXUSER
********** | Created on ....: 99/99/99 at 00:00:00
********** | Description ...: Add Section
********** | =======================================================
********** | Working fields, lists and groups
********** | =======================================================
********** |
********** | =======================================================
********** | Screen Panel Groups and Lists)
********** |
 | =======================================================
********** | =======================================================
********** | Report line declarations)
********** | =======================================================
********** |
********** | =======================================================
********** | Program Mainline : iiiFN13)
********** | =======================================================
********** |
FUNCTION | OPTIONS(*DIRECT)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
REQUEST | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #STD_AMNT)
INSERT | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) TO_FILE(iiiFIL03)

5. Optional:

a. Save the RDML and exit the editor.

b. Compile the function.

c. Execute the function.

d. Do not enter any data in the fields

e. Press Enter.

  • Notice that all fields in error are highlighted. STD_AMNT has no error messages as it is not used in the iiiFIL03 Section file and has no validation rules. In Step 2, you will use the STD_AMNT field to replace the iiiAMOUNT field.

f. Add some valid data and press Enter.

  • Notice that the function terminates after one record is added.

g. Execute the function again. This time press F12 to return to the menu without adding any data.

  • Notice that the function routing is handled by the options on the REQUEST command. (Refer to the MENU_KEY option.) Additional RDML code does not have to be written.


Step 2. Add More than One Record

LFA_F10 A Simple Add Function

In this step, you will modify the function created in Step 1 so that you can add more than one record when you execute the function, i.e. the function will not terminate after adding one record. After each record is inserted into the file, a message will be displayed. You will also remove the iiiAMOUNT field from the display and use the STD_AMNT field to update the iiiAMOUNT field.

You will modify the function as follows:

  • Allow more than one record to be added at a time by using the BEGIN_LOOP and END_LOOP commands. The data entry panel should be displayed until the user presses Cancel or Exit.
  • Display a message that the data has been inserted into the file.
  • Remove the iiiAMOUNT field from the display.
  • Change the REQUEST command so that the fields are displayed using their descriptions.
  • Change iiiAMOUNT to the STD_AMOUNT before inserting data into the file.

1. Edit the RDML commands in your function iiiFN13 Add SectionData.

2. Try to create the RDML code based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #STD_AMNT) IDENTIFY(*DESC)
CHANGE | FIELD(#iiiAMOUNT) TO(#STD_AMNT)
INSERT | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) TO_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |

4. Optional:

a. Save the RDML and exit the editor.

b. Compile the function.

c. Execute your new function.

d. Do not enter any data in the fields

e. Press Enter.

  • Review the messages. Notice that there are error messages for the iiiAMOUNT field but the STD_AMNT field is not highlighted as being in error.

f. Add a new record. (You may notice that your existing entries are still displayed after the INSERT. In a following step, you will reset the entry fields to their default.)

  • Notice that the BEGIN_LOOP/END_LOOP will allow you to add more records to the file.

g. Press F12 to cancel the function.


Step 3. Function Level Validations

LFA_F10 A Simple Add Function

In order to highlight function level validations, the iiiAMOUNT was removed from the display. The STD_AMNT field is used to enter data into iiiAMOUNT. You will add function level validations to check the STD_AMNT field. The validation rules added will be the same rules used in the repository for the iiiAMOUNT field.

You will modify the function as follows:

  • Add the appropriate validation rules to the STD_AMNT field by including a BEGINCHECK and ENDCHECK block after the REQUEST command.
  • Use an IF statement to check if STD_AMNT is 0, and then use a SET_ERROR command to highlight the field and display an error message.
  • Use a RANGECHECK to check if STD_AMNT is between –5000 and 5000.

1. Edit the RDML commands in your function iiiFN13 Add SectionData.

2. Try to create the RDML code based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #STD_AMNT) IDENTIFY(*DESC)
BEGINCHECK |
IF | COND('#STD_AMNT *EQ 0')
SET_ERROR | FOR_FIELD(#STD_AMNT) MSGTXT('Amount cannot be zero.')
ENDIF |
RANGECHECK | FIELD(#STD_AMNT) RANGE((-5000 5000)) MSGTXT('Amount must be in range -5000 to 5000.')
ENDCHECK |
CHANGE | FIELD(#iiiAMOUNT) TO(#STD_AMNT)
INSERT | FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) TO_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |

4. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function. Execute your new function.

d. Do not enter any data in the fields

e. Press Enter.

  • Notice that only the iiiAMOUNT field is highlighted. The repository validations have not been performed by the INSERT command because the ENDCHECK routes control back to the REQUEST before the INSERT command can be executed.

f. Enter a valid amount but leave the other fields blank. Press Enter. Notice that the fields validated by the OAM are now highlighted because the INSERT command has been executed.

g. Add a new record to the section file.

  • Notice that your existing entries are still displayed after the INSERT. In the next step, you will reset the entry fields to their default.

h. Press F12 to cancel the function.


Step 4. Reset the Data in the Entry Panel

LFA_F10 A Simple Add Function

In this step, you will modify the function as follows:

  • Change the screen fields to their defaults after a record is added.
  • Add all of the input fields of the iiiFIL03 file to the data entry panel.
  • Use a GROUP_BY command to make coding more efficient.

1. Edit the RDML commands in your function iiiFN13 Add Section Data.

2. Immediately after the INSERT command, add a change command which resets all of the screen fields to their defaults. Hint: You should be able to do this with one command.

3. Review the RDML code and determine what changes are required so that the following fields are displayed on the data entry panel, and then inserted into the file, and then reset to their defaults: #iiiDEPT, #iiiSECT, #iiiSECDSC, #SECADDR1, #SECADDR2, #SECADDR3, #SECPCODE, #SECPHBUS, #iiiAMOUNT, #iiiAREAC, #iiiLOCAL.

4. You will need to change the list of fields in the CHANGE, REQUEST and INSERT commands. Instead of modifying all of these lists of fields, use a GROUP_BY for the list of fields. You can use the GROUP_BY field in the CHANGE, REQUEST and INSERT commands.

5. The RDML in your function should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#ADDDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #STD_AMNT #iiiAMOUNT #iiiAREAC #iiiLOCAL)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC)
BEGINCHECK |
IF | COND ('#STD_AMOUNT *EQ 0')
SET_ERROR | FOR_FIELD(#STD_AMNT) MSGTXT('Amount cannot be zero.')
ENDIF |
RANGECHECK | FIELD(#STD_AMNT) RANGE((-5000 5000)) MSGTXT('Amount must be in range -5000 to 5000.')A
ENDCHECK |
CHANGE | FIELD(#iiiAMOUNT) TO(#STD_AMNT)
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03)
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |

6. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your new function.

Because of the newly added GROUP_BY, the iiiAMOUNT field appears on the display along with the STD_AMNT. In the next step, you will hide the iiiAMOUNT field.

e. Do not enter any data in the fields

f. Press Enter.

g. Add some valid data

h. Press Enter to add a new record.

  • Notice that all the fields are displayed as their defaults after the record is added.

i. Press F12 to exit function.


Step 5. Hide the iiiAMOUNT Field

LFA_F10 A Simple Add Function

In this step, you will modify the function so that the iiiAMOUNT field is not shown on the display.

1. Edit the RDML commands in your function iiiFN13 Add Section Data.

2. Modify the GROUP_BY command and add a *HIDDEN attribute to the iiiAMOUNT field. Your final RDML function should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#ADDDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #STD_AMNT (#iiiAMOUNT *HIDDEN) #iiiAREAC #iiiLOCAL)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC)
BEGINCHECK |
IF | COND('#STD_AMOUNT *EQ 0')
SET_ERROR | FOR_FIELD(#STD_AMNT) MSGTXT('Amount cannot be zero.')
ENDIF |
RANGECHECK | FIELD(#STD_AMNT) RANGE((-5000 5000)) MSGTXT('Amount must be in range -5000 to 5000.')
ENDCHECK |
CHANGE | FIELD(#iiiAMOUNT) TO(#STD_AMNT)
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03)
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |

3. Save and check the RDML. Make any corrections as required.

4. Exit the editor. Compile the function.

5. Execute and test your new function. The iiiAMOUNT field should no longer be displayed.


Step 6. Compare to iiiFN11

LFA_F10 A Simple Add Function

1. Compare the RDML code in the function you have just created with the RDML code in the iiiFN11 Add Section function which is based on the FRADD01 template.

2. You will notice that the structure of the code in these functions is very similar. Some minor changes and additions were made to highlight features of LANSA RDML.


Summary

What You Should Know

  • You should be familiar with the following commands:
  • FUNCTION
  • MESSAGE
  • REQUEST
  • INSERT
  • IF
  • BEGINCHECK
  • ENDCHECK
  • CONDCHECK
  • RANGECHECK
  • VALUECHECK
  • SET_ERROR
  • BEGIN_LOOP/END_LOOP
  • GROUP_BY
  • CHANGE

Other Tutorials

LFA_F20 Create a Maintenance Function

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_F20 Create a Maintenance Function

Objectives:

  • To develop the code for a maintenance function (similar to the code from the FRMNT01 template).
  • To highlight how functions interact with the menu, other functions, and subroutines within a function.
  • To introduce the concept of modes for data entry.
  • To introduce the FETCH, UPDATE and DELETE database commands.
  • To introduce the following RDML commands:
  • FETCH
  • DISPLAY
  • IF_KEY
  • EXECUTE
  • SUBROUTINE
  • ENDROUNTINE
  • CALL
  • IF_MODE
  • IF_STATUS
  • UPDATE
  • DELETE.

To achieve these objectives you must complete the following:

  • Step 1. Create a Simple Display Function
  • Step 2. File Error Checking
  • Step 3. Allow Data Entry Using a Subroutine
  • Step 4. Allow Add, Change and Delete
  • Step 5. Correct the Modes in the Maintenance Function
  • Step 6. Compare to iiiFN05
  • Summary

Very Important Note:
Depending upon the response time for your iSeries, you may wish to only compile the final version of the function. If your iSeries takes 5 or 10 minutes to compile a function, do not compile the function at the end of each step.


Step 1. Create a Simple Display Function

LFA_F20 Create a Maintenance Function

In this step, you will create a very simple function which requests a department code and section code, and then displays the requested record from the iiiFIL03 Section file. The fields displayed will include: #iiiDEPT, #iiiDEPPJF, #iiiSECT, #iiiSECDSC, #SECADDR1, #SECADDR2, #SECADDR3, #SECPCODE, #iiiDATE, #iiiAMOUNT, #iiiTAXAMT, #iiiAREAC, #iiiLOCAL, #iiiDATEDM. The basic structure of the function will be as follows:

Group the display fields

Begin loop

Request the Department and Section Code

Fetch the field group from iiiFIL03 using the Department and Section Code as the key

(issue a message if not found)

Display the field group

End loop

1. Create a new function iiiFN14 Maintain Section Data in your iiiPRO04 process. The function should be manually defined.

2. Try to create the RDML code based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiDATE #iiiAMOUNT #iiiTAXAMT #iiiAREAC #iiiLOCAL #iiiDATEDM)
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
FETCH | FIELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) ISSUE_MSG(*YES)
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC)
END_LOOP |

4. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your new function.

e. Enter a valid department and section code to display the data from the file section.

f. Enter a blank department and section. You know that no record will be found.

  • Notice that an error message is displayed indicating that the record was not found, but the fields are still displayed. (This data is the previous record fetched from the file.) In the next step, you will validate the data before executing the fetch.

g. Enter an invalid department and section code.

  • Again, an error message will be displayed along with the previous data. In the next step, you will make sure that the record is not displayed unless found.

h. Exit the function.


Step 2. File Error Checking

LFA_F20 Create a Maintenance Function

In this step, you will modify the function as follows:

  • Use a BEGINCHECK and ENDCHECK with a CONDCHECK and VALUECHECK to test that the requested department and section codes are not blank.
  • After the FETCH, use a BEGINCHECK and ENDCHECK to control the routing if the FETCH fails to find a valid record. Use the IF_STATUS and SET_ERROR commands within the BEGINCHECK and ENDCHECK loop. Remove the ISSUE_MSG(*YES) from the FETCH statement.

1. Edit the RDML commands in your function iiiFN14 Maintain Section Data.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiDATE #iiiAMOUNT #iiiTAXAMT #iiiAREAC #iiiLOCAL #iiiDATEDM)
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
BEGINCHECK |
CONDCHECK | FIELD(#iiiDEPT) COND('(#iiiDEPT *EQ *BLANKS)') IF_TRUE(*ERROR) IF_FALSE(*NEXT) MSGTXT('Department Code must be entered.')
VALUECHECK | FIELD(#iiiSECT) WITH_LIST(*BLANK) IN_LIST(*ERROR) NOT_INLIST(*NEXT) MSGTXT('Section Code must be entered.')
ENDCHECK |
FETCH | FIELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT)
BEGINCHECK |
IF_STATUS | IS(*NORECORD)
SET_ERROR | FOR_FIELD(#iiiDEPT #iiiSECT) MSGTXT('Department/Section not found.')
ENDIF |
ENDCHECK |
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC)
END_LOOP |

4. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your new function.

e. Enter a valid department and section code to display the data from the file section.

f. Enter a blank department and section code.

  • Notice that an error message is displayed and you return to the request panel.

g. Enter an invalid department and section code.

  • Notice that an error message is displayed that the record was not found and that you return to the request panel with the department and section fields highlighted.


Step 3. Allow Data Entry Using a Subroutine

LFA_F20 Create a Maintenance Function

In this step, you will modify the function to allow the user to enter data, as well as to display data. You will need to make the following changes:

  • Enable the Add function key on the REQUEST panel.
  • If the user has pressed Add, then execute an ADDRECORD subroutine.
  • Create an ADDRECORD subroutine which requests data and adds it to the Section file. The ADDRECORD subroutine is very simple to code. It is simply the code you created for the iiiFN13 function.

1. Edit the RDML commands in your function iiiFN14 Maintain Section Data.

2. Try to make the necessary RDML code changes based on the function description above.

Tip: For the RDML code in the subroutine, use the editor action code EF to copy RDML code from function iiiFN13 Add Section Data.)

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiDATE #iiiAMOUNT #iiiTAXAMT #iiiAREAC #iiiLOCAL #iiiDATEDM)
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC) ADD_KEY(*YES)
IF_KEY | WAS(*ADD)
EXECUTE | SUBROUTINE(ADDRECORD)
ELSE |
BEGINCHECK |
CONDCHECK | FIELD(#iiiDEPT) COND('(#iiiDEPT *EQ *BLANKS)') IF_TRUE(*ERROR) IF_FALSE(*NEXT) MSGTXT('Department Code must be entered.')
VALUECHECK | FIELD(#iiiSECT) WITH_LIST(*BLANK) IN_LIST(*ERROR) NOT_INLIST(*NEXT) MSGTXT('Section Code must be entered.')
ENDCHECK |
FETCH | FIELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT)
BEGINCHECK |
IF_STATUS | IS(*NORECORD)
SET_ERROR | FOR_FIELD(#iiiDEPT #iiiSECT) MSGTXT('Department/Section not found.')
ENDIF |
ENDCHECK |
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC)
ENDIF |
END_LOOP |
SUBROUTINE | NAME(ADDRECORD)
GROUP_BY | NAME(#ADDDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiAMOUNT #iiiAREAC #iiiLOCAL)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC)
BEGINCHECK |
ENDCHECK |
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03)
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |
ENDROUTINE |

Note: In the example above, the code from iiiFN13 was copied and then simplified. The use of STD_AMNT and the related CONDCHECK and RANGECHECK were removed from the subroutine since they are not needed. The BEGINCHECK and ENDCHECK are not removed since it is good programming practice to include these types of commands.

4. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your new function.

e. Enter a department and section code and display the record.

f. Press Enter to return to the request panel.

g. Press F6 to add a new record in the Section file.

  • Notice that the information from the previous record displayed is shown in the data entry fields. You would expect the fields to display their default values.

h. Press F12 to exit the ADDROUTINE.

  • Notice that you completely exit the function. What parameter do you think needs to be changed on the REQUEST so that you return to the mainline function?

i. Execute the function again.

j. Display a record.

  • Notice that you cannot add a record from the display panel. In the next step, you will be able to add, change and delete from this panel.


Step 4. Allow Add, Change and Delete

LFA_F20 Create a Maintenance Function

In this step, you will modify the function to allow the user to add, change and delete data. To complete these tasks, you will begin to use modes for your display. You will need to make the following changes.

  • Enable the Add, Change and Delete function keys on the DISPLAY panel.
  • Use an IF_MODE command to determine the mode of the display and then perform the appropriate action. If the mode is *ADD, call the iiiFN11 Add Section function. If the mode is *DELETE, delete the record displayed. If *CHANGE, update the record displayed. Display appropriate messages after the data access.
  • As noted in the last step, update the MENU_KEY option on the REQUEST panel in the ADDRECORD subroutine so that the subroutine returns to the mainline function.
  • As noted in the last step, move the CHANGE FIELDS(#ADDDATA) TO (*DEFAULT) before the REQUEST so that the fields are set to their defaults when the panel is first displayed.

1. Edit the RDML commands in your function iiiFN14 Maintain Section Data.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#PANELDATA) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiDATE #iiiAMOUNT #iiiTAXAMT #iiiAREAC #iiiLOCAL #iiiDATEDM)
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC) ADD_KEY(*YES)
IF_KEY | WAS(*ADD)
EXECUTE | SUBROUTINE(ADDRECORD)
ELSE |
BEGINCHECK |
CONDCHECK | FIELD(#iiiDEPT) COND('(#iiiDEPT *EQ *BLANKS)') IF_TRUE(*ERROR) IF_FALSE(*NEXT) MSGTXT('Department Code must be entered.')
VALUECHECK | FIELD(#iiiSECT) WITH_LIST(*BLANK) IN_LIST(*ERROR) NOT_INLIST(*NEXT) MSGTXT('Section Code must be entered.')
ENDCHECK |
FETCH | FIELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT)
BEGINCHECK |
IF_STATUS | IS(*NORECORD)
SET_ERROR | FOR_FIELD(#iiiDEPT #iiiSECT) MSGTXT('Department/Section not found.')
ENDIF |
ENDCHECK |
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC) ADD_KEY(*YES) CHANGE_KEY(*YES) DELETE_KEY(*YES)
IF_MODE | IS(*ADD)
CALL | PROCESS(*DIRECT) FUNCTION(iiiFN11)
ENDIF |
IF_MODE | IS(*CHANGE)
UPDATE | FIELDS(#PANELDATA) IN_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully changed in the Section File.')
ENDIF |
IF_MODE | IS(*DELETE)
DELETE | FROM_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully deleted from the Section File.')
ENDIF |
ENDIF |
END_LOOP |
SUBROUTINE | NAME(ADDRECORD)
GROUP_BY | NAME(#ADDDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiAMOUNT #iiiAREAC #iiiLOCAL)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC) MENU_KEY(*YES *RETURN)
BEGINCHECK |
ENDCHECK |
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |
ENDROUTINE |

4. Optional:

a. Save the RDML.

b. Exit the editor .

c. Compile the function.

d. Execute your new function.

e. Enter a valid department and section code and display the record.

  • Notice that the Change and Delete options are now available.

f. Press F21 to change some data.

  • Notice that all the fields are input capable; however, some fields should not be input capable. You will correct this in the next step.

g. Press Enter to perform the update.

h. Enter another valid department and section code, and then display the record.

  • Notice that the record is still displayed in CHANGE mode; however, the record should simply be displayed. You will also correct this in the next step.

i. Exit the function.

j. Execute the function again.

k. Press F6 and add a new record to the Section file. You are executing the ADDRECORD subroutine.

Check that the fields are displayed as their defaults.

l. Press F12 to ensure that you have returned to the department and section code request panel instead of exiting the function.

m. Enter a valid department and section code, and then display the record.

  • Notice that the record is being displayed in ADD mode. Again, the record should simply be displayed. You will correct this in the next step.

n. Press Enter. You will see the iiiFN11 function being executed. If you are unsure why this is occurring, execute in debug mode and follow the RDML execution.

o. Exit the function, and execute the function again.

p. Enter a valid department and section code, and then display the record.

q. Press F6 to add a new record in the Section file. You are executing the iiiFN11 function.

r. Add a new record.

s. Press F12 to exit the iiiFN11 function.

  • Notice that you return to the process menu. It would be better if you were returned to the calling function.

t. Execute the function again.

u. Enter a valid department and section code, and then display the record. Press F22 and delete the record from the Section file.

v. Exit the function.


Step 5. Correct the Modes in the Maintenance Function

LFA_F20 Create a Maintenance Function

In this step, you will modify the function to correct the problems identified in the previous step. You will need to make the following changes:

  • Make sure that the DISPLAY panel is set to the correct mode by including a SET_MODE command before the DISPLAY statement.
  • When in CHANGE mode, set the field attributes so that the correct fields are input capable, i.e. iiiDEPT, iiiDEPPJF, iiiSECT, iiiDATE, iiiTAXAMT and iiiDATEDM should not be input capable.
  • As noted in the last step, update the routing so that the iiiFN11 returns control to the calling function instead of exiting to the menu.

1. Edit the RDML commands in your function iiiFN14 Maintain Section Data.

2. Include the following command immediately before the RDML DISPLAY command:

SET_MODE TO(*DISPLAY)

3. Modify the GROUP_BY command so that the following attributes are set:

GROUP_BY NAME(#PANELDATA) FIELDS((#iiiDEPT *NOCHG)(#iiiDEPPJF *OUTPUT) (#iiiSECT *NOCHG) #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE (#iiiDATE *HIDDEN) #iiiAMOUNT (#iiiTAXAMT *OUTPUT) #iiiAREAC #iiiLOCAL (#iiiDATEDM *OUTPUT))

4. Change the MENU_USED option in the CALL command:

CALL PROCESS(*DIRECT) FUNCTION(iiiFN11) MENU_USED(*NEXT)

5. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#PANELDATA) FIELDS((#iiiDEPT *NOCHG)(#iiiDEPPJF *OUTPUT) (#iiiSECT *NOCHG) #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE (#iiiDATE *HIDDEN) #iiiAMOUNT (#iiiTAXAMT *OUTPUT) #iiiAREAC #iiiLOCAL (#iiiDATEDM *OUTPUT))
BEGIN_LOOP |
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC) ADD_KEY(*YES)
IF_KEY | WAS(*ADD)
EXECUTE | SUBROUTINE(ADDRECORD)
ELSE |
BEGINCHECK |
CONDCHECK | FIELD(#iiiDEPT) COND('(#iiiDEPT *EQ *BLANKS)') IF_TRUE(*ERROR) IF_FALSE(*NEXT) MSGTXT('Department Code must be entered.')
VALUECHECK | FIELD(#iiiSECT) WITH_LIST(*BLANK) IN_LIST(*ERROR) NOT_INLIST(*NEXT) MSGTXT('Section Code must be entered.')
ENDCHECK |
FETCH F | IELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT)
BEGINCHECK |
IF_STATUS | IS(*NORECORD)
SET_ERROR | FOR_FIELD(#iiiDEPT #iiiSECT) MSGTXT('Department/Section not found.')
ENDIF |
ENDCHECK |
SET_MODE | TO(*DISPLAY)
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC) ADD_KEY(*YES) CHANGE_KEY(*YES) DELETE_KEY(*YES)
IF_MODE | IS(*ADD)
CALL | PROCESS(*DIRECT) FUNCTION(iiiFN11) MENU_USED(*NEXT)
ENDIF |
IF_MODE | IS(*CHANGE)
UPDATE | FIELDS(#PANELDATA) IN_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully changed in the Section File.')
ENDIF |
IF_MODE | IS(*DELETE)
DELETE | FROM_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully deleted from the Section File.')
ENDIF |
ENDIF |
END_LOOP |
SUBROUTINE | NAME(ADDRECORD)
GROUP_BY | NAME(#ADDDATA) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiAMOUNT #iiiAREAC #iiiLOCAL)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC) MENU_KEY(*YES *RETURN)
BEGINCHECK |
ENDCHECK |
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |
ENDROUTINE |

6. Save the RDML.

7. Exit the editor.

8. Compile the function.

9. Execute your function.

a. Enter a valid department and section code and display the record.

b. Press F21 to change some data. Notice that the *OUTPUT and *NOCHG fields are not input capable.

c. Display a record to check that the mode has been properly reset to *DISPLAY.

d. Press F6 so that iiiFN11 function is called. Press F12 to check that you are returned to the iiiFN14 function instead of the process menu.

10. Following are some things you should notice:

  • The SET_MODE command makes sure the proper mode is set each time a record is displayed. It is a programmatic change to the mode in the function. When the user presses add or change or delete, an equivalent operation to a SET_MODE command is automatically performed.
  • The field attributes are directly linked to the mode of the display. Specifying *OUTPUT or *NOCHG indicates that the user cannot enter data for these fields. These attributes do not impact database access commands such as FETCH, UPDATE, INSERT or DELETE.
  • When calling the iiiFN11 Add Section function, you specified MENU_USED(*NEXT). This option specifies that when the user cancels from the called function, the next RDML statement is executed. The default was *MENU which would cause the calling function to return to the menu instead of continuing to execute.


Step 6. Compare to iiiFN05

LFA_F20 Create a Maintenance Function

1. Compare the RDML code in the function you have just created with the RDML code in the iiiFN05 Section Maintenance function which is based on the FRMNT01 template.

  • You will notice that the structure of the code in these functions is very similar. Some changes and additions were made to highlight features of LANSA RDML.
  • Summary

What You Should Know

  • You should be familiar with the following commands:
  • DISPLAY
  • FETCH
  • UPDATE
  • DELETE
  • EXECUTE
  • SUBROUTINE
  • ENDROUTINE
  • CALL
  • IF_KEY
  • IF_MODE
  • IF_STATUS.

Other Tutorials

LFA_F30 Create a POPUP Function

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_F30 Create a POPUP Function

Objectives:

  • To develop the code for a popup prompter function (similar to the code from the FRPOP01 template).
  • To introduce the POP_UP command. POP_UP commands are used to display the popup windows used for the department and section prompts.
  • To introduce lists and list concepts used in LANSA functions.
  • To introduce the following RDML commands:
  • DEFINE
  • DEF_LIST
  • CLR_LIST
  • ADD_ENTRY
  • GET_ENTRY
  • SELECT
  • ENDSELECT
  • POP_UP
  • DOUNTIL
  • EXCHANGE
  • MENU
  • LEAVE.

To achieve these objectives you must complete the following:

  • Step 1. Execute a Popup Prompt
  • Step 2. Create a New Field in the Repository
  • Step 3. Create a Simple Popup Function
  • Step 4. Select Data and Add to the List
  • Step 5. Exchanging Information
  • Step 6. Retrieve the Selected Record
  • Step 7. Loop Until a Selection is Made
  • Step 8. Compare to iiiFN07
  • Summary

Very Important Note:
Depending upon the response time for your iSeries, you may wish to only compile the final version of the function. If your iSeries takes 5 or 10 minutes to compile a function, do not compile the function at the end of each step.


Step 1. Execute a Popup Prompt

LFA_F30 Create a POPUP Function

1. Execute your iiiFN13Section Maintenance function.

2. Prompt on the section code. Notice how a list of all sections with an amount greater than 0 is displayed. Remember, the prompt function is defined as part of the field definition in the repository. The iiiSECT field calls the iiiFN07Section Greater Than 0 prompt function.

3. Select a section. Notice how the department and section codes are returned to the function which called the prompt.

4. You will now create a prompt function which is based on the POP_UP command. The code you will create is very similar to the FRPOP01 template used to create the iiiFN07 Sectionprompt function.


Step 2. Create a New Field in the Repository

LFA_F30 Create a POPUP Function

If a field is being used on a display panel, it should always be defined in the repository. In Step 3, youwill add a new field which youwill use to count the number of sections in a department.

1. Create a new field in the repository with the following characteristics:

Field name: | iiiCOUNT
Description: | Section Count
Type: | Signed
Length: | 3
Decimals: | 0
Edit Code: | 3

2. Add some help text for this field. (This field will be used to display the total number of sections in a department.)


Step 3. Create a Simple Popup Function

LFA_F30 Create a POPUP Function

In this step, you will create a simple popup window which displays a list of department and section codes, and their descriptions based on the data from the iiiFIL03 Section file. The basic structure of the function will be as follows:

Define a list of fields

Clear the list

Select records from the Section file

Add the records to the list

End the selection loop

Popup a window with the list of records

Return to the calling function

1. Create a new function iiiFN15 Section Prompt in the iiiPRO04 process. The function should be manually defined.

2. Define your RDML code as follows:

a. Include a FUNCTION statement with *DIRECT and *CLOSE_DISPLAY. For details, refer to the *CLOSE_DISPLAY parameter in the iSeries Technical Reference Guide.

FUNCTION OPTIONS(*DIRECT *CLOSE_DISPLAY)

b. Define a browse list with 100 entries. It should include the iiiDEPT, iiiSECT, iiiSECDSC and iiiAMOUNT fields. Specify that the iiiCOUNT field will be used as the list counter. (You should have already defined iiiCOUNT in the repository in a previous tutorial.)

DEF_LIST NAME(#iiiLIST) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) COUNTER(#iiiCOUNT) ENTRYS(100)

c. Clear the list to make sure that all entries are blank.

CLR_LIST NAMED(#iiiLIST)

d. Display a popup at row 5, column 22. The popup will show the iiiCOUNT field and the empty list.

POP_UP FIELDS(#iiiCOUNT) AT_LOC(5 22) BROWSELIST(#iiiLIST)

e. Return to the menu.

MENU

3. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

4. Modify the field definition for the iiiSECT field. Change the Prompting Function to use your iiiFN15Section Prompt.

5. Optional: Execute your iiiFN13 Add Section function.

a. Prompt on the Section Code to invoke your iiiFN15 function.

  • Notice that a popup window appears with no data. The Section Count should be 0 since no records are in the list.

b. Cancel the prompt function.

c. Exit the process.


Step 4. Select Data and Add to the List

LFA_F30 Create a POPUP Function

1. Add a SELECT/ENDSELECT loop to your function which reads all records from the iiiFIL03 Section file. As you loop through the records, add them to the list.

2. Your code will appear as follows:

FUNCTION | OPTIONS(*DIRECT *CLOSE_DISPLAY)
DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) COUNTER(#iiiCOUNT) ENTRYS(100)
CLR_LIST | NAMED(#iiiLIST)
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
POP_UP | FIELDS(#iiiCOUNT) AT_LOC(5 22) BROWSELIST(#iiiLIST)
MENU |

3. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function. Execute your iiiFN13 Add Section function.

d. Prompt on the Section Code to invoke your iiiFN15 function.

The popup window should list all of the data in the Section file. The Section Count should indicate the number of records in the list.

e. Select one of the sections in the list.

  • Notice that the values of the department and section code are not returned to the calling function. You will add this functionality in the next step.

f. Exit the process.


Step 5. Exchanging Information

LFA_F30 Create a POPUP Function

You will modify the function as follows:

  • Modify the options in the POPUP command so that the Prompt and Exit keys are not allowed.
  • Allow the iiiDEPT and iiiSECT fields to be exchanged between functions.

1. Edit the RDML commands in your function iiiFN15 Section Prompt.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT *CLOSE_DISPLAY)
DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) COUNTER(#iiiCOUNT) ENTRYS(100)
CLR_LIST | NAMED(#iiiLIST)
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
POP_UP | FIELDS(#iiiCOUNT) AT_LOC(5 22) BROWSELIST(#iiiLIST) EXIT_KEY(*NO) PROMPT_KEY(*NO)
EXCHANGE | FIELDS(#iiiDEPT #iiiSECT)
MENU |

4. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your iiiFN13 Add Section function.

e. Prompt on the Section Code to invoke your iiiFN15 function. Make note of the last record in the list.

f. Select a record from the popup window. Notice that the value returned to the calling function is the last record in the file. In the next step, you will add logic to retrieve the correct data from the list.

g. Exit the process.


Step 6. Retrieve the Selected Record

LFA_F30 Create a POPUP Function

You will modify the function as follows:

  • DEFINE a new working field called ENTRYNUM which will be used to store the entry number of the item selected in the list. The field will be P(7,0).
  • Modify the DEF_LIST to update the newly defined ENTRYNUM field.
  • Use the GET_ENTRY command to get the selected entry in the list so it can be exchanged with the calling function.

1. Edit the RDML commands in your function iiiFN15Section Prompt.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT *CLOSE_DISPLAY)
DEFINE | FIELD(#ENTRYNUM) TYPE(*DEC) LENGTH(7) DECIMALS(0)
DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) COUNTER(#iiiCOUNT) ENTRYS(100) SEL_ENTRY(#ENTRYNUM)
CLR_LIST | NAMED(#iiiLIST)
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
POP_UP | FIELDS(#iiiCOUNT) AT_LOC(5 22) BROWSELIST(#iiiLIST) EXIT_KEY(*NO) PROMPT_KEY(*NO)
GET_ENTRY | NUMBER(#ENTRYNUM) FROM_LIST(#iiiLIST)
EXCHANGE | FIELDS(#iiiDEPT #iiiSECT)
MENU |

4. Optional:

a. Save the RDML.

b. Exit the editor .

c. Compile the function.

d. Execute your iiiFN13 Add Section function.

e. Prompt on the Section Code to invoke your iiiFN15 function.

f. Select a record from the popup window. The value should be properly returned.

g. Prompt on the Section Code to invoke your iiiFN15 function again. Make note of the last record in the list.

h. This time simply press Enter.

  • Notice that the value returned to the calling function is the last record in the file. In the next step, you will add logic to check that a record was selected before returning to the calling function.


Step 7. Loop Until a Selection is Made

LFA_F30 Create a POPUP Function

You will modify the function as follows:

  • Add a DOUNTIL/ENDUNTIL loop which checks if the user has selected an item in the list, i.e. the ENTRYNUM is not zero.
  • If the user does not select a record and has pressed Enter, display a message to select a record or press Cancel.

1. Edit the RDML commands in your function iiiFN15Section Prompt.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT *CLOSE_DISPLAY)
DEFINE | FIELD(#ENTRYNUM) TYPE(*DEC) LENGTH(7) DECIMALS(0)
DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT) COUNTER(#iiiCOUNT) ENTRYS(100) SEL_ENTRY(#ENTRYNUM)
CLR_LIST | NAMED(#iiiLIST)
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
DOUNTIL | COND('#ENTRYNUM *GT 0')
POP_UP | FIELDS(#iiiCOUNT) AT_LOC(5 22) BROWSELIST(#iiiLIST) EXIT_KEY(*NO) PROMPT_KEY(*NO)
IF | COND('#ENTRYNUM *EQ 0')
MESSAGE | MSGTXT('Select an entry from the list or use Cancel.')
ENDIF |
ENDUNTIL |
GET_ENTRY | NUMBER(#ENTRYNUM) FROM_LIST(#iiiLIST)
EXCHANGE | FIELDS(#iiiDEPT #iiiSECT)
MENU |

5. Save the RDML. Exit the editor . Compile the function. Execute your iiiFN13 Add Section function.

6. Prompt on the Section Code to invoke your iiiFN15 function.

7. Test your changes.


Step 8. Compare to iiiFN07

LFA_F30 Create a POPUP Function

1. Compare the RDML code in the function you have just created with the RDML code in the iiiFN07 Section Prompt function which is based on the FRPOP01 template.

2. You will notice that the structure of the code in these functions is very similar. Some changes and additions were made to highlight features of LANSA's RDML.

  • Summary

What You Should Know

  • You should be familiar with the following commands:
  • DEFINE
  • DEF_LIST
  • CLR_LIST
  • ADD_ENTRY
  • GET_ENTRY
  • SELECT
  • ENDSELECT
  • POP_UP
  • DOUNTIL
  • EXCHANGE
  • MENU
  • LEAVE.

Other Tutorials

LFA_F40 Create a Header / Detail Function

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_F40 Create a Header / Detail Function

Objectives:

  • To highlight the use of browse lists with the DISPLAY command.
  • To summarize the RDML commands you have used in the first three exercises.
  • To allow you to develop an application function on your own.

To achieve these objectives you must complete the following:

  • Step 1. Design Specification
  • Step 2. Create Your Function
  • Step 3. Test Your Function
  • Step 4. Compare Your Function to the Solution
  • Step 5. Include a Detailed Display Screen (Optional)
  • Step 6. Allow More Than One Record to be Selected (Optional)
  • Summary


Step 1. Design Specification

LFA_F40 Create a Header / Detail Function

You will create a function which requests a department code from the user and then displays the department details along with a list of the sections in the department. The user will be allowed to select sections from the list to display full details of a section.

The function will appear something like the following:

  • Notice that the header section of the display contains the iiiDEPT and iiiDEPDSC fields.
  • Notice that the list of field contains the iiiSECT, iiiSECDSC and iiiAMOUNT fields.
  • Also notice the buttons which are supported on each screen.
  • Your function might use some or all of the following commands:
  • ADD_ENTRY
  • BEGIN_LOOP
  • BEGINCHECK
  • CHANGE
  • CLR_LIST
  • DEF_LIST
  • DISPLAY
  • END_LOOP
  • ENDCHECK
  • ENDIF
  • ENDSELECT
  • FETCH
  • FUNCTION
  • GROUP_BY
  • IF_STATUS
  • REQUEST
  • SELECT
  • SET_ERROR

Your first set of RDML code should perform the following tasks:

-Specify the function characteristics

-Group fields for the header area of the display

-Define a list of fields to be used in the display

-Begin a Loop

-Change the header fields to their defaults

-Clear the list

-Request the Department Code

-Fetch the header fields from the department file by using the Department Code

-Begin Validations

-If the I/O Status is no record found

-Set an error on the department code

-Display a message that 'Department was not found.'

-End If Condition

-End Validations

-Select the list of fields from the Section file by using the Department Code as the key

-Add an Entry to the list

-End Select Loop

-Display the header fields and list of fields

-End a Loop


Step 2. Create Your Function

LFA_F40 Create a Header / Detail Function

1. Create a new function called iiiFN16 Department/Section Inquiry. This function should be part of your iiiPRO04 process.

2. Using the information provided in Step 1, create the RDML code for the function.

3. Refer back to previous exercises in this tutorial and use the iSeries Technical Reference Guide to help develop the code.


Step 3. Test Your Function

LFA_F40 Create a Header / Detail Function

1. Execute your function. Be sure to test the following:

a. Enter a valid department code. Check the header and details values displayed.

b. Enter an invalid department code to test error checking when no record is found.

c. Display more than one department to check that both the header and lists are properly reset each time new information is being displayed.

d. Use the Cancel and Exit keys from both panels in the function.


Step 4. Compare Your Function to the Solution

LFA_F40 Create a Header / Detail Function

1. Following is one solution for this function:

FUNCTION | OPTIONS(*DIRECT)
GROUP_BY | NAME(#HEADER) FIELDS(#iiiDEPT #iiiDEPDSC)
DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiSECT #iiiSECDSC #iiiAMOUNT)
BEGIN_LOOP |
CHANGE | FIELD(#HEADER) TO(*DEFAULT)
CLR_LIST | NAMED(#iiiLIST)
REQUEST | FIELDS(#iiiDEPT) DESIGN(*DOWN) IDENTIFY(*DESC)
FETCH | FIELDS(#HEADER) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT)
BEGINCHECK |
IF_STATUS | IS(*NORECORD)
SET_ERROR | FOR_FIELD(#iiiDEPT) MSGTXT('Department was not found.')
ENDIF |
ENDCHECK |
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
DISPLAY | FIELDS(#HEADER) DESIGN(*DOWN) IDENTIFY(*DESC) BROWSELIST(#iiiLIST)
END_LOOP |

2. You may also execute the FRENQ02 Header/Detail Inquiry template. This template will produce the following RDML solution:

 | FUNCTION | OPTIONS(*NOMESSAGES *DEFERWRITE *DIRECT)
 | GROUP_BY | NAME(#HEADER) FIELDS(#iiiDEPT #iiiDEPDSC)
 | DEF_LIST | NAME(#LIST) FIELDS((#LISTDUMMY *HIDDEN) #iiiSECT #iiiSECDSC #iiiAMOUNT)
 | ********** | Loop until user EXITs or CANCELs
 | BEGIN_LOOP |
R10 | REQUEST | FIELDS(#iiiDEPT) DESIGN(*DOWN) IDENTIFY(*DESC)
 | ********** | Fetch file iiiFIL02 details
 | FETCH | FIELDS(#HEADER) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) NOT_FOUND(R10) ISSUE_MSG(*YES)
 | ********** | Select all file iiiFIL03 details
 | SELECT | FIELDS(#LIST) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT)
 | ADD_ENTRY | TO_LIST(#LIST)
 | ENDSELECT |
 | ********** | Display results to the user
 | DISPLAY | FIELDS(#HEADER) DESIGN(*DOWN) IDENTIFY(*DESC) BROWSELIST(#LIST)
 | ********** | Clear header and list and loop around
 | CHANGE | FIELD(#HEADER) TO(*DEFAULT)
 | CLR_LIST | NAMED(#LIST)
 | END_LOOP |


Step 5. Include a Detailed Display Screen (Optional)

LFA_F40 Create a Header / Detail Function

1. Modify the function so that it will perform the following:

  • Allow the user to select a single record from the list of sections.
  • If a record is selected, get the section code from the list.
  • Fetch the details of the selected section from the Section file.
  • If no record is found, (it could have been deleted by another user), display appropriate messages.
  • If a record is found, display another panel which shows all of the details of the section.
  • After the details are displayed, return to the list of sections to allow the user to select another item from the list.

2. Following are some tips:

  • You can use the #LISTENTRY field (which already exists in the repository) to store the selected entry from the list.
  • Use GROUP_BY commands to simplify your code.
  • Use a SUBROUTINE to help separate the displays and isolate the BEGIN_LOOP / END_LOOPS.
  • Remember the use of *RETURN and the RETURN command from within a SUBROUTINE.
  • Do not try to build the function all at once. Build the function one step at a time.

3. Following is one possible solution to this exercise: (There are many different ways of building this function.)

 | FUNCTION | OPTIONS(*DIRECT)
 | GROUP_BY | NAME(#HEADER) FIELDS(#iiiDEPT #iiiDEPDSC)
 | GROUP_BY | NAME(#DETAILS) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #SECPHBUS #iiiAREAC #iiiLOCAL #iiiDATE #iiiDATEDM #iiiAMOUNT #iiiTAXAMT)
 | DEF_LIST | NAME(#iiiLIST) FIELDS(#iiiSECT #iiiSECDSC #iiiAMOUNT) SEL_ENTRY(#LISTENTRY)
 | BEGIN_LOOP |
 | CHANGE | FIELD(#HEADER) TO(*DEFAULT)
 | CLR_LIST | NAMED(#iiiLIST)
 | REQUEST | FIELDS(#iiiDEPT) DESIGN(*DOWN) IDENTIFY(*DESC)
 | FETCH | FIELDS(#HEADER) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT)
 | BEGINCHECK |
 | IF_STATUS | IS(*NORECORD)
 | SET_ERROR | FOR_FIELD(#iiiDEPT) MSGTXT('Department was not found.')
 |  | ENDIF
 | ENDCHECK |
 | SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT)
 | ADD_ENTRY | TO_LIST(#iiiLIST)
 | ENDSELECT |
 | EXECUTE | SUBROUTINE(DISPSECT)
 | END_LOOP |
 | SUBROUTINE | NAME(DISPSECT)
 | BEGIN_LOOP |
R10 | DISPLAY | FIELDS(#HEADER) DESIGN(*DOWN) IDENTIFY(*DESC) BROWSELIST(#iiiLIST) MENU_KEY(*YES *RETURN)
 | IF | COND('#LISTENTRY *GT 0')
 | GET_ENTRY | NUMBER(#LISTENTRY) FROM_LIST(#iiiLIST)
 | FETCH | FIELDS(#DETAILS) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NOT_FOUND(R10)
 | DISPLAY | FIELDS(#DETAILS) DESIGN(*DOWN) IDENTIFY(*DESC) EXIT_KEY(*NO) MENU_KEY(*YES *RETURN)
 | ELSE |
 | RETURN |
 | ENDIF |
 | END_LOOP |
 | ENDROUTINE |


Step 6. Allow More Than One Record to be Selected (Optional)

LFA_F40 Create a Header / Detail Function

In this step, you will use a new command, SELECTLIST. SELECTLIST allows you to read multiple records from a list just as SELECT allows you to read multiple records from a file. You will also use the *SELECT field attribute for a field defined in the DEF_LIST. The *SELECT attribute will be used with the SELECTLIST statement.

1. Modify the function so that it will perform the following:

  • Add a new field (one character) to the DEF_LIST which will allow the user to mark an item as selected. Give the field the *SELECT attribute.
  • Use SELECTLIST and ENDSELECT commands, (instead of the GET_ENTRY command), in order to process all of the records selected by the user.
  • If the fetch of a selected record is not found, then return to the function mainline to force the user to select a more current list of sections.
  • Remove the BEGIN_LOOP and ENDLOOP in the subroutine since the user can now select more than one record at a time. It is not necessary to redisplay the list of sections.

2. Following are some tips:

  • You can use the #SELECTOR field (which already exists in the repository) to act as the selection field. Be sure to make this the first field in the DEF_LIST.
  • Refer to SELECTLIST command in the iSeries Technical Reference Guide for details about the SELECTLIST command.
  • Remember to remove the SEL_ENTRY from the DEF_LIST.

3. Following is one possible solution to this exercise: (There are many different ways of building this function.)

 | FUNCTION | OPTIONS(*DIRECT)
 | GROUP_BY | NAME(#HEADER) FIELDS(#iiiDEPT #iiiDEPDSC)
 | GROUP_BY | NAME(#DETAILS) FIELDS(#iiiDEPT #iiiDEPPJF #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #SECPHBUS #iiiAREAC #iiiLOCAL #iiiDATE #iiiDATEDM #iiiAMOUNT #iiiTAXAMT)
 | DEF_LIST | NAME(#iiiLIST) FIELDS((#SELECTOR *SELECT) #iiiSECT #iiiSECDSC #iiiAMOUNT)
 | BEGIN_LOOP |
 | CHANGE | FIELD(#HEADER) TO(*DEFAULT)
 | CLR_LIST | NAMED(#iiiLIST)
 | REQUEST | FIELDS(#iiiDEPT) DESIGN(*DOWN) IDENTIFY(*DESC)
 | FETCH | FIELDS(#HEADER) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT)
 | BEGINCHECK |
 | IF_STATUS | IS(*NORECORD)
 | SET_ERROR | FOR_FIELD(#iiiDEPT) MSGTXT('Department was not found.')
 | ENDIF |
 | ENDCHECK |
 | SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT)
 | ADD_ENTRY | TO_LIST(#iiiLIST)
 | ENDSELECT |
 | EXECUTE | SUBROUTINE(DISPSECT)
 | END_LOOP |
 | SUBROUTINE | NAME(DISPSECT)
R10 | DISPLAY | FIELDS(#HEADER) DESIGN(*DOWN) IDENTIFY(*DESC) BROWSELIST(#iiiLIST) MENU_KEY(*YES *RETURN)
 | SELECTLIST | NAMED(#iiiLIST) GET_ENTRYS(*SELECT)
 | FETCH | FIELDS(#DETAILS) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NOT_FOUND(*RETURN) ISSUE_MSG(*YES)
 | DISPLAY | FIELDS(#DETAILS) DESIGN(*DOWN) IDENTIFY(*DESC) EXIT_KEY(*NO) MENU_KEY(*NO *RETURN)
 | ENDSELECT |
 | ENDROUTINE |


Summary

What You Should Know

  • How to create simple functions with LANSA.

Other Tutorials

LFA_F50 Create a Report Function

LFA_F60 Create a Trigger Function


LFA_F50 Create a Report Function

Objectives:

  • To highlight the RDML commands used to create a reporting function in LANSA.
  • To create a very simple report listing the sections in a department.
  • To introduce the following RDML commands:
  • DEF_LINE
  • DEF_HEAD
  • DEF_FOOT
  • DEF_BREAK
  • DEF_REPORT
  • PRINT
  • SKIP
  • SPACE
  • ENDPRINT
  • KEEP_xxxxx (KEEP_AVG, KEEP_COUNT, KEEP_MAX, KEEP_MIN, KEEP_TOTAL)
  • SUBMIT.

To achieve these objectives you must complete the following:

  • Step 1. Create a Simple List Style Report Using a Template
  • Step 2. Manually Create a Reporting Function
  • Step 3. Add a Header and Footer
  • Step 4. Keep Statistics and Print
  • Step 5. Add a Grand Total Line
  • Step 6. Allow the Report to Execute in Batch (Optional)
  • Step 7. Paint the Report (Optional)
  • Summary

Very Important Note:
Depending upon the response time for your iSeries, you may wish to only compile the final version of the function. If your iSeries takes 5 or 10 minutes to compile a function, do not compile the function at the end of each step.


Step 1. Create a Simple List Style Report Using a Template

LFA_F50 Create a Report Function

In this step, you will create a simple list style report on the Section file. The function will be created by executing a LANSA template. After you have reviewed the code and executed the template, you will code a similar reporting function.

1. Review the section on Producing Reports Using LANSA in the LANSA Technical Guide.

2. Create a new process iiiPRO006 Temporary Functions.

3. Create a new function iiiRPT Department Report in your iiiPRO06 process. The function should be created using the FRPRT01 List Style Report (with Generic Selection) template. Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question.

TEMPLATE QUESTION | ANSWER
Do you want this function to be part of an action-bar style process? | N
Enter the name of the primary file to be used by this template | iiiFIL03
Select related files | Select iiiFIL02.
Fields to appear in header line | Select iiiDEPT, iiiDEPDSC.
Fields to appear in detail line | Select iiiSECT, iiiSECDSC, iiiAMOUNT, iiiDATEDM.
Fields to trigger a new page | Select iiiDEPT.
Please specify a title for this report. | Section Listing
Do you want this report to run in batch? | Y

4. Open the editor to review the code created. The RDML should appear as follows:

FUNCTION | OPTIONS(*DEFERWRITE *DIRECT)
OPEN | USE_OPTION(*ONDEMAND)
GROUP_BY | NAME(#FETCHDATA) FIELDS(#iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM #iiiDEPT #iiiDEPDSC)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #DATE #TIME #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPDSC) TRIGGER_BY(*OVERFLOW #iiiDEPT) DESIGN(*DOWN)
DEF_LINE | NAME(#DET01) FIELDS(#iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
CHANGE | FIELD(#STD_TITLE) TO('''Section Listing''')
********** | If this program is running online
IF | COND('*JOBMODE = I')
********** | Request report print criteria)
REQUEST | FIELDS(#iiiDEPT #iiiSECT) DESIGN(*DOWN) IDENTIFY(*DESC)
********** | Submit batch run of this program
SUBMIT | PROCESS(#PROCESS) FUNCTION(#FUNCTION) EXCHANGE(#iiiDEPT #iiiSECT) JOB(#FUNCTION)
********** | Else, if this program is running in batch
ELSE |
********** | Select required iiiFIL03 details
SELECT | FIELDS(#FETCHDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
********** | Fetch file iiiFIL02 details
FETCH | FIELDS(#FETCHDATA) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) KEEP_LAST(1)
********** | Print the detail line
PRINT | LINE(#DET01
ENDSELECT |
********** | Finish all printing and end program
ENDPRINT |
ENDIF |

5. Save the RDML.

a. Exit the editor.

b. Compile the function.

c. Execute your new function.

  • If you do not enter a Department or Section, a list of all records in the Section file will be created. Enter a Department of ADM to list all Sections in the Administration department.

d. Execute your new function again.

e. Enter a Department of ADM and a section of 01.

f. Execute your new function again.

g. Enter a Department of T. You should see listings for both the TRN and TRVL departments.


Step 2. Manually Create a Reporting Function

LFA_F50 Create a Report Function

The finished report will appear something like the following:

Page . . . . . . 9999

Function . . . . xxxxxxx

Title . . . . . xxxxxxxxxxxxxxxxxx

Department . . . xxxx

Department Desc xxxxxxxxxxxxxxxxxxx

Section

Code Section Description Amount Date (D/M/Y)

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

Section Count 999 Total Amount 99,999,999,999.99cr

Date . . . 99/99/99 Time . . . . . 99:99:99 Page . . . 9999

Page . . . . . . 9999

Function . . . . xxxxxxx

Title . . . . . xxxxxxxxxxxxxxxxxx

Department . . . xxxx

Department Desc xxxxxxxxxxxxxxxxxxx

Section

Code Section Description Amount Date (D/M/Y)

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

Section Count 999 Total Amount 99,999,999,999.99cr

Grand Total 9,999,999,999,999.99cr

Date . . . 99/99/99 Time . . . . . 99:99:99 Page . . . 9999

A new page will be printed for each Department. A count of the sections and the total of the iiiAMOUNT field will be printed for each department. A grand total of all departments will be printed on the last page of the report. The report will be 80 characters wide and 66 lines long.

1. You will build the reporting function in small steps. In this step, you will code a reporting function which does the following:

-Define the report to be 66 lines long and 80 characters wide

-Define a report line (#DET01) containing iiiDEPT, iiiSECT, iiiSECDSC, iiiAMOUNT, and iiiDATEDM

-Request the Department Code and Section Code

-Select all records which generically match the Department Code and Section Code based on the number of keys entered

-Print the report line (#DET01)

-End the select loop

-End the print

2. Create a new function iiiFN17 Section Report in your iiiPRO04 process. The function should be manually defined.

3. Try to make the necessary RDML code changes based on the function description above.

4. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
DEF_REPORT | FORMSIZE(66 80)
DEF_LINE | NAME(#DET01) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
SELECT | FIELDS(#DET01) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
PRINT | LINE(#DET01)
ENDSELECT |
ENDPRINT |

5. Optional:

a. Save the RDML.

b. Exit the editor.

c. Compile the function.

d. Execute your new function.

e. Enter a Department of ADM to list all Sections in the Administration department.

f. Execute your new function again.

g. Enter a Department of T and leave the section blank.

h. Notice that there is no break when the department code changes. You will correct this in the next step.


Step 3. Add a Header and Footer

LFA_F50 Create a Report Function

In this step, you modify the function to include a header and footer. You will need to make the following changes:

  • Add a header to the report. Include the report page number (#REP1PAGE), function name (#FUNCTION), a title (#STD_TITLE),#iiiDEPT and the #iiiDEPDSC fields in the header. List the fields down the page. Specify that a new page should be printed whenever a page is full (i.e. each new page always has a header) and when the department code changes.
  • Change the #STD_TITLE field to be Section Report.
  • Add a footer to the report which lists the date (#DATE), time (#TIME), and report page number (REP1PAGE) across the bottom of the page.
  • In the SELECT loop, FETCH the iiiDEPDSC field from iiiFIL02 using the department code. Remember to include KEEP_LAST logic.

1. Edit the RDML commands in your function iiiFN17 Section Report.

2. Review the repository field definitions for the #REP1PAGE, #DATE, #TIME and #FUNCTION fields.

3. Try to make the necessary RDML code changes based on the function description above.

4. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
DEF_REPORT | FORMSIZE(66 80)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPDSC) TRIGGER_BY(*OVERFLOW #iiiDEPT) DESIGN(*DOWN)
DEF_FOOT | NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE | NAME(#DET01) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
CHANGE | FIELD(#STD_TITLE) TO('Section Report')
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
SELECT | FIELDS(#DET01) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
FETCH | FIELDS(#iiiDEPDSC) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) KEEP_LAST(1)
PRINT | LINE(#DET01)
ENDSELECT |
ENDPRINT |

5. Optional:

a. Save the RDML.

b. Exit the editor .

c. Compile the function.

d. Execute your new function.

e. Enter a department of T and leave the section blank.

f. Check that the report headers and footers properly appear.


Step 4. Keep Statistics and Print

LFA_F50 Create a Report Function

In this step, you will keep some statistics based on each department and define some report breaks.

  • Define a working field for the report called iiiTOTAL. The field should be P(11,2) with an edit code of A. Enter a label, column heading and description of Total Amount.
  • Define a report break which prints the iiiCOUNT and iiiTOTAL as a trailing break when the iiiDEPT code changes.
  • Keep track of the total of the iiiAMOUNT field in the iiiTOTAL field.
  • Keep a count of the different iiiSECT fields in the iiiCOUNT field. (iiiCOUNT was created in the Popup exercise).

1. Edit the RDML commands in your function iiiFN17 Section Report.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
DEFINE | FIELD(#iiiTOTAL) TYPE(*DEC) LENGTH(11) DECIMALS(2) LABEL('Total Amount') DESC('Total Amount') COLHDG('Total Amount') EDIT_CODE(A)
DEF_REPORT | FORMSIZE(66 80)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPDSC) TRIGGER_BY(*OVERFLOW #iiiDEPT) DESIGN(*DOWN)
DEF_FOOT | NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE | NAME(#DET01) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
DEF_BREAK | NAME(#BRK01) FIELDS(#iiiCOUNT #iiiTOTAL) TRIGGER_BY(#iiiDEPT)
CHANGE | FIELD(#STD_TITLE) TO('Section Report')
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
SELECT | FIELDS(#DET01) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
KEEP_TOTAL | OF_FIELD(#iiiAMOUNT) IN_FIELD(#iiiTOTAL) BY_FIELD(#iiiDEPT)
KEEP_COUNT | OF_FIELD(#iiiSECT) IN_FIELD(#iiiCOUNT) BY_FIELD(#iiiDEPT)
FETCH | FIELDS(#iiiDEPDSC) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) KEEP_LAST(1)
PRINT | LINE(#DET01)
ENDSELECT |
ENDPRINT |

4. Optional:

a. Save the RDML.

bExit the editor.

c. Compile the function.

d. Execute your new function.

e. Enter a department of T and leave the section blank.

f. Check that the break totals are properly printed and check that they are correct. Each department should have its own totals and a count of the sections.


Step 5. Add a Grand Total Line

LFA_F50 Create a Report Function

In this step, you will add the grand total of all departments displayed in the report and you will add a blank line between printed lines.

  • Define a working field for the report called GRANDTOT. The field should be P(15,2) with an edit code of A. Enter a label, column heading and description of Grand Total.
  • Define another report break which prints the GRANDTOT field.
  • Add another KEEP_TOTAL command to total iiiAMOUNT into the GRANDTOT field.
  • Add a blank line (SPACE) between each printed line.

1. Edit the RDML commands in your function iiiFN17 Section Report.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
DEFINE | FIELD(#iiiTOTAL) TYPE(*DEC) LENGTH(11) DECIMALS(2) LABEL('Total Amount') DESC('Total Amount') COLHDG('Total Amount') EDIT_CODE(A)
DEFINE | FIELD(#GRANDTOT) TYPE(*DEC) LENGTH(15) DECIMALS(2) LABEL('Grand Total') DESC('Grand Total') COLHDG('Grand Total') EDIT_CODE(A)
DEF_REPORT | FORMSIZE(66 80)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPDSC) TRIGGER_BY(*OVERFLOW #iiiDEPT) DESIGN(*DOWN)
DEF_FOOT | NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE | NAME(#DET01) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
DEF_BREAK | NAME(#BRK01) FIELDS(#iiiCOUNT #iiiTOTAL) TRIGGER_BY(#iiiDEPT)
DEF_BREAK | NAME(#BRK02) FIELDS(#GRANDTOT)
CHANGE | FIELD(#STD_TITLE) TO('Section Report')
REQUEST | FIELDS(#iiiDEPT #iiiSECT) IDENTIFY(*DESC)
SELECT | FIELDS(#DET01) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
KEEP_TOTAL | OF_FIELD(#iiiAMOUNT) IN_FIELD(#GRANDTOT)
KEEP_TOTAL | OF_FIELD(#iiiAMOUNT) IN_FIELD(#iiiTOTAL) BY_FIELD(#iiiDEPT)
KEEP_COUNT | OF_FIELD(#iiiSECT) IN_FIELD(#iiiCOUNT) BY_FIELD(#iiiDEPT)
FETCH | FIELDS(#iiiDEPDSC) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) KEEP_LAST(1)
PRINT | LINE(#DET01)
SPACE |
ENDSELECT |
ENDPRINT |

4. Save the RDML.

5. Exit the editor.

6. Compile the function.

7. Execute your new function.

8. Enter a department of T and leave the section blank. Check that the report grand total is correct and check that it appears in the proper location.


Step 6. Allow the Report to Execute in Batch (Optional)

LFA_F50 Create a Report Function

In this last step, you will change the function to execute the report to be produced in batch mode.

  • Use the system variable *JOBMODE to determine if the function is executing online or in batch mode.
  • If in online mode, request the department and section codes as normal and then submit the function for execution in batch.
  • If in batch mode, select the records and print the report as before.

1. Edit the RDML commands in your function iiiFN17 Section Report.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your RDML code should appear as follows:

FUNCTION | OPTIONS(*DIRECT)
DEFINE | FIELD(#iiiTOTAL) TYPE(*DEC) LENGTH(11) DECIMALS(2) LABEL('Total Amount') DESC('Total Amount') COLHDG('Total Amount') EDIT_CODE(A)
DEFINE | FIELD(#GRANDTOT) TYPE(*DEC) LENGTH(15) DECIMALS(2) LABEL('Grand Total') DESC('Grand Total') COLHDG('Grand Total') EDIT_CODE(A)
DEF_REPORT | FORMSIZE(66 80)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPDSC) TRIGGER_BY(*OVERFLOW #iiiDEPT) DESIGN(*DOWN)
DEF_FOOT | NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE | NAME(#DET01) FIELDS(#iiiDEPT #iiiSECT #iiiSECDSC #iiiAMOUNT #iiiDATEDM)
DEF_BREAK | NAME(#BRK01) FIELDS(#iiiCOUNT #iiiTOTAL) TRIGGER_BY(#iiiDEPT)
DEF_BREAK | NAME(#BRK02) FIELDS(#GRANDTOT)
CHANGE | FIELD(#STD_TITLE) TO('Section Report')
IF | COND('*JOBMODE = I')
REQUEST | FIELDS(#iiiDEPT #iiiSECT) DESIGN(*DOWN) IDENTIFY(*DESC)
SUBMIT | PROCESS(#PROCESS) FUNCTION(#FUNCTION) EXCHANGE(#iiiDEPT #iiiSECT) JOB(#FUNCTION)
ELSE |
SELECT | FIELDS(#DET01) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NBR_KEYS(*COMPUTE) GENERIC(*YES)
KEEP_TOTAL | OF_FIELD(#iiiAMOUNT) IN_FIELD(#GRANDTOT)
KEEP_TOTAL | OF_FIELD(#iiiAMOUNT) IN_FIELD(#iiiTOTAL) BY_FIELD(#iiiDEPT)
KEEP_COUNT | OF_FIELD(#iiiSECT) IN_FIELD(#iiiCOUNT) BY_FIELD(#iiiDEPT)
FETCH | FIELDS(#iiiDEPDSC) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) KEEP_LAST(1)
PRINT | LINE(#DET01)
SPACE |
ENDSELECT |
ENDPRINT |
ENDIF |


Step 7. Paint the Report (Optional)

LFA_F50 Create a Report Function

1. If you wish, you may paint the report using the Report Painter. The Report Painter is very similar to the LANSA Screen Painter and is accessed from the function editor.

  • Summary

What You Should Know

  • You should be familiar with the following commands:
  • DEF_LINE
  • DEF_HEAD
  • DEF_FOOT
  • DEF_BREAK
  • DEF_REPORT
  • PRINT
  • SKIP
  • SPACE
  • ENDPRINT
  • KEEP_xxxxx (KEEP_AVG, KEEP_COUNT, KEEP_MAX, KEEP_MIN, KEEP_TOTAL)
  • SUBMIT.

Other Tutorials

LFA_F60 Create a Trigger Function


LFA_F60 Create a Trigger Function

Objectives:

  • To highlight how trigger functions interact with the repository.
  • To use a template to create the skeleton of a trigger function.
  • To manually complete the coding of the RDML logic within a trigger function.
  • To introduce LANSA Built-In Functions (BIFs).
  • To introduce the following RDML commands:
  • CASE, WHEN, ENDCASE
  • ABORT
  • USE.

To achieve these objectives you must complete the following:

  • Step 1. Update the Trigger Definition in the Repository
  • Step 2. Create Trigger Function Using a Template
  • Step 3. Code the Trigger Logic
  • Step 4. Test The Trigger Function
  • Step 5. Remove the Trigger
  • Summary


Step 1. Update the Trigger Definition in the Repository

LFA_F60 Create a Trigger Function

In this step, you will update the trigger definition for the iiiFIL03 Section file. You will define a trigger which is called after a record is read and before it is updated. The trigger will only be called if iiiAMOUNT is less than 0.

The trigger function will perform the following tasks:

  • When a file whose amount is less than 0 is read, the amount will be changed to 0 before it is displayed to the user. This will force the user to re-enter the amount so that the record is updated, (since 0 is not a valid amount). It will also prevent any negative amounts from being displayed to the user.
  • When a file whose amount is less than 0 is updated, the amount will be converted to a character string and written to the SECADDR3 field.

1. From the Work with Files menu, review the Rules/Trigger for the iiiFIL03 Section file.

2. Add a trigger to the iiiAMOUNT field as follows:

User description of trigger: | Trigger Example
Trigger Function Name: | iiiFN18
Trigger Point(s): | After Read and Before Update
Trigger When: | iiiAMOUNT LT 0

3. Commit amendments and make the iiiFIL03 file operational.


Step 2. Create Trigger Function Using a Template

LFA_F60 Create a Trigger Function

In this step, you will execute a template to create a complete function skeleton for a file level trigger function.

1. Create a new function iiiFN18 Section Trigger in your iiiPRO04 process. The function should be created using a template.

2. When the Choose Template dialog box appears, scroll down and select the BBFILTRIG File Level Trigger Function template. Press Execute to start the template. The template will ask only one question as shown in the table below.

TEMPLATE QUESTION | ANSWER
What is the name of the file that the trigger is associated with? | iiiFIL03

3. Review the RDML code created. The RDML should appear as follows:

********** | =======================================================
********** | Copyright .....: (C) ASPECT COMPUTING PTY LTD, 1992
********** | Process .......: iiiPRO04
********** | Function ......: iiiFN18
********** | Type ..........: iiiFIL03 File Level Trigger
********** | Created by ....: PCXUSER
********** | Created on ....: 99/99/99 at 99:99:99
********** | Description ...: Section Trigger
********** | =======================================================
FUNCTION | OPTIONS(*DIRECT *NOMESSAGES *LIGHTUSAGE *MLOPTIMISE) RCV_LIST(#TRIG_LIST) TRIGGER(*FILE iiiFIL03)
********** | =======================================================
********** | Working fields, lists and groups
********** | =======================================================
********** | At entry #TRIG_LIST will contain 0,1 or 2
********** | entries representing current and previous
********** | record images of file iiiFIL03. Refer to the
********** | Technical Guide for details and examples.
********** | Do NOT define any fields in this list. They
********** | are automatically included by the compiler.
DEF_LIST | NAME(#TRIG_LIST) TYPE(*WORKING) ENTRYS(2)
********** | =======================================================
********** | Function Mainline : iiiFN18
********** | =======================================================
********** | Assume a "good" return initially
CHANGE | FIELD(#TRIG_RETC) TO(OK)
********** |
********** | >>> DELETE all "not defined" events from the <<<
********** | >>> the following CASE construct. (ie: Remove <<<
********** | >>> WHEN VALUE_IS commands that are not part <<<
********** | >>> of the definition of this trigger BEFORE <<<
********** | >>> specifying details of the events that are <<<
********** | >>> part of the definition of this trigger). <<<
********** | >>> This simplifies logic in this function <<<
********** | >>> and ensures an ABORT if someone attempts <<<
********** | >>> to cause it to be invoked during an event <<<
********** | >>> that it has not been set up to handle. <<<
********** |
CASE | OF_FIELD(#TRIG_OPER)
********** | Handle a before open event
WHEN | VALUE_IS('= BEFOPN')
********** | Handle an after open event
WHEN | VALUE_IS('= AFTOPN')
********** | Handle a before close event
WHEN | VALUE_IS('= BEFCLS')
********** | Handle an after close event
WHEN | VALUE_IS('= AFTCLS')
********** | Handle a before read event
WHEN | VALUE_IS('= BEFRED')
********** | Handle an after read event
WHEN | VALUE_IS('= AFTRED')
********** | Handle a before insert event
WHEN | VALUE_IS('= BEFINS')
********** | Handle an after insert event
WHEN | VALUE_IS('= AFTINS')
********** | Handle a before update event
WHEN | VALUE_IS('= BEFUPD')
********** | Handle an after update event
WHEN | VALUE_IS('= AFTUPD')
********** | Handle a before delete event
WHEN | VALUE_IS('= BEFDLT')
********** | Handle an after delete event
WHEN | VALUE_IS('= AFTDLT')
********** | Handle an event not catered for
OTHERWISE |
ABORT | MSGTXT('File iiiFIL03 trigger function invalidly invoked/ used.')
ENDCASE |
********** | Return control to the invoker
RETURN |


Step 3. Code the Trigger Logic

LFA_F60 Create a Trigger Function

In this step, you will add the logic for the after read condition. When a file whose iiiAMOUNT is less than 0 is read, iiiAMOUNT will be changed to 0 before it is displayed to the user. When a file whose amount is less than 0 is updated, the amount will be converted to a character string and written to the SECADDR3 field as "The amount is 9999.99". You will need to complete the following tasks:

  • Following the instructions in the RDML code, delete the unnecessary statements in the CASE loop.
  • Define a working field for the report called STRAMOUNT. The field should be A(8).
  • In the AFTRED loop, get the current values of the record from the TRIG_LIST and change the iiiAMOUNT to 0 and then update the TRIG_LIST.
  • In the BEFUPD loop, get the current values of the record from the TRIG_LIST. Use the NUMERIC_STRING to convert iiiAMOUNT to a string and store it in STRAMOUNT. Use the BCONCAT BIFs to update SECADDR3 with "The amount is ". Update the TRIG_LIST.

1. Edit the RDML commands in your trigger function.

2. Try to make the necessary RDML code changes based on the function description above.

3. Your function RDML should appear as follows:

FUNCTION | OPTIONS(*DIRECT *NOMESSAGES *LIGHTUSAGE *MLOPTIMISE) RCV_LIST(#TRIG_LIST) TRIGGER(*FILE iiiFIL03)
DEF_LIST | NAME(#TRIG_LIST) TYPE(*WORKING) ENTRYS(2)
DEFINE | FIELD(#STRAMOUNT) TYPE(*CHAR) LENGTH(8) DEFAULT(*blank)
********** | Assume a "good" return initially
CHANGE | FIELD(#TRIG_RETC) TO(OK)
CASE | OF_FIELD(#TRIG_OPER)
********** | Handle an after read event
WHEN | VALUE_IS('= AFTRED')
GET_ENTRY | NUMBER(1) FROM_LIST(#TRIG_LIST)
CHANGE | FIELD(#iiiAMOUNT) TO(0)
UPD_ENTRY | IN_LIST(#TRIG_LIST)
WHEN | VALUE_IS('= BEFUPD')
GET_ENTRY | NUMBER(1) FROM_LIST(#TRIG_LIST)
USE | BUILTIN(NUMERIC_STRING) WITH_ARGS(#iiiAMOUNT) TO_GET(#STRAMOUNT)
USE | BUILTIN(BCONCAT) WITH_ARGS('The amount is ' #STRAMOUNT) TO_GET(#SECADDR3)
UPD_ENTRY | IN_LIST(#TRIG_LIST)
********* | Handle an event not catered for
OTHERWISE |
ABORT | MSGTXT('File iiiFIL03 trigger function invalidly invoked/ used.')
ENDCASE |
********** | Return control to the invoker
RETURN |

4. Save the RDML. Exit the editor. Compile the function.


Step 4. Test The Trigger Function

LFA_F60 Create a Trigger Function

1. Execute your iiiFN14 Section Maintenance function.

a. Try using the prompt on Section Code. Notice how records with negative amounts are displayed as 0. Select one of these records.

b. Display the selected record which has a negative amount. Notice the value of the Tax Amount virtual field. What does this tell you about the virtual fields and the trigger functions?

c. Update the record with an amount of –1234.56.

d. Display the updated record.

e. Display a record where the amount is greater than 0 and update the record.

f. Display the updated record to check that the trigger was not invoked.

g. Execute your iiiFN17 Section Report. Print all sections for the ADM department. Notice that all of the negative amounts appear as 0.

2. Following are some things you should notice:

  • Trigger functions can be used to create virtual fields by deriving the value of the virtual field before it is passed to the function.
  • Once logic was defined in the trigger, all functions which retrieve records are impacted.


Step 5. Remove the Trigger

LFA_F60 Create a Trigger Function

1. Once you have successfully tested your trigger function, delete the trigger from the repository. (You will remove the trigger so that it will not impact testing of your functions.)

2. Make the file operational again.


Summary

What You Should Know

  • How to create a trigger function which is used with the LANSA repository.
  • You should be familiar with the following commands:
  • ABORT
  • CASE, WHEN, ENDCASE
  • USE.

Other Tutorials

  • There are no further iSeries tutorials.


LFA_G10 RDML Application

Objectives:

  • To review the skills you have used in the RDML section of the tutorial.
  • To allow you to develop an application function on your own.

This exercise is a summary of the LANSA Process, Functions and RDML tutorials. You will create a "work with" style function which will allow you to use a wide range of RDML commands. You should be able to create this function by using the skills learned in the earlier exercises.

To achieve these objectives you must complete the following:

Step 1. Design Specification

Step 2. Create Your Function

Step 3. Test Your Function

Step 4. Compare Your Function to the Solution

Summary

Some Helpful Reminders

  • If you need additional help completing any of the steps, refer back to previous tutorials.
  • Remember to use the LANSA Guides which are available online.
  • Refer to the existing Personnel System for additional examples.


Step 1. Design Specification

LFA_G10 RDML Application

1. You will create a "work with" style function for the Sections within a department.

2. The function should allow the user to perform the following tasks:

a. Request a department code from the user and then display all sections in the department.

  • Display the department details in the header area of the screen along with a list of the sections in the specified department.
  • Allow the user to enter action codes for the items in the list where:
  • 2=Edit/Change
  • 4=Delete
  • 8=Display
  • 9=Print (See sample below.)
  • Allow the function key F6=Create new sections.
  • Allow the function key F9=Print to be enabled on the request panel. When Print is selected, a list of sections for the department specified should be printed. (See sample below.)

3. Create the Work with Sections function in a new process. The process should allow the user to access iiiFN04, iiiFN16 and iiiFN17. Also, the process should allow the user to use the OS/400 command to work with spool files (WRKSPLF) for the reports created.

4. Create help text for the process and the function.

5. The function will appear something like the following:

Request Department Panel

Work with Section Panel

Edit Section Panel

Display Section Details Panel

Create a new Section Panel

Following is a sample of the report produced using the F9=Print function key.

Note: This is the same report that was used in the reporting exercise.

Page . . . . . . 9999

Function . . . . xxxxxxx

Title . . . . . xxxxxxxxxxxxxxxxxx

Department . . . xxxx

Department Desc xxxxxxxxxxxxxxxxxxx

Section

Code Section Description Amount Date (D/M/Y)

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,9999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

Section Count 999 Total Amount 99,999,999,999.99cr

Date . . . 99/99/99 Time . . . . . 99:99:99 Page . . . 9999

Page . . . . . . 9999

Function . . . . xxxxxxx

Title . . . . . xxxxxxxxxxxxxxxxxx

Department . . . xxxx

Department Desc xxxxxxxxxxxxxxxxxxx

Section

Code Section Description Amount Date (D/M/Y)

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

xxxx xxxxxxxxxxxxxxxxxxxx 9,999.99cr 99/99/99

Section Count 999 Total Amount 99,999,999,999.99cr

Grand Total 9,999,999,999,999.99cr

Date . . . 99/99/99 Time . . . . . 99:99:99 Page . . 9999

Following is a sample of the report produced when using the option 9=Print from the work with panel.

Page . . . . . . 9999

Function . . . . xxxxxxx

Title . . . . . xxxxxxxxxxxxxxxxxx

Department . . . xxxx

Department Desc xxxxxxxxxxxxxxxxxxx

Section Code xx

Section Desc xxxxxxxxxxxxxxxxxxxx

Amount 9,999.99cr

Date (D/M/Y) 99/99/99

Date . . . 99/99/99 Time . . . . . 99:99:99 Page . . 9999


Step 2. Create Your Function

LFA_G10 RDML Application

1. Create a new process iiiPRO05RDML Summary.

2. Create a new function called iiiFN20Work with Sections.

3. Using the information in the specification provided in Step 1, create the RDML code for the function. Refer back to previous exercises in this tutorial and use the iSeries Technical Reference Guide to help develop the code. You may use templates, copy, cut and paste code from your existing functions. You may also wish to call some of your existing functions.

4. Remember to build your function in small steps just as you did in the previous exercises. For example, you could:

a. Execute template FRENQ02 to create the basic request and header detail style panels or copy code from your existing header/detail function.

b. Include your existing report function for the F9=Print options.

c. Copy code from your maintenance functions.

d. etc.


Step 3. Test Your Function

LFA_G10 RDML Application

1. Execute your function. Be sure to test the following:

a. Enter a valid department code. Check the header and details values displayed.

b. Enter an invalid department code to test your error checking when no record is found.

c. Display more than one department to check that both the header and lists are properly reset each time new information is being displayed.

d. Use the Cancel and Exit keys from both panels in the function.

e. Try printing a department report.

f. Print the details of a section.

g. Add a new section and check that the list of sections is updated.

h. Change section details and check that the list of sections and the header is updated.

i. Delete a section and check that the list of sections is updated.


Step 4. Compare Your Function to the Solution

LFA_G10 RDML Application

Following is just one possible solution for this function: (There are many different ways to code this function.)

FUNCTION | OPTIONS(*DIRECT)
********** |
DEFINE | FIELD(#USEOPTION) TYPE(*DEC) LENGTH(1) DECIMALS(0) COLHDG('Opt') EDIT_CODE(4)
********** |
GROUP_BY | NAME(#HEADER) FIELDS(#iiiDEPT #iiiDEPDSC #iiiCNTPJF #iiiTOTPJF)
********** |
BEGIN_LOOP |
CHANGE | FIELD(#HEADER) TO(*DEFAULT)
MESSAGE | MSGTXT('Enter a Department Code to work with the Sections in that Department.')
REQUEST | FIELDS(#iiiDEPT) DESIGN(*DOWN) IDENTIFY(*DESC) USER_KEYS((09 'Print'))
********** | Check if the department code is valid)
BEGINCHECK |
FILECHECK | FIELD(#iiiDEPT) USING_FILE(iiiFIL02) USING_KEY(#iiiDEPT)
ENDCHECK |
********** | If F9=Print pressed, print department report)
IF_KEY | WAS(*USERKEY1)
CHANGE | FIELD(#iiiSECT) TO(*BLANK)
SUBMIT | PROCESS(iiiPRO04) FUNCTION(iiiFN17) EXCHANGE(#iiiDEPT #iiiSECT) JOB(#FUNCTION)
ELSE |
********** | Display the work with sections panel
EXECUTE | SUBROUTINE(DISPSECT)
ENDIF |
END_LOOP |
********** |
********** | Subroutine displays the work with panel
********** |
SUBROUTINE | NAME(DISPSECT)
DEFINE | FIELD(#PB$INST) TYPE(*CHAR) LENGTH(050) INPUT_ATR(PBIN) OUTPUT_ATR(PBIN)
DEFINE | FIELD(#PB$OPT1) TYPE(*CHAR) LENGTH(070) INPUT_ATR(PBIN) OUTPUT_ATR(PBIN)
CHANGE | FIELD(#PB$INST) TO('''Type options, press Enter''')
CHANGE | FIELD(#PB$OPT1) TO('''2=Change 4=Delete 8=Details 9=Print''')
BEGIN_LOOP |
EXECUTE | SUBROUTINE(BUILDLST)
DISPLAY | FIELDS((#iiiDEPT *L3 *P2)(#iiiDEPDSC *L3 *P37) (#iiiCNTPJF *L4 *P2) (#iiiTOTPJF *L4 *P37) (#PB$INST *L5 *P2 *NOID) (#PB$OPT1 *L6 *P2 *NOID)) DESIGN(*DOWN) IDENTIFY(*LABEL) BROWSELIST(#iiiLIST) MENU_KEY(*YES *RETURN) ADD_KEY(*YES)
IF_MODE | IS(*ADD)
EXECUTE | SUBROUTINE(ADDRECORD)
ELSE |
SELECTLIST | NAMED(#iiiLIST) GET_ENTRYS(*SELECT)
FETCH | FIELDS(#PANELDATA) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT #iiiSECT) NOT_FOUND(*RETURN) ISSUE_MSG(*YES)
CASE | OF_FIELD(#USEOPTION)
WHEN | VALUE_IS('= 2')
SET_MODE | TO(*CHANGE)
EXECUTE | SUBROUTINE(WRK_DATA)
WHEN | VALUE_IS('= 4')
MESSAGE | MSGTXT('Press Enter to delete this record')
SET_MODE | TO(*DELETE)
EXECUTE | SUBROUTINE(WRK_DATA)
WHEN | VALUE_IS('= 8')
SET_MODE | TO(*DISPLAY)
EXECUTE | SUBROUTINE(WRK_DATA)
WHEN | VALUE_IS('= 9')
EXECUTE | SUBROUTINE(PRT_DATA)
OTHERWISE |
MESSAGE | MSGID(DCU0014) MSGF(DC@M01)
ENDCASE |
ENDSELECT |
ENDIF |
END_LOOP |
ENDROUTINE |
********** |
********** | Subroutine builds the header area and browse list
********** |
SUBROUTINE | NAME(BUILDLST)
DEF_LIST | NAME(#iiiLIST) FIELDS((#USEOPTION *SELECT) (#iiiDEPT *HIDDEN) #iiiSECT #iiiSECDSC #iiiAMOUNT)
FETCH | FIELDS(#HEADER) FROM_FILE(iiiFIL02) WITH_KEY(#iiiDEPT) VAL_ERROR(*NEXT) ISSUE_MSG(*YES)
********** | If the record cannot be found, then abort the program.
IF_STATUS | IS_NOT(*OKAY)
ABORT |
ENDIF |
********** | Clear the list and then select all sections.
CLR_LIST | NAMED(#iiiLIST)
SET_MODE | TO(*DISPLAY)
SELECT | FIELDS(#iiiLIST) FROM_FILE(iiiFIL03) WITH_KEY(#iiiDEPT)
ADD_ENTRY | TO_LIST(#iiiLIST)
ENDSELECT |
ENDROUTINE |
********** |
********** | Subroutine for display, change and delete
********** |
SUBROUTINE | NAME(WRK_DATA)
GROUP_BY | NAME(#PANELDATA) FIELDS((#iiiDEPT *NOCHG) (#iiiDEPPJF *OUTPUT) (#iiiSECT *NOCHG) #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE (#SECPHBUS *OUTPUT) #iiiAREAC #iiiLOCAL #iiiAMOUNT (#iiiTAXAMT *OUTPUT) (#iiiDATE *OUTPUT) (#iiiDATEDM *OUTPUT))
DISPLAY | FIELDS(#PANELDATA) IDENTIFY(*DESC) MENU_KEY(*YES *RETURN)
********** | Update the record
IF_MODE | IS(*CHANGE)
UPDATE | FIELDS(#PANELDATA) IN_FILE(iiiFIL03) ISSUE_MSG(*YES)
MESSAGE | MSGTXT('Data successfully changed in the Section File.')
ENDIF |
********** | Delete the record
IF_MODE | IS(*DELETE)
DELETE | FROM_FILE(iiiFIL03) ISSUE_MSG(*YES)
MESSAGE | MSGTXT('Data successfully deleted from the Section File.')
ENDIF |
ENDROUTINE |
********** |
********** | Subroutine adds a record to the section file
********** |
SUBROUTINE | NAME(ADDRECORD)
GROUP_BY | NAME(#ADDDATA) FIELDS((#iiiDEPT *NOCHG) #iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiAMOUNT #iiiAREAC #iiiLOCAL)
********** | Define working field to save iiiDEPT
DEFINE | FIELD(#SAVDEPT) REFFLD(#iiiDEPT)
********** | Save the iiiDEPT field
CHANGE | FIELD(#SAVDEPT) TO(#iiiDEPT)
MESSAGE | MSGTXT('Enter data to be added to the Section File.')
BEGIN_LOOP |
CHANGE | FIELD(#ADDDATA) TO(*DEFAULT)
********** | Restore the iiiDEPT field from the save field
CHANGE | FIELD(#iiiDEPT) TO(#SAVDEPT)
REQUEST | FIELDS(#ADDDATA) IDENTIFY(*DESC) MENU_KEY(*YES *RETURN)
BEGINCHECK |
ENDCHECK |
INSERT | FIELDS(#ADDDATA) TO_FILE(iiiFIL03) ISSUE_MSG(*YES)
MESSAGE | MSGTXT('Data successfully added to the Section File.')
END_LOOP |
ENDROUTINE |
********** |
********** | Subroutine prints out the section details
********** |
SUBROUTINE | NAME(PRT_DATA)
DEF_REPORT | FORMSIZE(66 80)
DEF_HEAD | NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #iiiDEPT #iiiDEPPJF) DESIGN(*DOWN)
DEF_FOOT | NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE | NAME(#DET01) FIELDS(#iiiSECT #iiiSECDSC #SECADDR1 #SECADDR2 #SECADDR3 #SECPCODE #iiiAREAC #iiiLOCAL #iiiDATEDM #iiiAMOUNT #iiiTAXAMT) DESIGN(*DOWN) IDENTIFY(*LABEL) DOWN_SEP(1)
CHANGE | FIELD(#STD_TITLE) TO('Section Report')
PRINT | LINE(#DET01)
ENDPRINT |
ENDROUTINE |

Following are some things you should notice:

  • A FILECHECK is used with the REQUEST of the department code. Validating the department code makes the function more efficient. The user cannot enter an invalid or blank department.
  • The department report is created simply by calling the iiiFN17 function.
  • The function is broken into many subroutines in order to make the code easier to understand and maintain.
  • The subroutine DISPSECT is used to display and process the main "work with" panel.
  • The subroutine BUILDLST is called to rebuild the list of sections. This subroutine is called before the main "work with" panel is displayed in case any sections were added, changed or deleted.
  • The WRKDATA subroutine is responsible for displaying, changing and deleting sections. It uses modes to accomplish these tasks.
  • Notice how working fields #PB$OPT1 and #PB$INST are defined to create the option list and instructions on the main "work with" display. Using variables is recommended over using text on the screen.


Summary

What You Should Know

  • How to create simple functions with LANSA.


Appendix A. Application Summary

The following tables list the information stored in the Repository:

K | Key
J | Predetermined Join Field
V | Virtual Field
0 | Optional Field/Exercise

 | Name | Description | Notes
 | iiiFIL02 | Department | Physical File
K | iiiDEPT | Department | A(4);default *BLANK; prompt iiiFN06 Cannot be blank (Field) Must be in range A to ZZZZ. (File) Cannot be deleted if exists in iiiFIL03 (File)
 | iiiDEPDSC | Dept. Description | A(20);default *BLANK; reffld(iiiDSC) Cannot be blank (Field)
J | iiiTOTPJF | Total Amount | P(11,2) Virtual - PJF total iiiAMOUNT in iiiFIL03 file
J | iiiAVEPJF | Average Amount | P(6,2) Virtual - PJF average iiiAMOUNT in iiiFIL03 file
J | iiiMAXPJF | Maximum Amount | P(6,2) Virtual - PJF maximum iiiAMOUNT in iiiFIL03 file
J | iiiMINPJF | Minimum Amount | P(6,2) Virtual - PJF minimum iiiAMOUNT in iiiFIL03 file
J | iiiCNTPJF | Section Count | S(3) Virtual - PJF count sections in iiiFIL03 file
 | iiiVEW02 | By Description | Logical File (Keyed on iiiDEPDSC)

 | Name | Description | Notes
 | iiiFIL03 | Section | Physical File - (Optional High Speed Table on iSeries)
K | iiiDEPT | Department | A(4); from iiiFIL02 Cannot be blank. (Field) Must exist in iiiFIL02 file (File)
K | iiiSECT | Section | A(30); default *BLANK; prompt iiiFN07 Cannot delete if exists in iiiFIL04. (File)
 | iiiSECDSC | Section Description | A(20); default *BLANKS; reference iiiDSC Cannot be blank (Field)
 | SECADDR1 | Street No and Name | A(25); existing field in DEM partition
 | SECADDR2 | Suburb or Town | A(25); existing field in DEM partition Cannot be blank if SECADDR1 is not blank. (File)
 | SECADDR3 | State and Country | A(25); existing field in DEM partition
 | SECPCODE | Post / Zip Code | S(6,0); existing field in DEM partition
 | SECPHBUS | Business Phone | A(15); existing field in DEM partition
 | iiiAMOUNT | Amount | P(6,2); default 0 Cannot be 0 Must be in range –5000 to 5000 Trigger CALCTAX called when =5000; before add & update
 | iiiDATE | Date | S(8,0); Can be zero Must be in format YYYYMMDD, and in past
V | iiiTAXAMT | Tax Amount | P(6,2) Virtual - calculated from iiiAMOUNT
V | iiiDATEDM | Date | S(6,0); Edit code Y Virtual - date in DD/MM/YY format; output only
V | iiiAREAC | Area Code | A(7) Virtual – substring of SECPHBUS; on input and before output
V | iiiLOCAL | Local Phone | A(8) Virtual – substring of SECPHBUS; on input and before output Must be in Range A to ZZZZZZZZ
V | iiiFULDSC | Full Description | A(27) Virtual – concatenation iiiDEPT, iiiSECT, iiiDEPPJF
J | iiiDEPPJF | Department Desc | A(20) Virtual – PJF lookup department description in iiiFIL02 file
 | iiiVEW03 | Amount > 0 | Logical View (Select iiiAMOUNT GT 0)

 | Name | Description | Notes
 | iiiFIL04 | Employee | Physical File
K | iiiEMPNO | Employee | A(5); existing field in DEM partition Must be in range A0000-A9999 (Field)
 | SURNAME |  | A(20); existing field in DEM partition Cannot be blank. (Field)
 | GIVENAME |  | A(20); existing field in DEM partition Cannot be blank. (Field)
 | ADDRESS1 | Street No and Name | A(25); existing field in DEM partition Cannot be blank. (Field)
 | ADDRESS2 | Suburb or Town | A(25); existing field in DEM partition
 | ADDRESS3 | State and Country | A(25); existing field in DEM partition
 | POSTCODE | Post / Zip Code | S(6,0); existing field in DEM partition Must be in range 2000-7999. (Field)
 | PHONEHME | Home Phone | A(15); existing field in DEM partition Cannot be blank. (Field)
 | PHONEBUS | Business Phone | A(15); existing field in DEM partition Cannot be blank. (Field)
 | STARTDTER | Start Date | S(6,0); existing field in DEM partition
 | TERMDATER | Termination Date | S(6,0); existing field in DEM partition
 | iiiDEPT | Department | A(4); from iiiFIL02
 | iiiSECT | Section | A(2); from iiiFIL03 Must exist in iiiFIL03
 | SALARY |  | P(11,2); existing field in DEM partition Must be greater than 0. (Field)
V | MNTHSAL |  | P(11,2); existing field in DEM partition
V | STARTDTE |  | S(6,0); existing field in DEM partition Valid format and range. (Field)
V | TERMDATE |  | S(6,0); existing field in DEM partition Can be 0. (Field) Valid format and range. (Field)
J | iiiDEPPJF | Department Desc | A(20) Virtual - PJF lookup department description in iiiFIL02 file
 | iiiVEW04 | By Surname | Logical View (keyed on SURNAME)
 | iiiVEW05 | By Dept/Sect | Logical View (keyed on iiiDEPT and iiiSECT)

Listing of Processes and Functions

iiiPRO01 | Test Menu | Process
iiiFN01 | Add Employee | Created with FRADD01 template

iiiPRO02 | Repository Testing Menu | Process
iiiFN02 | Test Fields | Created with FLDTEST template
iiiFN03 | Test Rules | Created with FRADD01 template
iiiFN04 | Department Maintenance | Created with FRMNT01 template
iiiFN05 | Section Maintenance | Created with FRMNT01 template
iiiFN06 | Department Prompt | Created with FRPOP02 template with search using logical
iiiFN07 | Section Amount > 0 Prompt | Created with FRPOP01 template showing s/o logical
iiiFN08 | Employee Prompt | Created with FRPOP02 template with search using logical
iiiFN09 | Employee Maintenance | Created with FRMNT01 template

iiiPRO03 | Test Process Menu | Process
iiiFN10 | Add Department | Created with FRADD01 template
iiiFN11 | Add Section | Copied from iiiFN10 and manually edit
iiiFN12 | Add Employee | Manually define a function & execute a template in editor.

iiiPRO04 | RDML Applications | Process
iiiFN13 | Add Section Data | Manually Defined
iiiFN14 | Maintain Section Data | Manually Defined
iiiFN15 | Section Prompt | Manually Defined
iiiFN16 | Dept/Section Inquiry | Manually Defined
iiiFN17 | Department Report | Manually Defined
iiiFN18 | Section Trigger | Created with BBFILTRIG template & Manually Defined

iiiPRO05 | RDML Summary | Process
iiiFN20 | Work with Sections | Manually Defined

iiiPRO06 | RDML Summary | Process
iiiRPT | Department Report | Created with FRPRT01 template.


Disclaimer

While every effort has been made to ensure that the information in the LANSA documentation is accurate. In no event shall LANSA be liable for any damages arising from its use.

LANSA MAKES NO WARRANTIES, EXPRESSED OR IMPLIED.

Copyright and trademark information

© LANSA. "LANSA" is a trade name and registered trademark of LANSA in the United States of America, Australia, the United Kingdom and other countries. All rights reserved.

The following are some companies which require attribution:

Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Microsoft, Windows, .NET and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.

Other company, product, and service names may be trademarks or service marks of others.

This material may contain other proprietary notices and copyright information, the terms of which must be observed and followed.