Repository
Version 11.0
ii
Contents
LFA_010 LANSA Application Development............................................................... 1
LFA_A10 Creating New Fields................................................................................. 13
LFA_A20 Help Text.................................................................................................. 21
LFA_A30 Validation Rules ....................................................................................... 25
LFA_A40 System Variables ..................................................................................... 33
LFA_B10 Manually Created File Definitions ............................................................ 37
LFA_B20 Create Logical Files/Views....................................................................... 45
LFA_B30 Validation Rules ....................................................................................... 49
LFA_B40 Virtual Fields ............................................................................................ 53
LFA_C10 Access Routes ......................................................................................... 61
LFA_C20 Predetermined Join Fields (PJF) ............................................................. 65
LFA_C30 Referential Integrity.................................................................................. 71
LFA_D10 Repository Summary ............................................................................... 73
Appendix A. Application Summary........................................................................... 79
iii
Introduction
Some Important Tips:
Each student will be assigned a unique 3-character identifier (iii) based on your ID. Remember to use
this prefix when creating your objects in LANSA.
Follow the instructions! For example, do not make a file operational unless instructed. You may lock
a file definition when you still need to modify it.
Following are some important notes regarding the structure of the exercises for this course:
The first steps in an exercise provide very precise descriptions of the tasks to perform. As the steps
and course progresses, the instructions will become much more general.
Read the instruction steps CAREFULLY. Complete only the requested tasks.
The exercises are broken into modules based on topic but are designed to be done in groups.
Later exercises have been designed to use skills from the preceding exercises.
The summary exercise at the end of the Repository section is an excellent test of your understanding
of the LANSA Repository. It combines the skills developed in the earlier exercises into one single
step.
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.
iv
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.
Step 6. Review the Personnel System Case Study and Database Model
Summary
2005 LANSA
Page 1
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.
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).
Page 2
2005 LANSA
Step 6. Review the Personnel System Case Study and Database Model
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.
2005 LANSA
Page 3
EMPNO*
------>
SKILDESC
PSLMST
<------
EMPNO*
SKILCODE*
SURNAME
DATEACQR
GIVENAME
GRADE
ADDRESS1
COMMENT
ADDRESS2
dateacq
POSTCODE
ADDRESS3
gradedes
PHONEHME
PHONEBUS
STARTDTER
DEPTAB
DEPTMENT*
DEPTDESC
SECTAB
------>
TERMDATER
DEPTMENT*
------>
DEPTMENT
SECTION*
------>
SECTION
SECDESC
SALARY
SECADDR1
*file keys
SECADDR2
mnthsal
SECADDR3
startdte
SECPCODE
termdate
SECPHBUS
Page 4
2005 LANSA
SECTAB
iiiFIL02
iiiDEPT*
STARTDTER
iiiFIL03
------>
TERMDATER
iiiDEPT*
------>
iiiDEPT
iiiDEPDSC
iiiSECT*
------>
iiiSECT
iiitotpjf
SECADDR1
iiiavepjf
SECADDR2
mnthsal
iiimaxpjf
SECADDR3
startdte
iiiminpjf
SECPCODE
termdate
iiicntpjf
SECPHBUS
iiideppjf
iiiSECDSC
SALARY
iiiAMOUNT
iiiDATE
iiitaxamt
iiidatedm
iiiareac
iiilocal
iiifuldsc
iiideppjf
*file keys
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.
2005 LANSA
Page 5
iiiPRO01
Process Description:
Test Process
iiiFN01
Function Description:
Function Type:
Page 6
2005 LANSA
ANSWER
employee
PSLMST
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.
2005 LANSA
Page 7
Page 8
2005 LANSA
2005 LANSA
Page 9
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.
Page 10
2005 LANSA
6. Press the Refresh button to remove the highlighting before you print the page or copy and paste the
text into another document.
7. If you have a printer available, print a page or all pages within a 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
guides font is designed for viewing, the printed copies font is designed for reading from paper.
2005 LANSA
Page 11
Summary
What You Should Know
Page 12
2005 LANSA
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
Summary
2005 LANSA
Page 13
iiiDEPT
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.
Page 14
2005 LANSA
iiiDSC
Type:
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:
Length:
Description:
Date
iiiAMOUNT
Type:
Length:
Decimals:
Description:
Amount
Edit code:
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).
2005 LANSA
Page 15
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.
Page 16
2005 LANSA
2005 LANSA
Page 17
iiiPRO02
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
Function Description:
Test Fields
Function Type:
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
iiiDEPDSC
iiiSECT
iiiSECDSC
iiiDSC
iiiDATE
iiiAMOUNT
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.
Page 18
2005 LANSA
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.
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.
2005 LANSA
Page 19
Summary
What You Should Know
How to define a field by copying, manually defining, and using a reference field.
When you change a default value, you must recompile the function.
Page 20
2005 LANSA
To create field level help text for the new fields created in the last exercise.
Summary
field.
4. Test your changes to the field help text by using the test function.
2005 LANSA
Page 21
Page 22
2005 LANSA
Summary
What You Should Know
How to define field level help text by copying or by using a standard form.
2005 LANSA
Page 23
Page 24
2005 LANSA
To show the types of validation rules which can be defined in the repository.
Cannot be blank
iiiAMOUNT
iiiDATE
iiiDSC
Cannot be blank
iiiDEPDSC
Cannot be blank
iiiSECDSC
Cannot be blank
iiiSECT
Step 5. Add a List of Values Rule to the iiiDSC, iiiDEPDSC and iiiSECDSC Fields
Summary
2005 LANSA
Page 25
01 to 99
If
NEXT
ERROR
#iiiAMOUNT *EQ 0
If
ERROR
NEXT
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.
Page 26
2005 LANSA
20
-5000
If
NEXT
to 5000
ERROR
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.
Accept if date is 0.
#iiiDATE *EQ 0
If
ACCEPT
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.
2005 LANSA
Page 27
YYYYMMDD
9999999
If
NEXT
ERROR
Step 5. Add a List of Values Rule to the iiiDSC, iiiDEPDSC and iiiSECDSC Fields
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
*BLANKS
If
ERROR
NEXT
Page 28
2005 LANSA
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
iiiDEPT
iiiDEPDSC
iiiSECT
iiiSECDSC
iiiDSC
iiiDATE
iiiAMOUNT
2005 LANSA
Page 29
iiiFN03
Function Description:
Function Type:
4. Select the FRADD01 Flat Screen Data Entry template and answer the template questions as shown
below.
TEMPLATE QUESTION
ANSWER
test
iiiFIL01
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.
Page 30
2005 LANSA
iiiAMOUNT
is 0, is 5001, is 5001, is 1
iiiDATE
iiiDSC
iiiDEPDSC
iiiSECDSC
iiiSECT
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.
2005 LANSA
Page 31
Summary
What You Should Know
How the same business rules can be defined by using different types of validation checks.
Page 32
2005 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.
Summary
2005 LANSA
Page 33
*AUTOALP02iiiNUM
Description:
Method of Derivation:
DYNAMIC
Data Type:
ALPHA
Length:
Name:
M@SYSNUM
Type:
3GL
*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.
Page 34
2005 LANSA
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.
2005 LANSA
Page 35
Summary
What You Should Know
Page 36
2005 LANSA
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.
Section File
iiiFIL03
iiiDEPT*
iiiSECT*
iiiSECDESC
SECADDR1
SECADDR2
SECADDR3
SECPCODE
SECPHBUS
iiiAMOUNT
iiiDATE
Summary
2005 LANSA
Page 37
iiiFIL02
Description:
Department
Maintained by:
LANSA
3. Press Enter to save the file definition. The new file iiiFIL02 will now appear in the file list.
Name
iiiDEPT
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.
Page 38
2005 LANSA
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.
iiiFIL03
Description:
Section
Maintained by:
LANSA
Name
iiiDEPT
iiiSECT
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.
2005 LANSA
Page 39
iiiFN04
Function Description:
Department Maintenance
Function Type:
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
iiiFIL02
DOWN
department
4. Check if the make operational job for the iiiFIL03 Section file has completed successfully.
5. Add a new function to your iiiPRO02 process. Enter the following details:
Function Name:
iiiFN05
Function Description:
Section Maintenance
Function Type:
Page 40
2005 LANSA
ANSWER
iiiFIL03
DOWN
section
2005 LANSA
Page 41
Page 42
2005 LANSA
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
1234.56
ADM
02
Purchasing
1234.56-
ADM
03
Accounting
1234.56
ADM
04
Sales
1234.56-
LGL
01
Contract
1234.56
LGL
02
Foreign
1234.56-
LGL
03
Domestic
1234.56
TRN
01
Internal
1234.56
TRN
02
External
1234.56-
TRVL
01
Local
1234.56
TRVL
02
International
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.
2005 LANSA
Page 43
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
What are some of the attributes which can be specified for database files.
Page 44
2005 LANSA
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.
Step 5. Edit the Prompting Functions for iiiDEPT and iiiSECT Fields
Summary
iiiVEW02
Department by Description
iiiDEPDSC
2005 LANSA
Page 45
iiiVEW03
iiiDEPT
iiiSECT
Field
Operation(s)
SELECT
iiiAMOUNT
COMP(GT 0)
iiiFN06
Function Description:
Department Prompt
Function Type:
3. Use the FRPOP02 Pop Up Prompter (Requests Search Values) template. Answer the template
questions as shown in the table below.
TEMPLATE QUESTION
ANSWER
Department
iiiVEW02
Fields to be displayed?
Fields to be returned?
Page 46
2005 LANSA
iiiFN07
Function Description:
Section Prompt
Function Type:
2. Use the FRPOP01 Pop Up Prompter (Full File) template. Answer the template questions as shown
in the table below.
TEMPLATE QUESTION
ANSWER
iiiVEW03
Fields to be displayed?
Fields to be returned?
Step 5. Edit the Prompting Functions for iiiDEPT and iiiSECT Fields
1. From the Work with Fields menu, review the iiiDEPT field and make the following change:
Prompting process/function:
*DIRECT / iiiFN06
2005 LANSA
*DIRECT / iiiFN07
Page 47
Summary
What You Should Know
Page 48
2005 LANSA
To highlight the difference between field and file level validation rules and the hierarchy which exists
between these rules.
To reinforce how the OAM relates to validation rules in the repository and how the OAM relates to
your functions.
Summary
If
NEXT
to ZZZZ
ERROR
2005 LANSA
Page 49
iiiFIL02
iiiDEPT
If
NEXT
ERROR
ADDUSE
If
ERROR
CHGUSE
NEXT
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.
Page 50
2005 LANSA
2005 LANSA
Page 51
Summary
What You Should Know
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.
Page 52
2005 LANSA
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.
Step 5. Concatenation
Step 8. Create a New Test Function for the iiiFIL03 Section File
Summary
2005 LANSA
Page 53
iiiDATEDM
Type:
Length:
Description:
Date (D/M/Y)
Edit Code:
Default:
*ZERO
YES
No
iiiDATE
DDMMYY
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.
Page 54
2005 LANSA
iiiTAXAMT
Type:
Length:
Decimals:
Description:
Tax Amount
Edit Code:
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
2005 LANSA
Page 55
iiiAREAC
Type:
Length:
Description:
Area Code
Default:
*BLANK
Field name:
iiiLOCAL
Type:
Length:
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
YES
SECPHBUS
Start position
The telephone area code will be the first 7 digits (1 to 7) of the SECPHBUS field and starts at position
1.
Page 56
2005 LANSA
Step 5. Concatenation
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
NO
Using fields
iiiDEPT
iiiSECT
2005 LANSA
Page 57
Step 8. Create a New Test Function for the iiiFIL03 Section File
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 iiiFN05 Section Maintenance function using the FRMNT01 Flat Screen
Maintenance template. Answer the template questions as shown in the table below.
TEMPLATE QUESTION
ANSWER
iiiFIL03
DOWN
section
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.
Page 58
2005 LANSA
2005 LANSA
Page 59
Summary
What You Should Know
What is the purpose of the Derive virtual field on input from file and Setup virtual field before output
to file options.
Page 60
2005 LANSA
To create an access route to define a relationship between the department and section files.
Summary
01 02
03
04
02
01
01
02
01
02
03
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:
2005 LANSA
Page 61
iiiFIL0301
Section belongs to a
department.
iiiFIL02
IGNORE
iiiDEPT
iiiFIL0201
iiiFIL03
999
IGNORE
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 iiiFIL02 Department file operational.
Page 62
2005 LANSA
ANSWER
iiiFIL03
DOWN
section
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.
2005 LANSA
Page 63
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
Page 64
2005 LANSA
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.
Step 2. Create File Lookup Predetermined Join Field in the iiiFIL03 Section File
Step 5. Create Calculated Predetermined Join Field in the iiiFIL02 Department File
Summary
iiiDEPPJF
Description:
Department
Type:
Length:
20
Field name:
iiiTOTPJF
Description:
Total Amount
Type:
Length:
11
Decimals:
Edit code:
2005 LANSA
Page 65
iiiMAXPJF
Description:
Maximum Amount
Type:
Length:
Decimals:
Edit code:
Field name:
iiiMINPJF
Description:
Minimum Amount
Type:
Length:
Decimals:
Edit Code
Field name:
iiiAVEPJF
Description:
Average Amount
Type:
Length:
Decimals:
Edit code:
Field name:
iiiCNTPJF
Description:
Section Count
Type:
Length:
Decimals:
Edit code
Page 66
2005 LANSA
Step 2. Create File Lookup Predetermined Join Field in the iiiFIL03 Section File
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.
2005 LANSA
Page 67
Step 5. Create Calculated Predetermined Join Field in the iiiFIL02 Department File
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 iiiFIL02 Department file. Notice that the Predetermined
Join Fields appear but they cannot be maintained from the virtual field dialog.
7. Commit amendments and make the iiiFIL02 Department file operational
Page 68
2005 LANSA
ANSWER
iiiFIL03
Related files
DOWN
section
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.)
2005 LANSA
Page 69
ANSWER
iiiFIL02
Related files
DOWN
department
Summary
What You Should Know
Page 70
2005 LANSA
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.
Summary
2005 LANSA
Page 71
Summary
What You Should Know
What is the advantage of using the LANSA Repository to enter referential integrity rules, as opposed
to using the database management system.
Page 72
2005 LANSA
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.
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.
2005 LANSA
Page 73
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 12. Create Access Routes for Department & Section Files
Summary
Page 74
2005 LANSA
iiiEMPNO
Description:
Employee Number
Type:
Length:
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.
2005 LANSA
Page 75
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.
Page 76
2005 LANSA
Step 12. Create Access Routes for Department & Section Files
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.
Summary
What You Should Know
How to use the features in the LANSA Repository to create an application database.
2005 LANSA
Page 77
Page 78
2005 LANSA
Key
Virtual Field
Optional Field/Exercise
Name
Description
Notes
iiiFIL02
Department
Physical File
iiiDEPT
Department
iiiDEPDSC
Dept. Description
iiiTOTPJF
Total Amount
P(11,2)
Virtual - PJF total iiiAMOUNT in iiiFIL03 file
iiiAVEPJF
Average Amount
P(6,2)
Virtual - PJF average iiiAMOUNT in iiiFIL03 file
iiiMAXPJF
Maximum Amount
P(6,2)
Virtual - PJF maximum iiiAMOUNT in iiiFIL03 file
iiiMINPJF
Minimum Amount
P(6,2)
Virtual - PJF minimum iiiAMOUNT in iiiFIL03 file
iiiCNTPJF
Section Count
S(3)
Virtual - PJF count sections in iiiFIL03 file
iiiVEW02
By Description
2005 LANSA
Page 79
Name
Description
Notes
iiiFIL03
Section
iiiDEPT
Department
iiiSECT
Section
iiiSECDSC
Section Description
SECADDR1
Street No and
Name
SECADDR2
Suburb or Town
SECADDR3
SECPCODE
SECPHBUS
Business Phone
iiiAMOUNT
Amount
iiiDATE
Date
iiiTAXAMT
Tax Amount
iiiDATEDM
Date
iiiAREAC
Area Code
iiiLOCAL
Local Phone
iiiFULDSC
Full Description
iiiDEPPJF
Department Desc
iiiVEW03
Amount > 0
Page 80
2005 LANSA
Name
Description
Notes
iiiFIL04
Employee
Physical File
iiiEMPNO
Employee
SURNAME
GIVENAME
ADDRESS1
Street No and
Name
ADDRESS2
Suburb or Town
ADDRESS3
POSTCODE
PHONEHME
Home Phone
PHONEBUS
Business Phone
STARTDTER
Start Date
TERMDATER
Termination Date
iiiDEPT
Department
iiiSECT
Section
SALARY
MNTHSAL
STARTDTE
TERMDATE
iiiDEPPJF
Department Desc
iiiVEW04
By Surname
iiiVEW05
By Dept/Sect
2005 LANSA
Page 81
iiiPRO01
Test Menu
Process
iiiFN01
Add Employee
iiiPRO02
Repository Testing
Menu
Process
iiiFN02
Test Fields
iiiFN03
Test Rules
iiiFN04
Department Maintenance
iiiFN05
Section Maintenance
iiiFN06
Department Prompt
iiiFN07
iiiFN08
Employee Prompt
iiiFN09
Employee Maintenance
iiiPRO03
Process
iiiFN10
Add Department
iiiFN11
Add Section
iiiFN12
Add Employee
iiiPRO04
RDML Applications
Process
iiiFN13
Manually Defined
iiiFN14
Manually Defined
iiiFN15
Section Prompt
Manually Defined
iiiFN16
Dept/Section Inquiry
Manually Defined
iiiFN17
Department Report
Manually Defined
iiiFN18
Section Trigger
iiiPRO05
RDML Summary
Process
iiiFN20
Manually Defined
iiiPRO06
RDML Summary
Process
iiiRPT
Department Report
Page 82
2005 LANSA