**synon** horse model

50
Chapter 6 Advanced Functions This chapter demonstrates the use of the Edit Transaction (EDTTRN) function with a Span (SPN) access path and the use of function fields. This chapter introduces the following topics. The Edit Transaction Function Type Span Access Path Defining an Edit Transaction Function Using Function Fields Defining Function Field Parameters Span Access Path and Edit Transaction Function This topic demonstrates the use of the Edit Transaction (EDTTRN) function with a Span (SPN) access path. New terms introduced Access path format New panels introduced Display Access Path Formats Objectives You will specify a SPN access path based on the RACE and RACE ENTRY files. COOL:2E Tutorial TUT 6–1

Upload: sats

Post on 13-Nov-2014

831 views

Category:

Documents


33 download

DESCRIPTION

horse model application development in SYNON

TRANSCRIPT

Page 1: **SYNON** HORSE MODEL

Chapter

6 Advanced Functions

This chapter demonstrates the use of the Edit Transaction (EDTTRN) function witha Span (SPN) access path and the use of function fields. This chapter introducesthe following topics.

The Edit Transaction Function Type

Span Access Path

Defining an Edit Transaction Function

Using Function Fields

Defining Function Field Parameters

Span Access Path and Edit Transaction Function

This topic demonstrates the use of the Edit Transaction(EDTTRN) function with a Span (SPN) access path.

New terms introduced

Access path format

New panels introduced

Display Access Path Formats

Objectives You will specify a SPN access path based on theRACE and RACE ENTRY files.

COOL:2E Tutorial TUT 6–1

Page 2: **SYNON** HORSE MODEL

Overview The Edit Transaction function allows two database filesto be updated simultaneously. The Edit Transactionfunction type requires a SPN access path, which is alogical file with two formats.

In order for a SPN access path to be built over twofiles, the two files must be connected by a file-to-filerelation; for example, an Owned by relation. The EditTransaction function provides a display consisting of asubfile control format for the owning file and a subfilerecord format for the owned file.

You will set up an Edit Transaction function for theRACE and RACE ENTRY files. This provides the facilityto enter both the race details and the race entry detailsfor a given race on the same interactive panel.

Overview ofProcessingSteps

To implement the Edit Transaction function you will:

1. Define and generate a SPN access path for the RACEand RACE ENTRY files.

2. Create the Edit Transaction function and modify thedevice design for the Edit Race and Entries function.

RACE

Edit Raceand Entries

RACE ENTRY

JOCKEYHORSE

Owned bySPN

COURSE

Figure 6-1 Span (SPN) Access Path

Span Access Path and Edit Transaction Function

TUT 6–2 COOL:2E Tutorial

Page 3: **SYNON** HORSE MODEL

3. Generate source for the function.

4. Compile the access path, display file, and programsource.

Entering YourDesign Model

Return to the Edit Database Relations panel for yourdesign model. Select the RACE and RACE ENTRYfiles by typing Race* on the selection line as shown.

Press Enter .

Creating a SpanAccess Path

Create a SPN access path on the RACE file. A SPNaccess path must be attached to the file that is to formthe header format of the access path. In this case, youwill create the SPN access path over the RACE file.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–3

Page 4: **SYNON** HORSE MODEL

Type Z against any relation on the RACE file to displayall existing access paths.

Press Enter . The Edit File Details panel displays.

Defining theSpan AccessPath

To specify the SPN access path you need to:

1. Define two access path file formats, one for the subfilecontrol (header) and one for the subfile record (detail)

2. Specify the keys for those formats

Span Access Path and Edit Transaction Function

TUT 6–4 COOL:2E Tutorial

Page 5: **SYNON** HORSE MODEL

Define the new access path by calling it Race andEntries of type SPN. Type the access path type, name,and Z as shown.

Press Enter . The Edit Access Path Details paneldisplays.

Entering theAccess PathFormats

