Sei sulla pagina 1di 108

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

D17669GC10

1.0

April 2004

D40576

PeopleCode

Volume I Activity Guide

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Copyright © 2004, 2005, Oracle. All rights reserved.

This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.

The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free.

If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.

Oracle, JD Edwards, and PeopleSoft are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

C ONTENTS

Preface

PeopleCode Typographical Conventions and Visual Cues Related Documentation

Lesson 1

Course

Overview

Lesson 2

Technology Overview

Lesson 3

Using PeopleCode Development Tools

Activity 1:

Reviewing the Application Development Process

Activity 2:

Using the PeopleCode Editor

Activity 3:

Debugging a PeopleCode Program

Lesson 4

Describing the Component Processor

Activity 4:

Watching the Search Events Run

Activity 5:

Watching the Component Build Events Run

Activity 6:

Watching the Row Action Events Run

Lesson 5

Lesson 6

Lesson 7

Lesson 8

Lesson 9

Lesson 10

Lesson 11

Lesson 12

Activity 7:

Activity 8:

Activity 9:

Watching the Save Action Events Run

Examining Deferred Processing

Choosing the Right Events

Writing PeopleCode Programs

Understanding PeopleCode Events

Activity 10:

Activity 11:

Using SearchInit to control the Search Page

Synchronizing the Student Table with the Customer Table

Using PeopleCode Variables

Activity 12:

Activity 13:

Using Derived Work Fields

Setting Up a Variable Prompt Table Edit

Using Built-In Functions

Activity 14:

Using Built-In Functions

Writing PeopleCode Functions

Activity 15:

Writing Functions

Explaining the Component Buffer

Activity 16:

Determining the Contents of the Component Buffer

Accessing Data in the Component Buffer

Programming With Object-Oriented PeopleCode

Activity 17:

Using Object-Oriented Methods and Properties

v

v

vi

1

3

5

6

9

12

15

16

18

20

22

23

25

27

29

30

32

37

38

41

43

44

47

48

51

52

55

57

58

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

PeopleCode

Lesson 13

Referencing Data in the Component Buffer

Activity 18:

Stepping Through the Data Buffer

Activity 19:

Traversing the Data Buffer

Activity 20:

Accessing Multiple Occurs Levels

Lesson 14

Creating Custom Objects with Application Classes

Activity 21:

Writing an Application Class

Activity 22:

Calling Hello World

Activity 23:

Using Application Classes

Lesson 15

Using Data Buffer Methods

Activity 24:

Using Select to Refresh Get Enrollments

Activity 25:

Adding the Flush Method

Lesson 16

Executing SQL in PeopleCode

Activity 26:

Updating Effort Spent With a SQLExec Statement

Activity 27:

Creating a SQL Definition

Activity 28:

Using a SQL Object

Activity 29:

Choosing the Best SQL Option

Activity 30:

Executing SQL in PeopleCode

Lesson 17

Lesson 18

Final Course Activity

Activity 31:

Using a Standalone Rowset to Track Overtime Hours

Course Review

Contents

61

62

67

69

71

72

74

75

79

80

84

87

88

89

91

92

94

97

98

101

Oracle Internal

Oracle

Preface

PeopleCode

Typographical Conventions and Visual Cues

This section discusses:

Typographical conventions.

Visual cues.

Typographical Conventions

This table contains the typographical conventions that are used in this guide:

Typographical Convention

Description

Bold

Indicates PeopleCode function names, method names, language

constructs, and PeopleCode reserved words that must be included

literally in the function call.

Italics

Only

Use Only

Indicates field values, emphasis, and PeopleSoft or other book-

length publication titles. In PeopleCode syntax, italic items are

placeholders for arguments that your program must supply.

We also use italics when we refer to words as words or letters as

letters, as in the following: Enter the letter O.

Internal & & OAI

KEY+KEY

OAI Use

Indicates a key combination action. For example, a plus sign (+)

between keys means that you must hold down the first key while

you press the second key. For ALT+W, hold down the ALT key

while you press the W key.

Monospace font

Indicates a PeopleCode program or other code example.

“ ” (quotation marks)

Indicate lesson and chapter titles in cross-references and words that

are used differently from their intended meanings.

.

(ellipses)

Indicate that the preceding item or series can be repeated any

number of times in PeopleCode syntax.

{ } (curly braces)

Indicate a choice between two options in PeopleCode syntax.

Options are separated by a pipe ( | ).

[ ] (square brackets)

Indicate optional items in PeopleCode syntax.

& (ampersand)

When placed before a parameter in PeopleCode syntax, an ampersand indicates that the parameter is an already instantiated object.

Ampersands also precede all PeopleCode variables.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

PeopleCode

Visual Cues

Training courses contain the following visual cues.

Preface

Notes

Notes indicate information that you should pay particular attention to as you work with the PeopleSoft system.

Note. Example of a note.

If the note is preceded by Important!, the note is crucial and includes information that concerns what you must do for the system to function properly.

Important! Example of an important note.

Warnings

Warnings indicate crucial configuration considerations. Pay close attention to warning messages.

Warning! Example of a warning.

Cross-References

Training guides provide cross-references either under the heading “See Also” or on a

separate line preceded by the word See. Cross-references lead to other documents, such

as PeopleBooks, that are pertinent to the immediately preceding documentation.

Example:

to the immediately preceding documentation. Example: Example of cross-reference to a PeopleBook Related

Example of cross-reference to a PeopleBook

Related Documentation

PeopleSoft applications are documented in PeopleBooks, which are delivered on the

PeopleBooks CD-ROM. You can also order printed, bound versions of PeopleBooks

through the Documentation section of the PeopleSoft Customer Connection website. You

can find updates and additional documentation for each release on the PeopleSoft

Customer Connection website.

See Also

PeopleSoft Customer Connection, http://www.peoplesoft.com/corp/en/login.asp

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 1

Course Overview

This lesson has no activities.

Course Overview

Lesson 1

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 2

Technology Overview

This lesson has no activities.

Technology Overview

Lesson 2

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 3

Using PeopleCode Development Tools

Using PeopleCode Development Tools

Lesson 3

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 1:

Reviewing the Application Development Process

In this activity, you will review the activity overview and review the eight steps of application development using the Training Tasks application as an example.

See PeopleCode: Activity Guide, “Using PeopleCode Development Tools,” Activity 1:

Reviewing the Application Development Process.

Slide 23

Activity Overview

In this activity, you will review the eight steps of application development, looking at specific examples of how those steps were implemented to create the Training Tasks application. In the process, you will consider how PeopleCode can be used to enhance and complete the application.

Reviewing the Application Development Process

The eight steps are application development are:

1. Plan the application.

2.

3.

4.

5.

6.

7.

8.

Define new fields and translate values.

Create record definitions.

Build Application Data tables.

Create the page definition.

Define the component.

Register the component.

Test.

Step 1: Planning the Application

This is probably the most difficult step in the entire process. Fortunately, our application

has been designed for us.

1.

2.

Step 2: Creating Fields

1.

In Application Designer, open the PSU_TASKS project. This will make accessing

the objects easier as we discuss them.

Select Tools, Options and select the Insert definition into project when definition is

modified and saved radio button and the Reload last project at startup checkbox.

Launch Application Designer.

a. Select Start, Programs, PeopleTools 8.44, Application Designer.

Lesson 3

Using PeopleCode Development Tools

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

b. Verify that your connection type is Application Server.

c. Select your database.

In the Central Training Environment (CTE) your database name will end in the last two digits of your student ID. For instance, if your student ID is STA107, then your database name might be T1B84407.

d. For User ID, enter PTCODE.

e. For password, enter PTCODE.

2. In the project workspace, expand the Fields folder.

3. Open the field TASK_STATUS by double-clicking it.