An access path format defines a view upon a physicalfile. By default, it makes all of the non-virtual entries inthat file available. An access path format can bedefined as a list of access path relations that will beresolved into a list of field entries. Relations can beremoved from a view on the Edit Access Path Relationspanel.

When you previously used the Edit Access Path Detailspanel, the access path format was automaticallyprovided. For the SPN access path you must explicitlyadd the formats. Note that it is important that you addthe formats in the correct sequence: header format first,detail format second.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–5

Page 6: **SYNON** HORSE MODEL

Press F9 to display the Display Access Path Formatspanel where you will add the format for the subfilecontrol (header).

Selecting theFirst AccessPath Format

The Display Access Path Formats panel shows you thefiles that you can select for the SPN access path. Inthis case, the two files shown are connected to theRACE file by an Owned by and a Defined as relation.

Select the RACE format with X as shown.

Span Access Path and Edit Transaction Function

TUT 6–6 COOL:2E Tutorial

Page 7: **SYNON** HORSE MODEL

Press Enter .

ConfirmingSelection of theFirst Format

The selection of the first format for the SPN accesspath, Race and Entries, has now been confirmed.Press F9 to add a second format for the subfile record(detail).

Specifying theSecond Format

The Display Access Path Formats panel displaysshowing the file-to-file relations for the RACE file. TypeX to select the Race Entry format for the subfile recordas shown.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–7

Page 8: **SYNON** HORSE MODEL

Press Enter to return to the Edit Access Path Detailspanel.

Adding VirtualFields to theAccess PathFormats

When the end user enters races and race entries, itwould be helpful to have the following virtual fieldsdisplay on the interactive panel: Course name, Horsename, and Jockey name. As mentioned previously,each access path initially contains all of the relations forthe file on which its is based, but none of the virtualentries. As a result, if you want virtual fields included onthe two formats for the Race and Entries access path,you need to add them explicitly.

In this step, you will add these virtual fields to the Raceand Race Entry access path formats. Type V in theSubfile selector for both the Race format and the RaceEntry format as shown.

Press Enter.

The Virtualize Access Path panel displays showing thevirtual field, Course name, that can be added to theRace access path format.

Span Access Path and Edit Transaction Function

TUT 6–8 COOL:2E Tutorial

Page 9: **SYNON** HORSE MODEL

Press Enter to add the Course name virtual field to theRace access path format.

A Confirm prompt displays in the lower right-handcorner of the panel.

Press Enter to confirm the addition of the Course namevirtual field.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–9

Page 10: **SYNON** HORSE MODEL

COOL:2E again displays the Virtualize Access Pathpanel showing the virtual fields that can be added tothe Race Entry access path format. In this case, thevirtual fields are Horse name and Jockey name.

Press Enter to add these virtual fields to the RaceEntry access path format. A Confirm prompt displays inthe lower right-hand corner of the panel.

Press Enter to confirm the addition of the Horse nameand Jockey name virtual fields and return to the EditAccess Path Details panel.

Span Access Path and Edit Transaction Function

TUT 6–10 COOL:2E Tutorial

Page 11: **SYNON** HORSE MODEL

Details for theFirst AccessPath Format

The Edit Access Path Details panel displays bothformats. Next, display the details for the access pathformat by zooming against the Race access pathformat. This displays the Edit Access Path FormatEntries panel.

Type Z against the Race access path format as shown.

Press Enter .

Specifying theKey for the FirstAccess PathFormat

The next step is to check the keys of the Race accesspath format. You may specify any of the fields from theRACE file as keys, in either ascending or descendingorder. However, there must be a common key betweenthe two formats. For example, the header record keyfields must be part of the detail record’s key.

The keys will be defaulted to the keys as specified bythe file relations. In the case of two files linked by anOwned by relation, the default keys are recommended.If the two file formats are linked by a Refers to relation,you need to change the key order.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–11

Page 12: **SYNON** HORSE MODEL

Since in this example, RACE ENTRY is Owned byRACE, press Enter to accept the defaults.

Press F3 to exit and return to the Edit Access PathDetails panel.

Details for theSecond AccessPath Format