Field characteristics are global and are defined on the field definition, not on the record definition. Change any field characteristic, and it will automatically be changed in every record in which that field is used.

4. Select the Properties button to look at the field’s translate values.

Step 3: Creating Records

1. Open the PSU_TASK_RSRC record definition.

2. Notice that the default display is the Field Display.

3.

4.

5.

6.

Select the Use Display button on the toolbar.

Double-click RESOURCE_NAME. Notice the default.

Double-click INSTRUCTOR.

Open the PSU_TASK_EFFORT record definition.

Step 4: Building the SQL Table

This is the most frequently forgotten step! Fortunately we don’t need to build any tables.

Step 5: Creating Pages

1.

2.

Open the page PSU_TASK_RESOURCES.

Select the Order tab. Notice the Allow Deferred Processing column. Even if it’s

checked here, deferred processing must be enabled at the component level.

Step 6: Creating Components

1.

Open the component PSU_TASK_RESOURCES.

2.

Open the component properties. (You need to be on the component’s Definition tab,

not the Structure tab, to open properties.)

3. Select the Internet tab. Notice the Processing Mode choices: Deferred and Interactive. We’ll spend more time on deferred processing later.

4. Close the Properties.

Using PeopleCode Development Tools

Lesson 3

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

5. Look at the Structure tab. Note the hierarchy of scrolls, records, and fields.

Step 7: Registering Components

The Component Registration Wizard attaches components to menu definitions, assigns security access for users, and places navigational links in the registry. You won’t need to use the Component Registration Wizard in this course.

Step 8: Testing

1. Launch Internet Explorer.

a. For User ID, enter PTCODE.

b. For password, enter PTCODE.

2. Select Set Up Training, Training Tasks, Task Table to access the Tasks component.

3. Select Set Up Training, Training Tasks, Task Resources and Efforts to access the Task Resources component.

4. Make sure to test by trying everything that a user can do in these components. For instance:

Add a new task.

Associate resources and efforts to the new task, including insertions and deletions

in both scrolls.

Check prompts, defaults, etc.

Verify that rows have been written to the appropriate database tables.

This concludes the activity. Do not continue.

Lesson 3

Using PeopleCode Development Tools

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 2:

Using the PeopleCode Editor

In this activity, you will review the activity overview and experiment with several features of the PeopleCode Editor.

See PeopleCode: Activity Guide, “Using PeopleCode Development Tools,” Activity 2:

Using the PeopleCode Editor.

Slide 32

Using the PeopleCode Editor

You launch the PeopleCode editor by opening a PeopleCode program.

1. Open the PeopleCode program on the record field PSU_STUDENT_TBL.SAME_ADDR_CUSTOMER.FIELDCHANGE.

Use any of the techniques you have learned to open the program in the PeopleCode Editor.

2. Note that the text is color coded.

The default color code for the PeopleCode Editor is:

3.

Keywords, built-in functions, and class definitions are blue.

Quoted strings are red.

Comments are green.

Select the left drop-down list.

Notice that it shows the current field. Fields that have PeopleCode display in bold

type.

4.

Select the right drop-down list.

Notice that it displays the current PeopleCode event.

Selecting it allows you to change events. Events with PeopleCode programs will

display in bold type.

5.

Choose the field STUDENT_NAME and the event FieldEdit.

The larger text editor portion behaves like a standard text editor.

6.

7.

Enter the following text into the text editor, exactly as shown:

If ^ = student_id then warning "Student name equals student id.";

Save.

When you save or select Validate Syntax, the PeopleCode Editor checks syntax and automatically formats the code.

Using PeopleCode Development Tools

Lesson 3

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

8. Did you get an error?

Add the following to the end of the line:

End-if;

9. Save again.

Notice the following features of the PeopleCode Editor:

If the editor encounters a caret (^) it replaces it with the current field name.

If the editor encounters a field name, it checks to see whether the field belongs to the current record definition. If it does, it prepends the record name.

If the name doesn’t exist, Validate Syntax displays a message in the Validate pane but does not generate an error.

The editor capitalizes PeopleCode functions and constructs, puts keywords and definition names in all caps and matches the case of all variables to the first occurrence.

Text in quoted literals is ignored.

Validate Syntax checks for auto-declared variables and displays a message in the Validate pane.

10.

Cut, copy, paste, and undo are available, as in other text editors.

The PeopleCode definition is not saved with the record definition. It is stored in

other PeopleTools tables.

Position your cursor in the word Warning and press F1.

The PeopleCode PeopleBook opens to the Warning function.

11.

Position your cursor in the word PSU_STUDENT_TBL.

Right-click and choose view definition.

You can view any definition, or the PeopleCode associated with a definition, by

right-clicking the definition name in a program.

12.

13.

If a user-defined function is referenced in a program, you can open that program by

right-clicking in the function name and selecting View Function.

The PeopleCode Editor supports drag and drop. Try dragging the following from the

project view into the editor pane (do not save):

A record definition.

A record field (a field name within a record definition).

A component definition.

You can also drag and drop from a definition that is open in the definition workspace and from one PeopleCode program to another.

Lesson 3

Using PeopleCode Development Tools

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

14. Navigate to the Z:\<Student ID>\temp\ directory, where <Student ID> is your CTE student ID (for example, Z:\STA107\temp\).

a. Locate the file with the name PPCMMDDYY_HHMMSS.txt, where MMDDYY is today’s date and HHMMSS is the time the file was generated.

b. Double-click the file to open it in Notepad.

This is your PeopleCode AutoSave file. The PeopleCode editor automatically backs up every keystroke between saves.

15. You can modify the font and colors used in the PeopleCode Editor.

a. Return to Application Designer.

b. Select Edit, Display Font and Colors…

This concludes the activity. Do not continue.

Using PeopleCode Development Tools

Lesson 3

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 3:

Debugging a PeopleCode Program

In this activity, you will review the activity overview and investigate the features of the PeopleCode debugger.

See PeopleCode: Activity Guide, “Using PeopleCode Development Tools,” Activity 3:

Debugging a PeopleCode Program.

Slide 34

Activity Overview

In this activity, you will open the PeopleCode program at ORDER_LINE_NBR.RowInsert on PSU_PO_DTL. You will set a breakpoint in the program and run the application until it hits the breakpoint. Then you will explore the types of information and options available to you through the Debugger.

Debugging a PeopleCode Program

1. In this activity, you will:Open a PeopleCode program.

2. Start the PeopleCode Debugger.

3.

4.

5.

6.

7.

Set a visible breakpoint.

View values using Hover Inspect.

View values in the variables panes.

Look at the Debug Log Options.

Exit PeopleCode Debugger.

Opening a PeopleCode Program to Debug

1.

Maximize your Application Designer window and close the Output Window (View,

Output Window) to make more room for your Debugger panes.

2.

3.

4.

5.

In Application Designer, open the record PSU_PO_DTL.

Open the program for ORDER_LINE_NBR.RowInsert.

Verify that you have the correct event: RowInsert, not RowDelete.

Close your Output pane (ALT+1) to make more room.

Starting the PeopleCode Debugger

1.

From the menu, choose Debug, Enter Debug Mode.

2.

The Local Variables watch window opens. If there are PeopleCode programs that had

breakpoints set from a previous debugging session, they are opened as well, and the

breakpoints are restored.

Lesson 3

Using PeopleCode Development Tools

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

3. Choose Debug, View Component Buffers. The Component Buffers pane opens.

Setting Visible Breakpoints

The Debugger supports visual indicators that signify breakpoint locations.

1. Place your cursor on the fourth line of code

If &LINE > &MAXLINE Then

and select Debug, Toggle Break at Cursor.

A red dot appears in the gutter beside the line of code.

2. To test, in the browser navigate to the Purchase Orders page.

Select Purchasing, Maintain Purchase Orders.