In this step you will zoom into the Race Entry accesspath format to check its key.

Type Z against the Race Entry access path format asshown.

Span Access Path and Edit Transaction Function

TUT 6–12 COOL:2E Tutorial

Page 13: **SYNON** HORSE MODEL

Press Enter .

The keys Course code, Race date, Race time, andEntry number have been selected by default to be thekeys of the format since these are the keys as definedby the file relations for the RACE ENTRY file.

Press Enter to confirm the keys.

Press F13 to exit and return to the Edit File Detailspanel.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–13

Page 14: **SYNON** HORSE MODEL

RequestingBatchGeneration ofthe SPN AccessPath

You have now finished the definition of the Races andEntries SPN access path. Request batch generation ofthe Races and Entries access path by typing J againstit as shown.

Press Enter .

The EditTransactionFunction

In this step you will define a function of type EditTransaction (EDTTRN).

Objectives You will create an Edit Transaction function for theRACE and RACE ENTRY files. The name of thefunction will be Edit Race and Entries and it will use theSPN access path Race and Entries you just created.This will provide the facility to enter both the racedetails and the race entry details for a given race on asingle panel.

Span Access Path and Edit Transaction Function

TUT 6–14 COOL:2E Tutorial

Page 15: **SYNON** HORSE MODEL

Defining the EditTransactionFunction

From the Edit File Details panel, you can transferdirectly to the Edit Functions panel for the RACE file bypressing F7.

Press F7 to access the Edit Functions panel.

Type the function details as shown; namely, type EditRace and Entries for the Function name, EDTTRN forthe Function type, Race and Entries for the Accesspath, and S to edit the device design.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–15

Page 16: **SYNON** HORSE MODEL

Press Enter to create the Edit Race and Entriesfunction and display the device design.

The DefaultDevice Design

The default device design for the Edit Race and Entriesfunction should look like the panel below. Note that thesubfile control (header) is positioned at the top with thesubfile record (detail) below. The common key of thetwo file formats displays only in the subfile control andacts as an implicit restrictor parameter to the subfiledetail records.

Note also the virtual fields Course name, Horse name,and Jockey name. If you had not explicitly added thesefields to the formats of the SPN access path, theywould not appear on this display.

Span Access Path and Edit Transaction Function

TUT 6–16 COOL:2E Tutorial

Page 17: **SYNON** HORSE MODEL

The ModifiedDevice Design

Update this default device design to look like the oneshown on the next panel. Use the function keys youused to edit the device design for the Edit Horse andSelect Horse functions earlier in this tutorial.

✍ Note: To move a field to another position on the panel,place the cursor on the field to be moved andpress F8. Position the cursor on the field thatappears before the desired position for the fieldyou are moving. Press F8. For example, place thecursor on the Finishing position field, and pressF8. Then position the cursor on the Horse namefield, and press F8 again. This moves theFinishing position field after Horse name.

DefiningOptional EntryFields

You have now updated the device design to meet theinitial requirements. However, by default, COOL:2Edefines all input-capable fields as required entry fields.To allow the end user to enter race entries withoutspecifying all the details about those entries, you canmake some of the fields optional. Note that onlynon-key fields can be optional.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–17

Page 18: **SYNON** HORSE MODEL

To make some of the fields in the RACE ENTRY fileoptional, position the cursor (❚) on a field in the firstsubfile record as shown.

Press F7.

This displays the relations for the subfile record format.You specify optional relations by typing O against therelations.

Type O against the relations as shown.

Span Access Path and Edit Transaction Function

TUT 6–18 COOL:2E Tutorial

Page 19: **SYNON** HORSE MODEL

Press Roll Up to view the remaining relations listed.Type O against the relation as shown.

Press Enter to confirm the changes to the formatrelations. Note that the values in the Check columnchanged from REQUIRED to OPTIONAL.

Press Roll Down to view the beginning of the list ofrelations.

Press F3 return to the device design.

Span Access Path and Edit Transaction Function

COOL:2E Tutorial TUT 6–19

Page 20: **SYNON** HORSE MODEL

Introduction to Function Fields

You will now add function fields to your device design.

New terms introduced

Function field

New panels introduced

Edit Device Function Field

Objectives Add a new field to the subfile control format of the EditTransaction panel that shows the number of horses thatfinished the race. To do so you will define a functionfield containing the total number of race entries havingan Entry Status of Finished.

Overview ofFunction Fields

Function fields are non-database fields that may beused in device designs and action diagrams. The samefunction field can be used in many different functions.

There are six types, or usages, of function fields. Fourprovide standard field-level functions: SUM, MIN, MAX,and CNT; two are user-defined and let you define yourown function fields: USR and DRV.

Function field parameters specify which field values areto be passed into the function field at execution timeand which field is to be returned from the function fieldas the result. All function fields with the exception ofUSR fields have one output parameter, the functionfield itself. The system-defined function fields have asingle input parameter. Derived function fields, of usageDRV, are specified in the action diagram and can haveup to nine input parameters.

Introduction to Function Fields

TUT 6–20 COOL:2E Tutorial

Page 21: **SYNON** HORSE MODEL

Adding FunctionFields

In this step, you will define a function field of usageDRV to evaluate whether or not a given race entryfinished a race. The DRV field will contain a value of 1if the horse finished and 0 if it did not. You will alsodefine a function field with a usage of SUM to calculatethe number of finishers. The sum of the values in theDRV function field gives the count of the number offinishers.

Position the cursor (❚) on the field that is to bedisplayed on the panel before the function field, in thiscase Handicap, as shown.

Press F19 to display the Edit Device Function Fieldpanel.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–21

Page 22: **SYNON** HORSE MODEL

Naming theFunction Field

If the function field already exists and you know itsname, you can fill in the name on the Edit DeviceFunction Field panel. Otherwise, type a ? to displayexisting fields.

Type ? for the Field name as shown.

Press Enter .

DisplayingExisting Fields

The ? displays a list of all existing fields. You canselect an existing function field or you can create a newone. In this tutorial, you will create two new functionfields.

Introduction to Function Fields

TUT 6–22 COOL:2E Tutorial

Page 23: **SYNON** HORSE MODEL

Defining TwoNew FunctionFields

To add the function fields you require, press F10 todisplay the Define Objects panel. You can define bothfunction fields at this point.

Here are the details for the two function fields:

1. Finished race is a function field that appears on eachsubfile record and evaluates whether or not thehorse finished a race. Its value is derived from thevalue of the Entry Status field. This requires ausage of DRV. You can edit the default field detailsdirectly by typing Y in Edit field.

2. No. of finishers is a function field in the subfilecontrol and is a sum of the values in the Finishedrace field of each subfile record. It is defined as aREF field based on the field Finished race.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–23

Page 24: **SYNON** HORSE MODEL

Type the new function fields as shown.

Press Enter.

Overriding theField Defaults

Since you specified Y for Edit field, you will be shownthe field details for the Finished race field. You can nowchange the internal field length to 3 from the Edit FieldDetails panel. Type 3 for internal length and press FieldExit .

Introduction to Function Fields

TUT 6–24 COOL:2E Tutorial

Page 25: **SYNON** HORSE MODEL

Press Enter . Press F3 to return to the Display Fieldspanel.

Displaying theFunction Fields

The Display Fields panel now has your new functionfields displayed. Note that you need to press Roll Upto view the No. of finishers function field.

Type P against Finished race as shown to edit itsparameters.

Press Enter to display the Edit Function Parameterspanel.

DefiningFunction FieldParameters

Next you are going to specify that Entry Status is aninput parameter to the Finished race function field. Youwill use the same Edit Function Parameters panel youused to specify function parameters earlier in thistutorial.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–25

Page 26: **SYNON** HORSE MODEL

Type the details for the Entry Status parameter asshown. The usage of this parameter defaults to input.Check the parameter usage by also typing Z againstthe field.