3. Select Order Number 00000029.

4. Position your cursor on the second line and insert a row (+…).

5. Return to Application Designer. Notice the green arrow that marks the current PeopleCode statement.

Viewing Values Using Hover Inspect

You can position the cursor (hover) over variables in the PeopleCode Editor to see their

current value.

Hover over &I and hold it until you see a pop-up containing the value of the variable.

You can also hover inspect field names to see the current value of the field.

Viewing Values in the Variables Panes

By default, the Local Variables pane appears with the debugger. This shows the values of

the variables and the properties of objects. You can expand objects here to view more

details about them.

You can also open panes for global variables, component variables, and function

parameters.

1.

Press F8 to step to the next line of code.

The arrow that shows the current line of execution will move to the next line.

Continue to step through the code and notice how the variables change as you loop

through the rows in the component.

2.

Look at the component buffers window. This window gives you a view of all the data

in

the component buffer.

Drill down until you see the values for the fields on the page.

Warning! Don’t drill down on ParentRowset and ParentRow. You can end up in an endless loop.

Using PeopleCode Development Tools

Lesson 3

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Creating a Debug Log

You can output a debug log to the Application Designer PeopleCode Log output pane.

Select Debug, Options, Log Options

Note the checkboxes available for various options. You can also choose to save your debug log. Be aware that logging will have a severe effect on performance.

Exiting PeopleCode Debugger

You should clean up before you exit the debugger.

1. Before exiting the Debugger it is good practice to clear your breakpoints. Go to Debug, Edit Breakpoints and click the Remove All push button.

2. Select Debug, Abort Running Program.

3. Select Debug, Exit Debug Mode.

4. Window, Close All.

This concludes the activity. Do not continue.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 4

Describing the Component Processor

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 4:

Watching the Search Events Run

In this activity, you will review the activity overview and place WinMessages in SearchInit and SearchSave so that you can see exactly when those events run in the Component Processor flow.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 4:

Watching the Search Events Run.

Slide 53

Activity Overview

By placing a WinMessage in an event, you can see exactly when that event runs. In this activity, you will place a WinMessage in SearchSave and SearchInit.

Watching the Search Events Run

To place WinMessages in SearchSave and SearchInit:

1. In PeopleSoft Application Designer, open the PSU_INSTR component definition.

2. From the left drop-down list, select PSU_INSTR_TBL (record).

3.

4.

5.

6.

7.

8.

9.