Press Enter. The Edit Function Parameter Details paneldisplays showing the Usage for Entry Status as I(input).

Press F3 to return to the Edit Function Parameterspanel.

Introduction to Function Fields

TUT 6–26 COOL:2E Tutorial

Page 27: **SYNON** HORSE MODEL

The derived (DRV) function field itself, Finished race, isautomatically defined as an output parameter. Checkthis by displaying the parameter details. Type Z againstthe Finished race field to display the Edit FunctionParameter Details panel. Note that the Usage for thisparameter is O (output).

Press F3 twice to exit and return to the Display Fieldspanel.

Selecting theFunction Field

You have just finished declaring the function fields inCOOL:2E. After returning to the Display Fields panel,you need to select the Finished race function field forinclusion on the device design. First, type Finished inthe positioner line and press Enter to position to thenew function fields.

Type X next to Finished race as shown.

Press Enter .

Introduction to Function Fields

COOL:2E Tutorial TUT 6–27

Page 28: **SYNON** HORSE MODEL

Accepting theParameters

The Edit Action - Function Details window is displayedshowing the parameters for the Finished race functionfield. Note that the input parameter is Entry Status, theoutput parameter is Finished race, and both parametershave the RCD (subfile record) context.

Press Enter to accept the default parameters andreturn to the device design.

Introduction to Function Fields

TUT 6–28 COOL:2E Tutorial

Page 29: **SYNON** HORSE MODEL

The ModifiedDevice Design

After returning to the device design, note that theFinished race function field has been added to thesubfile record.

Note that since the device design exceeds the limits ofthe panel, you will need to adjust this device designlater in the tutorial.

Press F3 to exit and display the Edit Function Devicespanel.

Defining aFunction FieldAction Diagram

You will now define the action for the user-defined(DRV) function field, Finished race. This will requireentering logic into the action diagram for the Edit Raceand Entries function.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–29

Page 30: **SYNON** HORSE MODEL

Press F5 to view the action diagram for the Edit Raceand Entries function.

Press F5 to view the Action Diagram User Points.

Recall that the user points are the places in the actiondiagram that you can change.

Introduction to Function Fields

TUT 6–30 COOL:2E Tutorial

Page 31: **SYNON** HORSE MODEL

Press Roll Up to see the next set of user points.

Type Z against the CALC: Subfile record function fieldsuser point as shown.

Press Enter . Note that COOL:2E automatically insertedthe Finished Race function field in the action diagramfor the Edit Race and Entries function.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–31

Page 32: **SYNON** HORSE MODEL

Type Z against Finished Race as shown to insert logicfor the function field.

Press Enter .

Adding a CASEConstruct

The action diagram for the function field Finished racewill be displayed. Note that you are now editing theFinished race function as shown in the upper rightcorner of the panel. You will use the Action DiagramEditor to insert the following conditions and actions forthe Finished race function field.

CASE Condition 1 Action 1 Condition 2 Action 2 ENDCASE

Does Entry Status = Finished?Yes, set Finished race to 1*OTHERWISESet Finished race to 0

Introduction to Function Fields

TUT 6–32 COOL:2E Tutorial

Page 33: **SYNON** HORSE MODEL

Type IC as shown.

Press Enter.

Adding an Action Insert an action into the action diagram. Type IA asshown.

Press Enter .

Introduction to Function Fields

COOL:2E Tutorial TUT 6–33

Page 34: **SYNON** HORSE MODEL

Adding aSecondCondition

Add another condition to the CASE construct by typingIX against the first !!! New condition as shown. Recallthat IX inserts a new condition within a CASE construct.

Press Enter.

Adding aSecond Action

Add another action to the CASE construct by typing IAagainst the second !!! New condition as shown.

Press Enter .

Introduction to Function Fields

TUT 6–34 COOL:2E Tutorial

Page 35: **SYNON** HORSE MODEL

Defining theConditions andActions

To define the conditions and actions, type F againstthem all, and press Enter . Recall that F lets you editthe action or condition details for a line in the actiondiagram.

Type F against the conditions and actions as shown.

Press Enter .

Specifying theFirst Condition

The first condition specifies that the action is only to beexecuted if the Entry Status is Finished.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–35

Page 36: **SYNON** HORSE MODEL

Type the details as shown. Type PAR (parameter) forthe context, Entry Status for the Field, and ? in thecondition field to view a list of the available conditions.

Press Enter .

Defining FieldConditions forthe Status Field

If you completed the earlier exercise of definingconditions for the Entry Status field, the Edit Field -Condition window panel will include the list ofconditions shown here. If you have not already doneso, you can add them at this point.

Introduction to Function Fields

TUT 6–36 COOL:2E Tutorial

Page 37: **SYNON** HORSE MODEL

Type X against the condition Finished as shown.

Press Enter twice.

Specifying theFirst Action

You have just finished defining the first condition in theCASE construct you are defining. Because you alsotyped F against the first action in the CASE construct,COOL:2E displays the Edit Action - Function Namewindow to specify the action. In this case, the actionwill be the built-in function *MOVE.

The action you are specifying is executed when the firstcondition is true; namely, when Entry Status isFinished. The action is to return a constant value ofone in the Finished race function field.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–37

Page 38: **SYNON** HORSE MODEL

Leave the Function file field blank to indicate a built-infunction and type *MOVE as shown.

Press Enter to enter parameter details for the *MOVEfunction.

Type the details for the *MOVE parameters as shown.

Press Enter .

Introduction to Function Fields

TUT 6–38 COOL:2E Tutorial

Page 39: **SYNON** HORSE MODEL

Specifying theSecondCondition

Because you typed F against the second new conditionin the action diagram CASE construct, COOL:2Edisplays the Edit Action - Condition window. Thesecond condition specifies the action to be executed inall cases other than that specified in the first condition.A special value of *OTHERWISE is used for this case.

Remove the ?’s and specify *OTHERWISE for thecondition.

Press Enter .

Defining theSecond Action

Because you typed F against the second action,COOL:2E displays the Edit Action - Function Namewindow. For the second action, you will specify theaction to take when the first condition is not true. Theaction is to return a value of zero in the Finished racefunction field. You will again use the *MOVE built-infunction.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–39

Page 40: **SYNON** HORSE MODEL

Leave the Function file field blank and specify the*MOVE function as shown.

Press Enter to enter parameter details for the *MOVEfunction.

Type the details for the *MOVE parameters as shown.

Press Enter to accept the parameters as shown andreturn to the Action Diagram Editor.

Introduction to Function Fields

TUT 6–40 COOL:2E Tutorial

Page 41: **SYNON** HORSE MODEL

Complete ActionDiagram

The completed action diagram should look like this.

Press F13 to exit the action diagram for the Finishedrace function field.

Accept the default of Y to save the Finished racefunction field.

Press Enter to return to the action diagram for the EditRace and Entries function.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–41

Page 42: **SYNON** HORSE MODEL

Press F13 to exit the action diagram for the Edit Raceand Entries function.

Accept the default of Y to save the function definition.

Press Enter .

Returning to theDevice Design

You have now finished defining the Finished racefunction field. Return to the device design to define theNo. of finishers function field.

Introduction to Function Fields

TUT 6–42 COOL:2E Tutorial

Page 43: **SYNON** HORSE MODEL

Type S against the Edit Race and Entries function asshown.

Press Enter .

Adding theSecondFunction Field

Add the second function field to the header format(subfile control). Position the cursor (❚) on the fieldbefore the desired location for the function field, in thiscase Prize money, as shown and press F19.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–43

Page 44: **SYNON** HORSE MODEL

Specifying theSecondFunction Field

The required field already exists; as a result, you cantype the name No. of finishers directly. Alternatively youcould type ? to obtain a selection list.

Type the function field name No. of Finishers as shown.

Press Enter .

DefiningParameters forthe No. offinishersFunction Field