From the right drop-down list, select SearchInit.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("SearchInit on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C);

From the right drop-down list, select SearchSave.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("SearchSave on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C);

Click the Save button.

Select Window, Close All.

In the PeopleSoft Internet Architecture, select Instructors, Professional Details.

The following message appears

“SearchInit on COMPONENT.PSU_INSTR, PSU_INSTR_TBL <Instructor> C = 1”

10. Click OK.

Lesson 4

Describing the Component Processor

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

The search page for Instructor, Professional Details appears.

11.

For Instructor, enter JEG and then click the Search button.

The following message appears:

“SearchSave on COMPONENT.PSU_INSTR, PSU_INSTR_TBL <Instructor> C =

2”

12.

Click OK.

The Instructor, Professional Details page appears.

This concludes the activity. Do not continue.

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 5:

Watching the Component Build Events Run

In this activity, you will review the activity overview and place WinMessages in PreBuild and RowInit so that you can see exactly when those events run in the Component Processor flow.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 5:

Watching the Component Build Events Run.

Slide 55

Activity Overview

By placing a WinMessage in an event, you can see exactly when that event runs.

In this activity you will place WinMessages in PreBuild and RowInit.

Watching the Component Build Events Run

To watch the component build events run:

1. In PeopleSoft Application Designer, open the PeopleCode Editor for the PSU_INSTR component definition.

2.

3.

4.

5.

6.

7.

8.

9.

From the left drop-down list, select PSU_INSTR_TBL (record).

From the right drop-down list, select RowInit.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("RowInit on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C, 0);

From the left drop-down list, select PSU_INSTR.GBL (component)

From the right drop-down list, select PreBuild.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("PreBuild on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C, 0);

Click the Save button.

Select Window, Close All.

10. If you have the Training application open in PeopleSoft Internet Architecture, log out and log in again.

Lesson 4

Describing the Component Processor

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Because you have changed the PeopleCode, you need to refresh the cache.

11. In the PeopleSoft Internet Architecture, select Instructors, Professional Details.

12. Select the Correct History check box.

13. Select instructor JGY (Joe Young).

14. Observe the order in which the messages are displayed, and how often.

This concludes the activity. Do not continue.

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 6:

Watching the Row Action Events Run

In this activity, you will review the activity overview and place a WinMessage in RowInsert so that you can see exactly when this event runs in the Component Processor flow.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 6:

Watching the Row Action Events Run.

Slide 58

Activity Overview

By placing a WinMessage in an event, you can see exactly when that event runs.

In this activity, you will place a WinMessage in RowInsert.

Watching the Row Action Events Run

To watch the row action events run:

1. In PeopleSoft Application Designer, open the PeopleCode Editor for the PSU_INSTR component definition.

2.

3.

4.

5.

6.

7.

From the left drop-down list, select PSU_INSTR_TBL (record).

From the right drop-down list, select RowInsert.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("RowInsert on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C, 0);

Click the Save button.

Select Window, Close All.

If you have the Training application open in PeopleSoft Internet Architecture, log out

and log in again.

Because you have changed the PeopleCode, you need to refresh the cache.

8.

9.

In PeopleSoft Internet Architecture, select Instructors, Professional Details.

Select the Correct History check box.

10.

11.

Select the instructor JGY (Joe Young).

Click the + button at level 1 (Instructor Information) to insert a new level 1 row.

12. Observe which events run.

Lesson 4

Describing the Component Processor

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

This concludes the activity. Do not continue.

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 7:

Watching the Save Action Events Run

In this activity, you will review the activity overview and place a WinMessage in SaveEdit so that you can see exactly when this event runs in the Component Processor flow.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 7:

Watching the Save Action Events Run.

Slide 60

Activity Overview

In this activity, you will place a WinMessage in SaveEdit.

Watching the Save Action Events Run

To watch the save action events run:

1. In PeopleSoft Application Designer, access the PSU_INSTR component definition.

2. Open the PeopleCode Editor.

3.

From the left drop-down list, select PSU_INSTR_TBL (record).

4.

5.

From the right drop-down list, select SaveEdit.

Enter the following code:

Component Integer &C;

&C = &C + 1;

WinMessage("SaveEdit on COMPONENT.PSU_INSTR, PSU_INSTR_TBL " |

PSU_INSTR_TBL.INSTRUCTOR | " C = " | &C, 0);

6.

Click the Save button.

7.

8.

9.

10.

11.

12.

13.

Select Window, Close All.

If you have the Training application open in PeopleSoft Internet Architecture, log out

and log in again to refresh the cache.

In PeopleSoft Internet Architecture, select Instructors, Professional Details.

Select the Correct History check box.

Select instructor JGY (Joe Young).

Make a change to the page. (Give Joe a middle initial.)

Click the Save button.

14. Observe the displayed messages to determine which events run.

This concludes the activity. Do not continue.

Lesson 4

Describing the Component Processor

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 8:

Examining Deferred Processing

In this activity, you will review the activity overview and look at the settings to control deferred processing for the component, the page, and the field.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 8:

Examining Deferred Processing.

Slide 66

Activity Overview

In this activity, you will look at the settings on component definitions, page definitions, and page field properties that control deferred processing.

Examining Deferred Processing

At the component level, the processing mode is set in the Component Properties dialog box, on the Internet tab. By default, under Processing Mode, the Deferred radio button is selected, meaning that deferred processing is on.

To examine deferred processing:

1.

In PeopleSoft Application Designer, open the PSU_TASK_RESOURCES.GBL

component.

2.

3.

Access the component properties and select the Internet tab.

In the Processing Mode group box:

To turn deferred processing off, select Interactive.

To turn deferred processing on, select Deferred.

Accept the default for this component, Deferred.

4.

In the Allow Expert Entry check box:

Select Allow Expert Entry to enable the Allow Expert Entry check box on the

component.

Enable Expert Entry must also be selected for the user profile in Security

(PeopleTools, Security, User Profiles, User Profiles, General).

Note. Expert Entry is only meaningful if the component is in interactive mode. If the

component is in deferred mode, the Expert Entry checkbox will have no effect.

5.

Select the Refresh check box in the Toolbar group box.

When the Refresh check box is selected, a Refresh button is displayed in the component toolbar that allows the user to force a trip to the server.

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Users can always press ALT-0 to force a server trip, even if the Refresh button is not displayed.

6. Open the PSU_TASK_RESOURCES page.

7. Access the Page Properties, Use tab.

Notice that the Allow Deferred Processing check box is selected.

8. Click the Cancel button.

9. From the PSU_TASK_RESOURCES page, open the Instructor page field and select the Use tab.

Notice that the Allow Deferred Processing check box is selected.

10. Clear the Allow Deferred Processing check box to make this field interactive and then click the OK button.

11. Select the Order tab on the PSU_TASK_RESOURCES page.

12. Scroll to the far right.

Notice that the check boxes for Allow Deferred Processing are display only and cannot be changed here. Also notice that the check box for the INSTRUCTOR field is cleared.

13.

Click the Save button.

This concludes the activity. Do not continue.

Lesson 4

Describing the Component Processor

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 9:

Choosing the Right Events

In this activity, you will review the activity overview and choose the correct events in which to place PeopleCode to enforce three business rules.

See PeopleCode: Activity Guide, “Describing the Component Processor,” Activity 9:

Choosing the Right Events.

Slide 67

Activity Overview

Before beginning any PeopleCode customization, ask these three questions:

1. WHEN (Event)? When should the PeopleCode be performed? In other words, which PeopleCode event should be used? Sometimes more than one is required.

2. WHERE (Definition/Field)? Where should the PeopleCode programs be attached? Depending on where the PeopleCode is placed, processing may be affected.

3. WHAT (Syntax)?

What will the PeopleCode look like? Notice that this is the last step. Once the first

two questions have been answered, the syntax is usually fairly straightforward.

In this activity, you will write PeopleCode programs to address three business rules. The

code for these programs is straightforward. The greater challenge will be choosing the

correct event for each program. Keep the three questions in mind while working on the

following customizations:

1.

2.

3.

On the Task Resources page, make sure that a resource is not available more than

100 percent of the time.

Make sure that a resource cannot be deleted from the Task Resources page if the

resource has finished the task.

On the Tasks page, if a start date and an end date have been entered, make sure that

the end date does not precede the start date.

Choosing the Right Events

Following each activity task is a PeopleCode program that meets the requirements of the

activity.

1.

On the Task Resources page, make sure that a resource is not available more than

100 percent of the time.

Note. Because the component is in deferred mode, the Component Processor may

not recognize that PCT_AVAILABLE has been changed until the next server trip.

You need to turn off deferred processing for PCT_AVAILABLE.

Describing the Component Processor

Lesson 4

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

To turn off deferred processing for PCT_AVAILABLE:

a. Open the PSU_TASK_RESOURCES page definition.

b. View the page field properties for PCT_AVAILABLE.

c. Access the Use tab.

d. Clear the Allow Deferred Processing check box.

e. Click OK.

f. Click the Save button.

[PSU_TASK_RSRC.PCT_AVAILABLE-FieldEdit] /* UniqueID---------------------------------*/ If PSU_TASK_RSRC.PCT_AVAILABLE > 100 Then Error "Resource cannot be available more than 100%."; End-If;

2. Make sure a resource cannot be deleted from the Task Resources page if the resource has finished the task.

Note. Because the component is in deferred mode, the Component Processor may not recognize that COMPLETED_FLAG has been checked until the next server trip. If you change the status of COMPLETED_FLAG to test RowDelete, save before

deleting a row.

[PSU_TASK_RSRC.COMPLETED_FLAG-RowDelete]

/* UniqueID-----------------------------------*/

If PSU_TASK_RSRC.COMPLETED_FLAG = "Y" Then

Error "Resource cannot be deleted if finished with the task.";

End-If;

3.

On the Tasks page, if a start date and an end date have been entered, make sure that

the end date does not precede the start date.

[PSU_TASK_TBL.START_DT-SaveEdit]

/* UniqueID-----------------------------------*/

If All(PSU_TASK_TBL.START_DT, PSU_TASK_TBL.END_DT) And

PSU_TASK_TBL.START_DT > PSU_TASK_TBL.END_DT Then

Error "Start Date must precede End Date";

End-If;

This concludes the activity. Do not continue.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 5

Writing PeopleCode Programs

This lesson has no activities.

Writing PeopleCode Programs

Lesson 5

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 6

Understanding PeopleCode Events

Understanding PeopleCode Events

Lesson 6

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 10:

Using SearchInit to control the Search Page

In this activity, you will review the activity overview and observe how the SetSearchDialogBehavior function can be used to bypass the search page.

See PeopleCode: Activity Guide, “Understanding PeopleCode Events,” Activity 10:

Using SearchInit to control the search page.

Slide 95

Activity Overview

In this activity, you will observe how the SetSearchDialogBehavior function is used to bypass the search page.

Using SearchInit to Control the Search Page

Perform the following steps:

1. Select Change My Password to access the Change Password page.

2. Notice that you are taken directly to the Change Password page with the user ID PTCODE.

3.

4.

In Application Designer open the record definition PSUSRSELF_SRCH and access

the SearchInit program on the field OPRID.

Add a REM statement in front of the line of the line SetSearchDialogBehavior(0).

5.

6.

Save your program.

Access the Change My Password page again. Notice that now you are taken to the

search page, and the User ID field is populated with PTCODE.

7.

Compare your Change Password page with the following results.

Results

Change Password page with the following results. Results Change Password search page 30 PeopleSoft Proprietary and

Change Password search page

Lesson 6

Understanding PeopleCode Events

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

This concludes the activity. Do not continue.

Understanding PeopleCode Events

Lesson 6

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 11:

Synchronizing the Student Table with the Customer Table

In this activity, you will review the activity overview and look at how PeopleCode is used to synchronize the Student Table and the Customer Table.

See PeopleCode: Activity Guide, “Understanding PeopleCode Events,” Activity 11:

Synchronizing the Student Table with the Customer Table.

Slide 116

Activity Overview

You have seen RowInit and FieldChange programs that enable or disable fields on the Student Table based on the value of the Same address as Customer checkbox on the Students, Personal Details page.

You also saw that the FieldChange program populates the Students, Personal Details page with values from the Customer Table if a user selects the Same address as Customer checkbox.

The purpose of these programs is to maintain data integrity. If a student is meant to have the same address as their employer (our customer), then PeopleCode is needed to prevent a user from making any changes that will break that relationship.

If any address data in the Customer Table changes, the system needs to update any

students related to that customer to reflect the new information. As you saw, a

SavePostChange program is used for that purpose.

Synchronizing the Student Table with the Customer Table

In this activity you will:

1.

Look at RowInit PeopleCode that is used to synchronize the Student Table and the

Customer Table.

2.

3.

Look at FieldChange PeopleCode that is used to synchronize the Student Table and

the Customer Table.

Observe how SavePostChange PeopleCode is used to synchronize the Student Table

and the Customer Table.

Looking at how RowInit PeopleCode synchronizes the Student Table and the Customer Table.

In this section you will create a search list with all the students who work for customer

XYZ and use the Next in List button to look at each student so you can observe the effect

of the Same address as Customer button.

1.

Create a search list with all the students who work for customer XYZ.

a.

Select Students, Personal Information.

b. On the search page, enter XYZ in the Customer field.

Lesson 6

Understanding PeopleCode Events

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

c. Select Search.

d. Select the first student link, which is Mark Larsen.

2. Use the Next in List button to look at each student.

3. Observe the relationship between the Same address as Customer checkbox and the student’s address fields.

If the Same address as Customer checkbox is selected, the address fields are disabled and cannot be changed.

If the Same address as Customer checkbox is cleared, the address fields are enabled and the values can be changed.

4. Look at the RowInit program that accomplished this:

[PSU_STUDENT_TBL.SAME_ADDR_CUSTOMER.RowInit]

* 01/14/02 PSU EdDev */

/* Declare the record object */

Local Record &PSU_Student_Tbl;

/* Instantiate the record object */

&PSU_Student_Tbl = GetRecord(Record.PSU_STUDENT_TBL);

/* We could also create an object for the PSU_CUST_TBL record, but it is

not necessary and would only be extra code. */

If &PSU_Student_Tbl.SAME_ADDR_CUSTOMER.Value = "Y" Then

&PSU_Student_Tbl.STREET1.Enabled = False;

&PSU_Student_Tbl.CITY.Enabled = False;

&PSU_Student_Tbl.STATE.Enabled = False;

&PSU_Student_Tbl.ZIP.Enabled = False;

&PSU_Student_Tbl.COUNTRY.Enabled = False;

&PSU_Student_Tbl.PHONE.Enabled = False;

End-If;

Looking at how FieldChange PeopleCode synchronizes the Student Table and the Customer

Table.

In this section you will change the Same address as Customer checkbox, which will cause

the FieldChange program associated with that field to execute, then observe the effects of

that FieldChange program.

1.

Access the Personal Details page for Mark Larsen.

You can either use the Return to Search push button and select Mark Larsen or select

the Previous in List push button until you reach Mark Larsen.

2.

Click on the Same address as Customer checkbox to clear it.

Notice that the address fields are enabled.

Understanding PeopleCode Events

Lesson 6

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

3. Change Mark’s street address to “One Larsen Way.”

4. Select the “Same address as Customer checkbox”.

Notice the address fields are disabled .

What is Mark’s street address now?

5. Look at the FieldChange program that accomplished this:

[PSU_STUDENT_TBL.SAME_ADDR_CUSTOMER.FieldChange]

/* 01/14/02 PSU EdDev */

/* Declare the record object */

Local Record &PSU_Student_Tbl;

/* Instantiate the record object */

&PSU_Student_Tbl = GetRecord(Record.PSU_STUDENT_TBL);

/* We could also create an object for the PSU_CUST_TBL record, but it is not necessary and would only be extra code. */

If &PSU_Student_Tbl.SAME_ADDR_CUSTOMER.Value = "Y" Then

&PSU_Student_Tbl.STREET1.Enabled = False;

&PSU_Student_Tbl.CITY.Enabled = False;

&PSU_Student_Tbl.STATE.Enabled = False;

&PSU_Student_Tbl.ZIP.Enabled = False;

&PSU_Student_Tbl.COUNTRY.Enabled = False;

&PSU_Student_Tbl.PHONE.Enabled = False;

&PSU_Student_Tbl.STREET1.Value = PSU_CUST_TBL.STREET1;

&PSU_Student_Tbl.CITY.Value = PSU_CUST_TBL.CITY;

&PSU_Student_Tbl.STATE.Value = PSU_CUST_TBL.STATE;

&PSU_Student_Tbl.ZIP.Value = PSU_CUST_TBL.ZIP;

&PSU_Student_Tbl.COUNTRY.Value = PSU_CUST_TBL.COUNTRY;

&PSU_Student_Tbl.PHONE.Value = PSU_CUST_TBL.PHONE;

Else

&PSU_Student_Tbl.STREET1.Enabled = True;

&PSU_Student_Tbl.CITY.Enabled = True;

&PSU_Student_Tbl.STATE.Enabled = True;

&PSU_Student_Tbl.ZIP.Enabled = True;

&PSU_Student_Tbl.COUNTRY.Enabled = True;

&PSU_Student_Tbl.PHONE.Enabled = True;

6.

End-If;

Identify the section of code that updates the address fields when the Same Address as

Customer checkbox is selected.

Observing how SavePostChange PeopleCode synchronizes the Student Table and the

Customer Table.

In the previous walk-throughs you saw how PeopleCode on the Student Table kept data on the Student Table synchronized. In this section you will observe how changes to the Customer Table can trigger PeopleCode that will update the Student Table as needed.

Lesson 6

Understanding PeopleCode Events

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

1. Select Customers, General Information.

2. Access Customer XYZ.

3. Change the customer’s address to:

One PeopleSoft Way Pleasanton, CA 90210

4. Save the component.

5. Once again, create a search list with students who work for customer XYZ (see above).

Notice that the address has changed for each student that has Same address as Customer selected.

6. Look at the PeopleCode program that accomplished this:

[PSU_CUST.GBL.SavePostChange]

If FieldChanged(PSU_CUST_TBL.STREET1) Or

FieldChanged(PSU_CUST_TBL.CITY) Or

FieldChanged(PSU_CUST_TBL.STATE) Or

FieldChanged(PSU_CUST_TBL.ZIP) Or

FieldChanged(PSU_CUST_TBL.COUNTRY) Or

FieldChanged(PSU_CUST_TBL.PHONE) Then

SQLExec("Update PS_PSU_STUDENT_TBL set STREET1 = :1, CITY = :2, STATE

= :3, ZIP = :4, COUNTRY = :5, PHONE = :6 Where CUSTOMER_ID = :7 and

SAME_ADDR_CUSTOMER = 'Y' ", PSU_CUST_TBL.STREET1, PSU_CUST_TBL.CITY,

PSU_CUST_TBL.STATE, PSU_CUST_TBL.ZIP, PSU_CUST_TBL.COUNTRY,

PSU_CUST_TBL.PHONE, PSU_CUST_TBL.CUSTOMER_ID);

End-If;

This concludes the activity. Do not continue.

Understanding PeopleCode Events

Lesson 6

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 7

Using PeopleCode Variables

Using PeopleCode Variables

Lesson 7

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 12:

Using Derived Work Fields

In this activity, you will review the activity overview and add derived/work fields to the Training Tasks application to track effort to go and display a resource status.

See PeopleCode: Activity Guide, “Using PeopleCode Variables,” Activity 12: Using Derived Work Fields.

Slide 136

Activity Overview

In this activity, you will use derived/work fields to calculate and display values that would not normally be stored in the database.

1. Create an Effort to Go field for the Task Table Page.

Currently, PSU_TASK_TBL tracks the amount of total effort required and effort spent for a task. Using these two fields, calculate the value of EFFORT_TO_GO and display it on the PSU_TASK page.

Make sure to test the application thoroughly. Think of everything that could be done by a user .

2.

Display a resource status on the Task Resources page.

Assign a resource status to each of the resources working on a task. It should be

based on the percentage of time the resource has available to work on the task.

The chart below indicates the guidelines for assigning a resource status. Try

using an evaluate statement.

Percent Available

Resource Status

100%

Dedicated

50%–99%

Semi-Dedicated

25%–49%

Part Time

below 25%

Occasional

Test.

The description of the resource status should display on the page.

Test for different values in the Percent Available field.

Using Derived Work Fields

In this activity you will:

Lesson 7

Using PeopleCode Variables

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

1. Create an Effort to Go field for the Task Table page.

2. Display a resource status on the Task Resources page.

Creating an Effort to Go Field for the Task Table

Perform the following steps:

1. Create an EFFORT_TO GO field as signed number.

2. Create a record definition named DERIVED_TRAIN.

3. Add the EFFORT_TO_GO field to DERIVED_TRAIN.

Set the record type to Derived/Work. You don’t need to build the table.

4. Put the DERIVED_TRAIN.EFFORT_TO_GO field on the PSU_TASK page.

Make it display-only.

In the page field properties, select the Display Zero checkbox or else a blank will be displayed.

5. Make the fields EFFORT_SPENT and EFFORT_TOTAL interactive or display the Refresh button on the page.

6. Add the following PeopleCode:

[PSU_TASK_TBL.EFFORT_SPENT-RowInit]

/* UniqueID-----------------------------------*/

DERIVED_TRAIN.EFFORT_TO_GO = PSU_TASK_TBL.EFFORT_TOTAL -

PSU_TASK_TBL.EFFORT_SPENT;

[PSU_TASK_TBL.EFFORT_SPENT-FieldChange]

/* UniqueID-----------------------------------*/

DERIVED_TRAIN.EFFORT_TO_GO = PSU_TASK_TBL.EFFORT_TOTAL -

PSU_TASK_TBL.EFFORT_SPENT;

[PSU_TASK_TBL.EFFORT_TOTAL-FieldChange]

/* UniqueID-----------------------------------*/

DERIVED_TRAIN.EFFORT_TO_GO = PSU_TASK_TBL.EFFORT_TOTAL -

PSU_TASK_TBL.EFFORT_SPENT;

7.

Test.

Displaying a resource status on the Task Resources page

Perform the following steps:

1.

Create a character field named RESOURCE_STATUS. Enter the appropriate

translate values.

2.

Add RESOURCE_STATUS field to DERIVED_TRAIN. On the Record Field

Properties, Edits tab, set the Table Edit type to Translate Table.

3. Add DERIVED_TRAIN.RESOURCE_STATUS to the Task Resources page as a dropdown list.

Using PeopleCode Variables

Lesson 7

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

4. In the page field properties, on the Record tab, select the radio button for Xlat Long.

5. Make the field display-only.

6. Make the field PCT_AVAILABLE interactive or display the Refresh button on the page.

7. Add the following PeopleCode:

[PSU_TASK_RSRC.PCT_AVAILABLE-RowInit]

and

[PSU_TASK_RSRC.PCT_AVAILABLE-FieldChange]

/* UniqueID-----------------------------------*/ Evaluate PSU_TASK_RSRC.PCT_AVAILABLE When = 0 DERIVED_TRAIN.RESOURCE_STATUS = "0"; Break; When = 100 DERIVED_TRAIN.RESOURCE_STATUS = "4"; Break; When >= 50 DERIVED_TRAIN.RESOURCE_STATUS = "3";

Break;

When >= 25

DERIVED_TRAIN.RESOURCE_STATUS = "2";

Break;

When-Other

DERIVED_TRAIN.RESOURCE_STATUS = "1";

End-Evaluate;

8.

Test.

This concludes the activity. Do not continue.

Lesson 7

Using PeopleCode Variables

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 13:

Setting Up a Variable Prompt Table Edit

In this activity, you will review the activity overview and look at the steps that were taken to set up a variable prompt table edit.

See PeopleCode: Activity Guide, “Referencing User-Defined Variables in PeopleCode,” Activity 13: Setting up a Variable Prompt Table Edit.

Slide 138

Activity Overview

In this activity, you will look at the steps to set up a variable prompt table edit and look specifically at how the variable prompt table edit was implemented for the Review Details page.

Setting Up a Variable Prompt Table Edit

In this activity you will learn how to:

1. Determine whether to add a field to the DERIVED record.

2. Set the prompt table edit to %FieldName.

3.

4.

5.

Add the DERIVED field to the page.

Possibly set the triggering field to Interactive Mode.

Populate the field DERIVED.FieldName using PeopleCode.

Determining Whether to Add a Field to the DERIVED Record

Open the record definition DERIVED.

The DERIVED record is a delivered record and already contains a number of fields.

Since it is a delivered record, you want to avoid adding fields, but you will probably find

what you need is already there. You cannot clone it, since the name must be DERIVED.

The first field in DERIVED is EDITTABLE. That works for most purposes. If you need

to put more than one variable prompt table field on a component, there are fields called

EDITTABLE2, EDITTABLE3, and so on.

Setting the Prompt Table Edit to %FieldName

In the record field properties of the field that has the prompt, set the prompt table edit to

%FieldName, where FieldName is a field on the derived/work record DERIVED.

If you use the DERIVED field EDITTABLE, in the record definition you would enter

%EDITTABLE as the prompt table name.

Open the record definition PSU_EMP_RVW_RVR.

Double-click the field REVIEWER_ID to access its record field properties

Using PeopleCode Variables

Lesson 7

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Select the Edits tab.

Notice the Prompt Table name – %EDITTABLE.

Adding the DERIVED Field to the Page

In order for PeopleCode to access the value in the field, it must be loaded into the Component Buffer, which means it must be on the page. Put it at the same level as the prompt table field. You will probably want to make it invisible.

1. Open the page definition PSU_EMP_REVIEW.

2. On the page definition, double-click the field Edit Table.

Notice the Record Name: DERIVED

Notice the Field Name – EDITTABLE.

3. Click Cancel.

Setting the Triggering Field to Interactive Mode

If the variable prompt table is conditional based on an enabled field, you need to turn off deferred processing for that field. Otherwise, the user prompt table may not change before the user accesses the prompt.

1.

2.

On the page definition double-click the field Review Type.

Select the Use tab.

Notice that the Allow Deferred Processing checkbox is cleared. This field must be in

interactive mode in order for the FieldChange PeopleCode to execute when the field

is changed.

Populating the Field DERIVED.FieldName Using PeopleCode

Probably in some type of Evaluate or If statement, you will have a statement like this:

DERIVED.EDITTABLE = “Record_Name”;

Consider all the events in which your code needs to be placed. Probably PreBuild or

RowInit, and FieldChange.

1.

2.

Open the component definition PSU_EMP_REVIEW.

Select the Structure tab.

3.

4.

Right-click and choose View PeopleCode.

Select the program for PSU_EMP_RVW_RVR.RowInit.

Notice the code that populates the DERIVED.EDITTABLE field with the

appropriate value based on the value of the REVIEW_TYPE.

This concludes the activity. Do not continue.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 8

Using Built-In Functions

Using Built-In Functions

Lesson 8

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 14:

Using Built-In Functions

In this activity, you will review the activity overview and use built-in functions to enhance the Training Tasks application.

See PeopleCode: Activity Guide, “Using Built-In Functions,” Activity 14: Using Built-In Functions.

Slide 164

Activity Overview

From now on, when displaying an error or warning message to the user, add the text to the Message Catalog and retrieve it using a function such as MsgGet.

1. Warn the user that managerial approval must be obtained when attempting to modify the task end date by more than three months.

2. On the Tasks page, issue a warning when the system date exceeds the start date and the task effort spent equals zero. This scenario implies that the task should have started, but hasn't yet because no effort has been recorded.

Using Built-In Functions

1.

Warn the user that managerial approval must be obtained when attempting to modify

the task end date by more than three months.

Change the END_DT field to Interactive.

Add a message to the Message Catalog:

a.

b.

Select PeopleTools, Utilities, Administration, Message Catalog.

Click the Add A New Value tab.

c.

d.

e.

For Message Set Number, enter 30420.

Click Add.

Enter the following information:

Page Element

Value or Status

Description

PeopleCode Course

Message Text

Managerial approval must be obtained to modify

end date by more than 3 months

f.

Save.

Add the following PeopleCode.

[PSU_TASK_TBL.END_DT-FieldEdit]

Lesson 8

Using Built-In Functions

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

/* UniqueID------------------------------------*/

Local date &Prior;

If None(PSU_TASK_TBL.END_DT) Then

/* Need to add a message to the Message Catalog for this to work */

Warning MsgGet(20000, 7, "MESSAGE NOT FOUND.");

Else

&Prior = PriorValue(PSU_TASK_TBL.END_DT);

If All(&Prior) Then

If PSU_TASK_TBL.END_DT > AddToDate(&Prior, 0, 3, 0) Or

PSU_TASK_TBL.END_DT < AddToDate(&Prior, 0, - 3, 0) Then

/*Need to add a message to the Message Catalog for this to work*/

Warning MsgGet(30420, 1, "MESSAGE NOT FOUND.");

End-If;

End-If;

End-If;

2. On the Tasks page, issue a warning when the system date exceeds the start date and the task effort spent equals zero. This scenario implies that the task should have started, but hasn't yet because no effort has been recorded.

Make sure this warning only happens when on the Tasks page.

Add a message to the Message Catalog:

a.

b.

c.

d.

Select PeopleTools, Utilities, Administration, Message Catalog.

For Message Set Number, enter 30420.

Click Search.

Enter the following information:

Page Element

Value or Status

Message Text

Start date has passed and no work has begun.

e.

Save.

Add the following PeopleCode:

[PSU_TASK.GBL.PSU_TASK_TBL.SaveEdit]

/* UniqueID------------------------------------*/

If All(PSU_TASK_TBL.START_DT, PSU_TASK_TBL.EFFORT_TOTAL) Then

If (%Date > PSU_TASK_TBL.START_DT) And

None(PSU_TASK_TBL.EFFORT_SPENT)Then

/* Need to add a message to the Message Catalog for this to work */

Warning MsgGet(30420, 2, "MESSAGE NOT FOUND.");

End-If;

Using Built-In Functions

Lesson 8

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

End-If;

This concludes the activity. Do not continue.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 9

Writing PeopleCode Functions

Writing PeopleCode Functions

Lesson 9

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 15:

Writing Functions

In this activity, you will review the activity overview and write PeopleCode functions to modularize five programs you wrote in earlier activities.

See PeopleCode: Activity Guide, “Writing PeopleCode Functions,” Activity 15: Writing Functions.

Slide 174

Activity Overview

In this activity, you will convert five existing programs into functions.

1. On the Tasks page, in order to calculate the Effort to Go for a task, the same logic was used in several different PeopleCode programs. Instead of using the same program in different places, create an external PeopleCode function to perform this logic. The function can then be called wherever the logic is needed.

2. On the Task Resources page, calculating the Resource Status based upon the percent available also reused the same PeopleCode in different places. Create an external

PeopleCode function to perform this logic. Try to use a different method of writing the function than you used above (for instance, no parameters, a different

combination of input/output parameters, or using Returns).

Writing Functions

Following each task description are PeopleCode programs that represent a possible

solution to the activity.

1.

On the Tasks page, in order to calculate the Effort to Go for a task, the same logic

was used in several different PeopleCode programs. Instead of using the same

program in different places, create an external PeopleCode function to perform this

logic. The function can then be called wherever the logic is needed.

a.

b.

c.

d.

Create a new derived/work record named FUNCLIB_TRAIN.

Add the field EFFORT_TO_GO to the record.

Save.

Add the following PeopleCode:

[FUNCLIB_TRAIN.EFFORT_TO_GO-FieldFormula]

/* UniqueID-----------------------------------*/

Function Calc_Effort_ToGo()

DERIVED_TRAIN.EFFORT_TO_GO = PSU_TASK_TBL.EFFORT_TOTAL -

PSU_TASK_TBL.EFFORT_SPENT;

End-Function;

e. Comment out the existing code in the following programs and add the code shown:

Lesson 9

Writing PeopleCode Functions

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

[PSU_TASK_TBL.EFFORT_SPENT-RowInit]

/* UniqueID-----------------------------------*/

Declare Function Calc_Effort_ToGo PeopleCode FUNCLIB_TRAIN.EFFORT_TO_GO FieldFormula;

Calc_Effort_ToGo();

[PSU_TASK_TBL.EFFORT_SPENT-FieldChange]

/* UniqueID-----------------------------------*/

Declare Function Calc_Effort_ToGo PeopleCode FUNCLIB_TRAIN.EFFORT_TO_GO FieldFormula;

Calc_Effort_ToGo();

[PSU_TASK_TBL.EFFORT_TOTAL-FieldChange]

/* UniqueID-----------------------------------*/

Declare Function calc_effort_togo PeopleCode

FUNCLIB_TRAIN.EFFORT_TO_GO FieldFormula;

Calc_Effort_ToGo();

2. On the Task Resources page, calculating the Resource Status based upon the percent available also reused the same PeopleCode in different places. Create an external

PeopleCode function to perform this logic. Try to use a different method of writing

the function than you used above (for instance, no parameters, a different

combination of input/output parameters, or using Returns).

[FUNCLIB_TRAIN.RESOURCE_STATUS-FieldFormula]

/* UniqueID-----------------------------------*/

Function ResourceStatus(&PCT) Returns string

Evaluate &PCT

When = 0

Return "0";

When = 100

Return "4";

When >= 50

Return "3";

When >= 25

Return "2";

When-Other

Return "1";

End-Evaluate;

End-Function;

[PSU_TASK_RSRC.PCT_AVAILABLE-RowInit]

/* UniqueID-----------------------------------*/

Declare Function ResourceStatus PeopleCode

FUNCLIB_TRAIN.RESOURCE_STATUS FieldFormula;

Writing PeopleCode Functions

Lesson 9

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

DERIVED_TRAIN.RESOURCE_STATUS = ResourceStatus(PSU_TASK_RSRC.PCT_AVAILABLE);

[PSU_TASK_RSRC.PCT_AVAILABLE-FieldChange]

/* UniqueID------------------------------------*/

Declare Function ResourceStatus PeopleCode

FUNCLIB_TRAIN.RESOURCE_STATUS FieldFormula;

DERIVED_TRAIN.RESOURCE_STATUS = ResourceStatus(PSU_TASK_RSRC.PCT_AVAILABLE);

This concludes the activity. Do not continue.

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 10

Explaining the Component Buffer

Explaining the Component Buffer

Lesson 10

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 16:

Determining the Contents of the Component Buffer

In this activity, you will review the activity overview and determine what fields and what PeopleCode programs are loaded into the component buffer for the Course Enrollment component.

See PeopleCode: Activity Guide, “Understanding the Component Buffer,” Activity 16:

Determining the Contents of the Component Buffer.

Slide 183

Activity Overview

In this activity, you will look at the record definition and page definition for the Course Enrollment component and apply the rules of component buffer allocation to determine what fields and what PeopleCode programs will be loaded into the buffer.

Determining the Contents of the Component Buffer

1. In the browser, select Courses, Course Enrollment.

2. Answer the following question:

Question

Answer

What fields are on the search page?

1.

2.

3.

4.

3.

4.

In Application Designer, open the record definition PSU_CRS_SESSN.

Answer the following questions:

Question

Answer

Which fields are search keys?

1.

2.

Which fields are alternate search keys?

1.

2.

5.

6.

In Application Designer, open the page definition PSU_CRS_ENROLL.

Select the Order tab.

Lesson 10

Explaining the Component Buffer

OAI Use

OracleOracle InternalInternal && OAI

7. Answer the following questions:

Question

Answer

What is the primary record definition for level 0?

 

What is the primary record definition for level 1?

 

8. Refer to the page definition to complete the following table:

Level Record Field Type What loads? PC? Use Only Only
Level
Record
Field
Type
What loads?
PC?
Use Only
Only

This concludes the activity. Do not continue.

Explaining the Component Buffer

Lesson 10

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 11

Accessing Data in the Component Buffer

This lesson has no activities.

Accessing Data in the Component Buffer

Lesson 11

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 12

Programming With Object- Oriented PeopleCode

Programming With Object-Oriented PeopleCode

Lesson 12

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 17:

Using Object-Oriented Methods and Properties

In this activity, you will review the activity overview and use object-oriented PeopleCode to implement enhancements to the Course Sessions and Task Resources applications.

See PeopleCode: Activity Guide, “Programming With Object-Oriented PeopleCode,” Activity 17: Using Object-Oriented Methods and Properties.

Slide 210

Activity Overview

Use object-oriented PeopleCode to complete the following tasks:

1. On the Course Sessions page, PeopleCode issues an error if the start date is greater

than

field when this error occurs. The program is on the component PSU_CRS_SESSN.

the end date. Enhance your program so that the cursor moves to the Start Date

To access the Course Sessions page, select Courses, Define, Course Sessions. Select Course Code 1001.

2. On the Task Resources page, make the Instructor and Resource Name fields work

properly together. If the instructor is changed, the resource name should change also.

If there is a value in the Instructor field, disable the Resource Name field.

Using Object-Oriented Methods and Properties

The PeopleCode for each task follows the task description.

1.

On the Course Sessions page, PeopleCode issues an error if the start date is greater

than the end date. Enhance your program so that the cursor moves to the Start Date

field when this error occurs. The program is on the component PSU_CRS_SESSN.

[PSU_CRS_SESSN.GBL.PSU_CRS_SESSN-SaveEdit]

/* UniqueID------------------------------------*/

Local Field &StartDt;

If All(PSU_CRS_SESSN.START_DATE, PSU_CRS_SESSN.END_DATE) And

PSU_CRS_SESSN.START_DATE > PSU_CRS_SESSN.END_DATE Then

&StartDt = GetField(PSU_CRS_SESSN.START_DATE);

&StartDt.SetCursorPos(%Page);

Error MsgGet(1040, 3, "Message Not Found: Course Start Date must not

be later than End Date.", PSU_CRS_SESSN.START_DATE,

PSU_CRS_SESSN.END_DATE)

End-If;

2.

On the Task Resources page, make the Instructor and Resource Name fields work

properly together. If the instructor is changed, the resource name should change also.

If there is a value in the Instructor field, disable the Resource Name field.

[PSU_TASK_RSRC.INSTRUCTOR -RowInit]

/* UniqueID------------------------------------*/

Lesson 12

Programming With Object-Oriented PeopleCode

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

If All(PSU_TASK_RSRC.INSTRUCTOR) Then Local Field &Resource; &Resource = GetField(PSU_TASK_RSRC.RESOURCE_NAME); &Resource.Enabled = False; End-If;

[PSU_TASK_RSRC.INSTRUCTOR-FieldChange] /* UniqueID------------------------------------*/ Local Field &Resource; &Resource = GetField(PSU_TASK_RSRC.RESOURCE_NAME);

&Resource.SetDefault(); If All(PSU_TASK_RSRC.INSTRUCTOR) Then &Resource.Enabled = False; Else &Resource.Enabled = True; End-If;

This concludes the activity. Do not continue.

Programming With Object-Oriented PeopleCode

Lesson 12

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Notes

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Lesson 13

Referencing Data in the Component Buffer

Referencing Data in the Component Buffer

Lesson 13

OracleOracle InternalInternal && OAIOAI UseUse OnlyOnly

Activity 18:

Stepping Through the Data Buffer

In this activity, you will review the activity overview and step through the process of traversing the component buffer from level 0 to level 1 and identify the data that is returned for each step.

See PeopleCode: Activity Guide, “Referencing Data in the Component Buffer,” Activity 18: Stepping Through the Data Buffer.

Slide 222

Activity Overview

In this activity you will review the seven steps to traverse a data buffer from level 0 to level 1 and answer some questions.

Stepping Through the Data Buffer

Before you look at the steps below, on your workstation access the Task Resources page.

The seven steps are:

Step 1. Declare data buffer objects.

Step 2. Get the level 0 rowset.

Step 3. Get the level 0 row.

Step 4. Get a level 1 rowset.

Step 5. Get a level 1 row.

Step 6. Get a level 1 record.

Step 7. Get a level 1 field.

Accessing the Task Resources page

1.

Select Set Up Training, Training Tasks, Task Resources and Efforts.

2.

Select Task 0001.

The table you will be working with below is a representation of the component buffer for

the Task Resources and Efforts component for Task 0001.

Step 1. Declaring data buffer objects

It is always good practice to declare variables and it is especially important to declare

objects.

Fill in the object types in the declaration statements below.

Local

Local &RS_Level0, &RS_Level1;

&RS_Level0, &RS_Level1;

Lesson 13

Referencing Data in the Component Buffer

Use Only

OAI Use

OracleOracle InternalInternal && OAI

Local

&Row_Level0, &Row_Level1;

Local

&Rec_TaskRsrc;

Local

&Fld_PctAvail;

Step 2. Getting the level 0 rowset

Using the GetLevel0 function, instantiate the level 0 rowset.

&RS_LEVEL0 = GetLevel0();

Draw a box around the cells in the table below that represent the level 0 rowset

PSU_TASK_TBL

PSU_TASK_RSRC

DERIVED_TRAIN

PSU_TASK_EFFORT

Task

Descr

Resource

Pct

Resource Status

Effort Date

Effort

Name

Avail

Amount

0001

Tools I

         

Guide

   

Ed Kelly

50

Semi-Dedicated

   
         

11/16/01

7.0

         

11/15/01

8.0

         

11/14/01

6.0

         

11/13/01

6.0

   

Jim Gutenkauf

100

Dedicated

 

Only

         

01/08/02

9.5

         

01/07/02

10.0

         

01/05/02

12.0

Step 3. Getting the level 0 row

Using the level 0 rowset object with the GetRow method, instantiate the level 0 row.

There is always exactly one row at level 0 of the component buffer, so the argument for

GetRow is always 1 to get the level 0 row.

&ROW_LEVEL0 = &RS_Level0.GetRow(1);

Draw a box around the cells in the table below that represent the level 0 row.

PSU_TASK_TBL

PSU_TASK_RSRC

DERIVED_TRAIN

PSU_TASK_EFFORT

Task

Descr

Resource

Pct

Resource Status

Effort Date

Effort

Name

Avail

Amount

0001

Tools I

         

Guide

   

Ed Kelly

50

Semi-Dedicated

   
         

11/16/01

7.0

Referencing Data in the Component Buffer

Lesson 13

Only

Use Only

Internal & & OAI

Oracle Internal

Oracle

     

11/15/01

8.0

     

11/14/01

6.0

     

11/13/01

6.0

Jim Gutenkauf

100

Dedicated

   
     

01/08/02

9.5

     

01/07/02

10.0

     

01/05/02

12.0

Step 4. Getting a level 1 rowset

A row contains one or more records and zero or more child rowsets. In this case, the level

0 row contains one level 1 rowset. Since there could be more than one level 1 scroll, you

need to specify which scroll by name.

Using the level 0 row object with the GetRowSet method, specify the primary record of the scroll.

&RS_LEVEL1 = &ROW_LEVEL0.GetRowSet(SCROLL.PSU_Task_RSRC);

Draw boxes around the cells in the table below that represents the level 1 PSU_Task_RSRC rowset.

PSU_TASK_TBL

PSU_TASK_RSRC

DERIVED_TRAIN

PSU_TASK_EFFORT

Task

Descr

Resource

Pct

Resource Status

Effort Date

Effort

Name

Avail

Amount

0001

Tools I

   

OAI Use