The parameters for the No. of finishers function fieldare defaulted. The input parameter is Finished racefrom the RCD (subfile record) context; the outputparameter is the No. of finishers function field itself inthe CTL (subfile control) context. Recall that youdefined the No. of finishers function field with the SUMfield usage. This causes the values in the inputparameter field (Finished race) for each detail record toautomatically be added together and the sum to beplaced in the output parameter (No. of finishers).

Introduction to Function Fields

TUT 6–44 COOL:2E Tutorial

Page 45: **SYNON** HORSE MODEL

Press Enter to accept the default parameters as shown.

The AddedFunction Field

The No. of Finishers field will be added to the subfilecontrol format.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–45

Page 46: **SYNON** HORSE MODEL

Readjusting theDevice Design

Adjust the device design so that all fields fit on thepanel. Move the No. of finishers function field to a newline and hide the Finished race function field so that itis not displayed.

To do the latter, position the cursor (❚) on the field andpress Enter . The Edit Screen Entry Details paneldisplays. Change the I/O usage for the field to hidden(H) as shown.

Press Enter . The final device design should look likethis:

Introduction to Function Fields

TUT 6–46 COOL:2E Tutorial

Page 47: **SYNON** HORSE MODEL

Press F3 to go to the Edit Function Devices panel.

Exiting theDevice Design

You have finished creating the function Edit Race andEntries and designed an appropriate panel layout.

Exit from the Edit Function Devices panel by pressingF3. The Exit Function Definition panel displays.

Submitting theFunction forGeneration

In addition to saving changes to the function, you canuse the Exit Function Definition panel to submit thefunction and display file for generation by setting theSubmit generation field to Y.

Introduction to Function Fields

COOL:2E Tutorial TUT 6–47

Page 48: **SYNON** HORSE MODEL

Accept the default of Y for Change/create function tosave your changes and change the Submit generationfield to Y.

Press Enter .

You will be returned to the Edit Functions panel.Messages indicating that the function has been savedand submitted for generation will appear at the bottomof the panel.

Introduction to Function Fields

TUT 6–48 COOL:2E Tutorial

Page 49: **SYNON** HORSE MODEL

You have now created a program that allows the enduser to update the two files, RACE and RACE ENTRY,simultaneously.

Exercises Do the following exercises in the order shown:

1. Submit the request for generation and compilation forthe Races and Entries SPN access path and theEdit Races and Entries function. You do this byselecting the Submit model create request(YSBMMDLCRT) option from the Display ServicesMenu (F17). For a program to compile successfully,all files and access paths used by the programmust have been generated and compiled first.

✍ Note: Be sure to write down the implementation name forthe Edit Races and Entries function. You will needthis name for testing the program using the CALLcommand.

2. Call the Edit Races and Entries function and add afew races to the database and some entries foreach race. When you call the program, rememberto specify the null or blank parameter for the returncode. For example,

call myaretr ’’

Try pressing F4 on fields like Horse code and Jockeycode to view a selection list of available entries.

✍ Note: COOL:2E automatically provides this promptingcapability for file-to-file relations, such as, RACEENTRY Refers to HORSE. When the end usertypes a ? or user prompt (F4) for a key or foreignkey field, by default COOL:2E calls the relatedSelect record function, such as, Select Horse. Afunction used in this way is known as a promptfunction .

Introduction to Function Fields

COOL:2E Tutorial TUT 6–49

Page 50: **SYNON** HORSE MODEL

3. Call the Edit Horse program and test the link youdefined between the Edit Horse program and theDisplay Racing Results program. You should beable to select a horse and display its racing history.

For example, the steps required to call DisplayRacing results for Faithful Dobbin are:

a. Type / in Subfile selector for Faithful Dobbin.

b. Press F10 to access the action bar.

c. Type S to access the Selector Choice menu.

d. Type 1 beside the Display Racing Results action.

e. Press Enter .

f. Press F3 to return to the Edit Horse function.

Introduction to Function Fields

TUT 6–50 COOL:2E Tutorial