108
Volume I Activity Guide D17669GC10 1.0 April 2004 D40576 PeopleCode Oracle Internal & OAI Use Only Oracle Internal & OAI Use Only

Peoplecode Activity Guide

Embed Size (px)

DESCRIPTION

peoplesoft guide

Citation preview

Page 1: Peoplecode Activity Guide

Volume I • Activity Guide

D17669GC10

1.0

April 2004

D40576

PeopleCode

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 2: Peoplecode Activity Guide

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 3: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l i i i

C O N T E N T S

PeopleCode.........................................................................................................................v Typographical Conventions and Visual Cues .....................................................................v Related Documentation ......................................................................................................vi

Course Overview ...............................................................................................................1

Technology Overview........................................................................................................3

Using PeopleCode Development Tools ............................................................................5 Activity 1: Reviewing the Application Development Process ........................................6 Activity 2: Using the PeopleCode Editor ........................................................................9 Activity 3: Debugging a PeopleCode Program..............................................................12

Describing the Component Processor............................................................................15 Activity 4: Watching the Search Events Run ................................................................16 Activity 5: Watching the Component Build Events Run...............................................18 Activity 6: Watching the Row Action Events Run........................................................20 Activity 7: Watching the Save Action Events Run........................................................22 Activity 8: Examining Deferred Processing ..................................................................23 Activity 9: Choosing the Right Events ..........................................................................25

Writing PeopleCode Programs ......................................................................................27

Understanding PeopleCode Events................................................................................29 Activity 10: Using SearchInit to control the Search Page ...........................................30 Activity 11: Synchronizing the Student Table with the Customer Table....................32

Using PeopleCode Variables...........................................................................................37 Activity 12: Using Derived Work Fields.....................................................................38 Activity 13: Setting Up a Variable Prompt Table Edit................................................41

Using Built-In Functions.................................................................................................43 Activity 14: Using Built-In Functions.........................................................................44

Writing PeopleCode Functions ......................................................................................47 Activity 15: Writing Functions....................................................................................48

Explaining the Component Buffer .................................................................................51 Activity 16: Determining the Contents of the Component Buffer ..............................52

Accessing Data in the Component Buffer .....................................................................55

Programming With Object-Oriented PeopleCode .......................................................57 Activity 17: Using Object-Oriented Methods and Properties .....................................58

Preface

Lesson 1

Lesson 2

Lesson 3

Lesson 4

Lesson 5

Lesson 6

Lesson 7

Lesson 8

Lesson 9

Lesson 10

Lesson 11

Lesson 12

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 4: Peoplecode Activity Guide

P e o p l e C o d e C o n t e n t s

i v P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Referencing Data in the Component Buffer .................................................................61 Activity 18: Stepping Through the Data Buffer ..........................................................62 Activity 19: Traversing the Data Buffer......................................................................67 Activity 20: Accessing Multiple Occurs Levels..........................................................69

Creating Custom Objects with Application Classes.....................................................71 Activity 21: Writing an Application Class ..................................................................72 Activity 22: Calling Hello World ................................................................................74 Activity 23: Using Application Classes ......................................................................75

Using Data Buffer Methods ............................................................................................79 Activity 24: Using Select to Refresh Get Enrollments................................................80 Activity 25: Adding the Flush Method........................................................................84

Executing SQL in PeopleCode .......................................................................................87 Activity 26: Updating Effort Spent With a SQLExec Statement ................................88 Activity 27: Creating a SQL Definition ......................................................................89 Activity 28: Using a SQL Object ................................................................................91 Activity 29: Choosing the Best SQL Option...............................................................92 Activity 30: Executing SQL in PeopleCode................................................................94

Final Course Activity ......................................................................................................97 Activity 31: Using a Standalone Rowset to Track Overtime Hours............................98

Course Review ...............................................................................................................101

Lesson 13

Lesson 14

Lesson 15

Lesson 16

Lesson 17

Lesson 18

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 5: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l v

P r e f a c e

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 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.

KEY+KEY 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 6: Peoplecode Activity Guide

P e o p l e C o d e P r e f a c e

v i P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Visual Cues

Training courses contain the following visual cues.

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:

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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 7: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1

L e s s o n 1

Course Overview

This lesson has no activities.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 8: Peoplecode Activity Guide

C o u r s e O v e r v i e w L e s s o n 1

2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 9: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3

L e s s o n 2

Technology Overview

This lesson has no activities.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 10: Peoplecode Activity Guide

T e c h n o l o g y O v e r v i e w L e s s o n 2

4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 11: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5

L e s s o n 3

Using PeopleCode Development Tools

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 12: Peoplecode Activity Guide

U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s L e s s o n 3

6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. Define new fields and translate values.

3. Create record definitions.

4. Build Application Data tables.

5. Create the page definition.

6. Define the component.

7. Register the component.

8. 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. In Application Designer, open the PSU_TASKS project. This will make accessing the objects easier as we discuss them.

2. 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.

Step 2: Creating Fields

1. Launch Application Designer.

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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 13: Peoplecode Activity Guide

L e s s o n 3 U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7

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. Select the Use Display button on the toolbar.

4. Double-click RESOURCE_NAME. Notice the default.

5. Double-click INSTRUCTOR.

6. 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. Open the page PSU_TASK_RESOURCES.

2. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 14: Peoplecode Activity Guide

U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s L e s s o n 3

8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 15: Peoplecode Activity Guide

L e s s o n 3 U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9

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:

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

• Quoted strings are red.

• Comments are green.

3. 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. Enter the following text into the text editor, exactly as shown:

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

7. Save.

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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 16: Peoplecode Activity Guide

U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s L e s s o n 3

1 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

• 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.

10. 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. 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.

13. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 17: Peoplecode Activity Guide

L e s s o n 3 U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 1

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 18: Peoplecode Activity Guide

U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s L e s s o n 3

1 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. Set a visible breakpoint.

4. View values using Hover Inspect.

5. View values in the variables panes.

6. Look at the Debug Log Options.

7. 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. In Application Designer, open the record PSU_PO_DTL.

3. Open the program for ORDER_LINE_NBR.RowInsert.

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

5. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 19: Peoplecode Activity Guide

L e s s o n 3 U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 3

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 20: Peoplecode Activity Guide

U s i n g P e o p l e C o d e D e v e l o p m e n t T o o l s L e s s o n 3

1 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 21: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 5

L e s s o n 4

Describing the Component Processor

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 22: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

1 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. From the right drop-down list, select SearchInit.

4. 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);

5. From the right drop-down list, select SearchSave.

6. 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);

7. Click the Save button.

8. Select Window, Close All.

9. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 23: Peoplecode Activity Guide

L e s s o n 4 D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 7

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 24: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

1 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. From the left drop-down list, select PSU_INSTR_TBL (record).

3. From the right drop-down list, select RowInit.

4. 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);

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

6. From the right drop-down list, select PreBuild.

7. 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);

8. Click the Save button.

9. Select Window, Close All.

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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 25: Peoplecode Activity Guide

L e s s o n 4 D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 9

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 26: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

2 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. From the left drop-down list, select PSU_INSTR_TBL (record).

3. From the right drop-down list, select RowInsert.

4. 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);

5. Click the Save button.

6. Select Window, Close All.

7. 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. In PeopleSoft Internet Architecture, select Instructors, Professional Details.

9. Select the Correct History check box.

10. Select the instructor JGY (Joe Young).

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

12. Observe which events run.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 27: Peoplecode Activity Guide

L e s s o n 4 D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 2 1

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 28: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

2 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. From the right drop-down list, select SaveEdit.

5. 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. Select Window, Close All.

8. If you have the Training application open in PeopleSoft Internet Architecture, log out and log in again to refresh the cache.

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

10. Select the Correct History check box.

11. Select instructor JGY (Joe Young).

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

13. Click the Save button.

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

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 29: Peoplecode Activity Guide

L e s s o n 4 D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 2 3

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. Access the component properties and select the Internet tab.

3. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 30: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

2 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 31: Peoplecode Activity Guide

L e s s o n 4 D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 2 5

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. On the Task Resources page, make sure that a resource is not available more than 100 percent of the time.

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

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.

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 32: Peoplecode Activity Guide

D e s c r i b i n g t h e C o m p o n e n t P r o c e s s o r L e s s o n 4

2 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 33: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 2 7

L e s s o n 5

Writing PeopleCode Programs

This lesson has no activities.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 34: Peoplecode Activity Guide

W r i t i n g P e o p l e C o d e P r o g r a m s L e s s o n 5

2 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 35: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 2 9

L e s s o n 6

Understanding PeopleCode Events

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 36: Peoplecode Activity Guide

U n d e r s t a n d i n g P e o p l e C o d e E v e n t s L e s s o n 6

3 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. In Application Designer open the record definition PSUSRSELF_SRCH and access the SearchInit program on the field OPRID.

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

5. Save your program.

6. 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 search page

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 37: Peoplecode Activity Guide

L e s s o n 6 U n d e r s t a n d i n g P e o p l e C o d e E v e n t s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3 1

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 38: Peoplecode Activity Guide

U n d e r s t a n d i n g P e o p l e C o d e E v e n t s L e s s o n 6

3 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. Look at FieldChange PeopleCode that is used to synchronize the Student Table and the Customer Table.

3. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 39: Peoplecode Activity Guide

L e s s o n 6 U n d e r s t a n d i n g P e o p l e C o d e E v e n t s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3 3

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 40: Peoplecode Activity Guide

U n d e r s t a n d i n g P e o p l e C o d e E v e n t s L e s s o n 6

3 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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;

End-If;

6. 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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 41: Peoplecode Activity Guide

L e s s o n 6 U n d e r s t a n d i n g P e o p l e C o d e E v e n t s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3 5

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 42: Peoplecode Activity Guide

U n d e r s t a n d i n g P e o p l e C o d e E v e n t s L e s s o n 6

3 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 43: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3 7

L e s s o n 7

Using PeopleCode Variables

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 44: Peoplecode Activity Guide

U s i n g P e o p l e C o d e V a r i a b l e s L e s s o n 7

3 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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:

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 45: Peoplecode Activity Guide

L e s s o n 7 U s i n g P e o p l e C o d e V a r i a b l e s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 3 9

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 46: Peoplecode Activity Guide

U s i n g P e o p l e C o d e V a r i a b l e s L e s s o n 7

4 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 47: Peoplecode Activity Guide

L e s s o n 7 U s i n g P e o p l e C o d e V a r i a b l e s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 4 1

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. Add the DERIVED field to the page.

4. Possibly set the triggering field to Interactive Mode.

5. 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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 48: Peoplecode Activity Guide

U s i n g P e o p l e C o d e V a r i a b l e s L e s s o n 7

4 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

• 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. On the page definition double-click the field Review Type.

2. 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. Open the component definition PSU_EMP_REVIEW.

2. Select the Structure tab.

3. Right-click and choose View PeopleCode.

4. 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. Oracle

Internal &

OAI U

se O

nly

Oracle In

ternal & O

AI Use

Only

Page 49: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 4 3

L e s s o n 8

Using Built-In Functions

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 50: Peoplecode Activity Guide

U s i n g B u i l t - I n F u n c t i o n s L e s s o n 8

4 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. Select PeopleTools, Utilities, Administration, Message Catalog.

b. Click the Add A New Value tab.

c. For Message Set Number, enter 30420.

d. Click Add.

e. 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]

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 51: Peoplecode Activity Guide

L e s s o n 8 U s i n g B u i l t - I n F u n c t i o n s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 4 5

/* 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. Select PeopleTools, Utilities, Administration, Message Catalog.

b. For Message Set Number, enter 30420.

c. Click Search.

d. 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;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 52: Peoplecode Activity Guide

U s i n g B u i l t - I n F u n c t i o n s L e s s o n 8

4 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

End-If;

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 53: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 4 7

L e s s o n 9

Writing PeopleCode Functions

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 54: Peoplecode Activity Guide

W r i t i n g P e o p l e C o d e F u n c t i o n s L e s s o n 9

4 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. Create a new derived/work record named FUNCLIB_TRAIN.

b. Add the field EFFORT_TO_GO to the record.

c. Save.

d. 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:

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 55: Peoplecode Activity Guide

L e s s o n 9 W r i t i n g P e o p l e C o d e F u n c t i o n s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 4 9

[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;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 56: Peoplecode Activity Guide

W r i t i n g P e o p l e C o d e F u n c t i o n s L e s s o n 9

5 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 57: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5 1

L e s s o n 1 0

Explaining the Component Buffer

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 58: Peoplecode Activity Guide

E x p l a i n i n g t h e C o m p o n e n t B u f f e r L e s s o n 1 0

5 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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. In Application Designer, open the record definition PSU_CRS_SESSN.

4. Answer the following questions:

Question Answer

Which fields are search keys? 1.

2.

Which fields are alternate search keys? 1.

2.

5. In Application Designer, open the page definition PSU_CRS_ENROLL.

6. Select the Order tab. Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 59: Peoplecode Activity Guide

L e s s o n 1 0 E x p l a i n i n g t h e C o m p o n e n t B u f f e r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5 3

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?

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 60: Peoplecode Activity Guide

E x p l a i n i n g t h e C o m p o n e n t B u f f e r L e s s o n 1 0

5 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 61: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5 5

L e s s o n 1 1

Accessing Data in the Component Buffer

This lesson has no activities.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 62: Peoplecode Activity Guide

A c c e s s i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 1

5 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 63: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5 7

L e s s o n 1 2

Programming With Object-Oriented PeopleCode

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 64: Peoplecode Activity Guide

P r o g r a m m i n g W i t h O b j e c t - O r i e n t e d P e o p l e C o d e L e s s o n 1 2

5 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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 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.

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------------------------------------*/

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 65: Peoplecode Activity Guide

L e s s o n 1 2 P r o g r a m m i n g W i t h O b j e c t - O r i e n t e d P e o p l e C o d e

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 5 9

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.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 66: Peoplecode Activity Guide

P r o g r a m m i n g W i t h O b j e c t - O r i e n t e d P e o p l e C o d e L e s s o n 1 2

6 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 67: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 6 1

L e s s o n 1 3

Referencing Data in the Component Buffer

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 68: Peoplecode Activity Guide

R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 3

6 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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 &RS_Level0, &RS_Level1;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 69: Peoplecode Activity Guide

L e s s o n 1 3 R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 6 3

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 Name

Pct Avail

Resource Status Effort Date Effort 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

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 Name

Pct Avail

Resource Status Effort Date Effort Amount

0001 Tools I Guide

Ed Kelly 50 Semi-Dedicated

11/16/01 7.0

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 70: Peoplecode Activity Guide

R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 3

6 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

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 Name

Pct Avail

Resource Status Effort Date Effort 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

01/08/02 9.5

01/07/02 10.0

01/05/02 12.0

Step 5. Getting a level 1 row.

A rowset contains one or more rows; this example has two. Usually, you won’t know the specific row number and will loop through the rowset using a variable, such as &I, to access each row.

Using the Level 1 rowset object with the GetRow method, specify the row number.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 71: Peoplecode Activity Guide

L e s s o n 1 3 R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 6 5

&Row_Level1 = &RS_Level1.GetRow(2);

Draw a box around the cells in the table below that represent level 1, row 2.

PSU_TASK_TBL PSU_TASK_RSRC DERIVED_TRAIN PSU_TASK_EFFORT

Task Descr Resource Name

Pct Avail

Resource Status Effort Date Effort 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

01/08/02 9.5

01/07/02 10.0

01/05/02 12.0

Step 6. Getting a level 1 record.

A row object contains one or more records and may contain child rowsets. In this example we want to get a record. Later, you will learn how to access the child rowset at level 2.

Using the level 1 row object with the GetRecord method, specify the record name.

&REC_TASKRSRC = &ROW_LEVEL1.GetRecord(RECORD.PSU_TASK_RSRC);

Draw a box around the cells in the table below that represent the level 1, row 2 record.

PSU_TASK_TBL PSU_TASK_RSRC DERIVED_TRAIN PSU_TASK_EFFORT

Task Descr Resource Name

Pct Avail

Resource Status Effort Date Effort 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

01/08/02 9.5

01/07/02 10.0

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 72: Peoplecode Activity Guide

R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 3

6 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

01/05/02 12.0

Step 7. Getting a level 1 field.

A record contains one or more fields.

Using the level 1 record object with the GetField method, specify the field name.

&FLD_PCTAVAIL = &REC_TASKRSRC.GetField(FIELD.PCT_AVAILABLE);

The code above returns a reference to single field. Draw a box around the cells that represents that field .

PSU_TASK_TBL PSU_TASK_RSRC DERIVED_TRAIN PSU_TASK_EFFORT

Task Descr Resource Name

Pct Avail

Resource Status Effort Date Effort 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

01/08/02 9.5

01/07/02 10.0

01/05/02 12.0

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 73: Peoplecode Activity Guide

L e s s o n 1 3 R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 6 7

Activity 19: Traversing the Data Buffer In this activity, you will review the activity overview and traverse a Student Enrollment rowset to check for the prerequisite to a course.

See PeopleCode: Activity Guide, “Referencing Data in the Component Buffer,” Activity 19: Traversing the Data Buffer.

Slide 226 ______________________________________________________________________________________________________

Activity Overview

On the Student Enrollment component (PSU_STU_ENROLL), do not allow enrollment into a PeopleCode class (course 1011) unless the student has enrolled in a PeopleTools II (course 1002) class at an earlier date. Begin by simply checking for the prerequisite, regardless of date. Once that works, add the logic to check for an earlier start date.

Course enrollment can occur on multiple pages. This activity uses Student Enrollment. Make sure to take this into consideration.

Select Courses, Student Enrollment to access the Student Enrollment page.

Traversing the Data Buffer

Here is an example of PeopleCode that would work to traverse the data buffer to check for prerequisites. You may find a different solution.

[PSU_STU_ENROLL.GBL.PSU_STU_ENROLL-SaveEdit]

If PSU_STU_ENROLL.COURSE = "1011" And

PSU_STU_ENROLL.ENROLL_STATUS = "ENR" Then

Local boolean &Completed = False;

Local Rowset &RS;

Local Record &RecStuEnroll;

Local Field &Course, &Status;

Local date &StartDate, &PreReqStart;

&RS = GetRowset();

&StartDate = GetField(PSU_CRS_SESSN.START_DATE).Value;

For &I = 1 To &RS.ActiveRowCount

&RecStuEnroll = &RS.GetRow(&I).GetRecord(Record.PSU_STU_ENROLL);

&Course = &RecStuEnroll.COURSE;

&Status = &RecStuEnroll.ENROLL_STATUS;

&PreReqStart = &RS.GetRow(&I).GetRecord(Record.PSU_CRS_SESSN).START_DATE.Value;

If &Course.Value = "1002" And

(&Status.Value = "ENR" Or

&Status.Value = "CMP") Then

If &PreReqStart < &StartDate Then

&Completed = True;

Break;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 74: Peoplecode Activity Guide

R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 3

6 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

End-If;

End-If;

End-For;

If Not &Completed Then

Error MsgGet(30420, 3, "MESSAGE NOT FOUND: Gotta have the prereq");

End-If;

End-If;

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 75: Peoplecode Activity Guide

L e s s o n 1 3 R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 6 9

Activity 20: Accessing Multiple Occurs Levels In this activity, you will review the activity overview, then modify the Task Resources and Efforts component to add up the effort amounts attributed to each resource and display the total for that resource on the page. Then you will make all the Task Effort occurs level rows display-only when a task has been completed.

See PeopleCode: Activity Guide, “Referencing Data in the Component Buffer,” Activity 20: Accessing Multiple Occurs Levels.

Slide 229 ______________________________________________________________________________________________________

Activity Overview

For this activity, make the following enhancements to the Task Resources component.

1. On the Task Resources page, add up the effort amounts attributed to each resource and display the total for that resource on the page.

If the effort for a date changes, recalculate the total by finding the prior value of effort, subtracting that from the total, then adding the new effort to the total.

2. Once a resource has finished a task, make all the Task Effort occurs level rows display-only (occurs level two).

Accessing Multiple Occurs Levels

1. On the Task Resources page, add up the effort amounts attributed to each resource and display the total for that resource on the page.

a. Create a new field, TOTAL_RES_HRS.

b. Add the field to the record definition DERIVED_TRAIN.

c. Add the field to the PSU_TASK_RESOURCES page at level 1.

d. Make the field display-only.

e. Add the following PeopleCode.

[PSU_TASK_EFFORT.EFFORT_AMT-RowInit]

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

DERIVED_TRAIN.TOTAL_RES_HRS =DERIVED_TRAIN.TOTAL_RES_HRS + PSU_TASK_EFFORT.EFFORT_AMT;

[PSU_TASK_EFFORT.EFFORT_AMT-RowDelete]

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

DERIVED_TRAIN.TOTAL_RES_HRS =DERIVED_TRAIN.TOTAL_RES_HRS – PSU_TASK_EFFORT.EFFORT_AMT;

[PSU_TASK_EFFORT.EFFORT_AMT-FieldChange]

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

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 76: Peoplecode Activity Guide

R e f e r e n c i n g D a t a i n t h e C o m p o n e n t B u f f e r L e s s o n 1 3

7 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

DERIVED_TRAIN.TOTAL_RES_HRS =DERIVED_TRAIN.TOTAL_RES_HRS + EFFORT_AMT - PriorValue(PSU_TASK_EFFORT.EFFORT_AMT);

2. Once a resource has finished a task, make all the Task Effort occurs level rows display-only (occurs level two).

Add the following PeopleCode.

[PSU_TASK_EFFORT.EFFORT_DT-RowInit]

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

If PSU_TASK_RSRC.COMPLETED_FLAG = "Y" Then

Local Record &Rec_TaskEffort;

&Rec_TaskEffort = GetRecord(); /* Current Context */

&Rec_TaskEffort.EFFORT_DT.Enabled = False;

&Rec_TaskEffort.EFFORT_AMT.Enabled = False;

&Rec_TaskEffort.CHARGE_BACK.Enabled = False;

End-If;

[PSU_TASK_RSRC.COMPLETED_FLAG-FieldChange]

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

Local Rowset &RS_Level2;

Local Row &Row_Level1;

Local Record &Rec_TaskEffort;

/* Current Context - GetRow() assumes current row */

&Row_Level1 = GetRow();

&RS_Level2 = &Row_Level1.GetRowset(Scroll.PSU_TASK_EFFORT);

If PSU_TASK_RSRC.COMPLETED_FLAG = "Y" Then

For &I = 1 To &RS_Level2.ActiveRowCount

&Rec_TaskEffort = &RS_Level2(&I).PSU_TASK_EFFORT;

&Rec_TaskEffort.EFFORT_DT.Enabled = False;

&Rec_TaskEffort.EFFORT_AMT.Enabled = False;

&Rec_TaskEffort.CHARGE_BACK.Enabled = False;

End-For;

Else

For &I = 1 To &RS_Level2.ActiveRowCount

&Rec_TaskEffort = &RS_Level2(&I).PSU_TASK_EFFORT;

&Rec_TaskEffort.EFFORT_DT.Enabled = True;

&Rec_TaskEffort.EFFORT_AMT.Enabled = True;

&Rec_TaskEffort.CHARGE_BACK.Enabled = True;

End-For;

End-If;

This concludes the activity. Do not continue. Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 77: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7 1

L e s s o n 1 4

Creating Custom Objects with Application Classes

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 78: Peoplecode Activity Guide

C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s L e s s o n 1 4

7 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 21: Writing an Application Class In this activity, you will review the activity overview and create an application class with a very simple PeopleCode program.

See PeopleCode: Activity Guide, “Creating Custom Objects with Application Classes,” Activity 21: Writing an Application Class.

Slide 239 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will create a new application containing a very simple PeopleCode, the classic “Hello World.”

Writing an Application Class

To write an application class you will:

1. Create a new application package.

2. Insert an application class.

3. Add PeopleCode to the application class.

Creating a New Application Package

To create a new application package:

1. In Application Designer, select File, New.

2. Choose Application Package.

3. Name the application package PSU.

Inserting an Application Class

To insert an application class:

1. Right-click the application package you just created.

2. Select Insert App Class.

3. For Class Name, enter HelloWorld.

Adding PeopleCode to the Application Class

To add PeopleCode to an Application Class:

1. Enter the following PeopleCode in your application class.

class HelloWorld

method Greeting();

end-class;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 79: Peoplecode Activity Guide

L e s s o n 1 4 C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7 3

method Greeting

WinMessage("Hello World", 0);

end-method;

2. Save.

You will test your application class in a later activity.

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 80: Peoplecode Activity Guide

C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s L e s s o n 1 4

7 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 22: Calling Hello World In this activity, you will review the activity overview and write a PeopleCode program that calls the HelloWorld class you created earlier.

See PeopleCode: Activity Guide, “Creating Custom Objects with Application Classes,” Activity 22: Calling Hello World.

Slide 249 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will write a simple PeopleCode that calls the HelloWorld class you created in the last activity.

Calling Hello World

For convenience, you will add your code to FieldEdit on the Get Enrollments Refresh button.

1. In Application Designer, open the component definition PSU_GET_ENROLL.

2. Access the FieldEdit event for DERIVED_ED_SVCS.REFRESH_BTN.

You are using FieldEdit because there is already code in FieldChange.

3. Add the following PeopleCode.

[PSU_GET_ENROLL.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldEdit]

/* Import the class */

import PSU:HelloWorld;

/* Declare an object using the class */

Local HelloWorld &Hi;

/* Instantiate an object using the class */

&Hi = create HelloWorld();

/* Use the object */

&Hi.Greeting();

4. Test. In the browser, select Set Up Training, Training Tasks, Get Enrollments. Select the Refresh button.

You should see a message saying “Hello World.”

5. Remove or comment out the PeopleCode in PSU_GET_ENROLL.

You will use this component again in a future activity.

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 81: Peoplecode Activity Guide

L e s s o n 1 4 C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7 5

Activity 23: Using Application Classes In this activity, you will review the activity overview and create and use a class called Order_Number to create a new purchase number.

See PeopleCode: Activity Guide, “Creating Custom Objects with Application Classes,” Activity 23: Using Application Classes.

Slide 250 ______________________________________________________________________________________________________

Activity Overview

Earlier you saw an example of a function that could be called to create a new purchase order number. Borrowing code from that function, you will create an application class to accomplish the same task, and modify the PeopleCode that calls the function to call the application class instead.

Insert a new application class called Order_Number in the application package PSU

Open the PeopleCode program .

Use the function assign_order_number() on FUNCLIB_ED_SVCS.Order_NBR.FieldFormula as the basis for your new application class.

Remember to:

• Declare the class.

• Declare properties and methods.

• Declare private constants, instance variables, and methods.

• Define methods.

• Define get and set properties if appropriate.

Modify the PeopleCode in PSU_PO_HR.ORDER_NBR.SavePreChange to call the application class instead of the function.

Remember to:

• Import the class.

• Declare an object.

• Instantiate the object.

• Call the method.

Do the following to test.

• Select Purchasing, Maintain Purchase Orders, Add a New Value.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 82: Peoplecode Activity Guide

C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s L e s s o n 1 4

7 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

• Accept the defaults and select Add.

• Save.

• Was a new order number assigned correctly?

Using Application Classes

To create and use a new application class, perform the following steps:

1. Open the application package PSU.

2. Insert a new application class called Order_Number.

3. Open the PeopleCode program FUNCLIB_ED_SVCS.Order_NBRFieldFormula.

4. Use the function assign_order_number() program as the basis for your new application class.

[PSU.Order_Number.OnExecute]

/* ! Assign Order Number. Assumes 8 character id. */

class Order_Number;

rem method Order_Number(&ORDER_NBR As Field out);

method Assign_Order_Number(&ORDER_NBR As string) Returns string;

private

Constant &LENGTH = 8;

instance string &CHECK;

instance string &PAD;

instance number &NBR;

end-class;

method Assign_Order_Number

/+ &ORDER_NBR as String +/

/+ Returns String +/

Local string &Last_Order;

&CHECK = Rept("9", &LENGTH);

SQLExec("Select order_last From PS_INSTALLATION_TR", &Last_Order);

If Value(&Last_Order) + 1 > Value(&CHECK) Then

Error MsgGet(10001, 4, "MESSAGE NOT FOUND.", &CHECK);

Else

&NBR = Value(&Last_Order) + 1;

&PAD = Rept(“0”, 8 – Len(RTrim(LTrim(&Last_Nbr, “0”))));

&ORDER_NBR = &PAD | String(&NBR);

SQLExec("Update PS_INSTALLATION_TR Set order_last = :1", &ORDER_NBR);

Return &ORDER_NBR;

End-If;

end-method;

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 83: Peoplecode Activity Guide

L e s s o n 1 4 C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7 7

5. Modify the PeopleCode in PSU_PO_HR.ORDER_NBR.SavePreChange to call the application class instead of the function.

[PSU_PO_HR.ORDER_NBR.SavePreChange]

import PSU:Order_Number;

Local Order_Number &NewOrder;

If PSU_PO_HDR.ORDER_NBR = "NEW" And

%Mode = "A" Then

/* assign order number */

&NewOrder = create Order_Number();

PSU_PO_HDR.ORDER_NBR =

&NewOrder.Assign_Order_Number(PSU_PO_HDR.ORDER_NBR);

End-If;

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 84: Peoplecode Activity Guide

C r e a t i n g C u s t o m O b j e c t s w i t h A p p l i c a t i o n C l a s s e s L e s s o n 1 4

7 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 85: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 7 9

L e s s o n 1 5

Using Data Buffer Methods

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 86: Peoplecode Activity Guide

U s i n g D a t a B u f f e r M e t h o d s L e s s o n 1 5

8 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 24: Using Select to Refresh Get Enrollments In this activity, you will review the activity overview and add PeopleCode to the Get Enrollments page to enable it to select students enrolled in a specified course session.

See PeopleCode: Activity Guide, “Using Data Buffer Methods,” Activity 24: Using Select to Refresh Get Enrollments.

Slide 256 ______________________________________________________________________________________________________

Activity Overview

The purpose of the Get Enrollments page is to allow a user to get enrollment information for course sessions without having to go through the search page for each session. The idea is to enter a course and session number, fill in the fields, hit the Refresh push button and retrieve all the students who are enrolled.

In this activity you will look at the elements of the Get Enrollments component and add some PeopleCode to select the appropriate data into the scroll.

Using Select to Refresh Get Enrollments

In this activity you will:

1. Try out the Get Enrollments page.

2. Examine the Get Enrollments page definition.

3. Examine the Get Enrollments component definition.

4. Add PeopleCode to select rows into the Get Enrollments scroll.

5. Test.

Trying out the Get Enrollments Page

1. Select Set Up Training, Training Tasks, Get Enrollments.

2. For Course Code, enter 1001.

3. For Session Number, enter 287.

4. Select the Refresh push button.

5. Answer the following questions:

Question Answer

What did the search page look like?

Why was the page blank when it displayed?

Why were no rows retrieved when you pushed the

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 87: Peoplecode Activity Guide

L e s s o n 1 5 U s i n g D a t a B u f f e r M e t h o d s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 8 1

Question Answer Refresh button?

Examining the Get Enrollments Page Definition

1. In Application Designer, open the page definition PSU_GET_ENROLL.

2. Look at the page field properties for Course Code, Session Number, and the Refresh button.

Question Answer

With what record definition are they associated?

Why a derived/work record?

This is one case where derived/work fields are enabled and have prompt table edits.

3. Look at the Grid properties.

• Double-click the grid to open the properties dialog box.

• Select the Use tab.

• Notice that the No Auto Select checkbox is selected.

The scroll or grid referenced by the rowset object should have the No Auto Select checkbox selected to prevent the Component Processor from automatically selecting rows into the scroll. You will take control of that with PeopleCode.

Examining the Get Enrollments Component

1. In Application Designer, open the component definition PSU_GET_ENROLL. Look at the Component Properties, Use tab. (Leave the page definition open.).

2. Answer the following questions:

Question Answer

What is the search record?

Why?

3. Select the page definition again.

Look at the grid properties, Use tab. Notice that No Auto Select is checked. That explains why the page was initially blank. We don’t want any rows selected into the buffer until the user selects Refresh.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 88: Peoplecode Activity Guide

U s i n g D a t a B u f f e r M e t h o d s L e s s o n 1 5

8 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

• Notice that the grid is set to display only. If it was enabled , the user would be able to save changes to the database.

• If the component processor doesn’t load the rows, how do they get loaded? PeopleCode!

4. Answer the following questions:

Question Answer

Where would PeopleCode be?

Would it be on the record or the component?

Adding PeopleCode to Select Rows into the Get Enrollments Scroll

1. Select the component definition again.

2. Select the Structure tab.

3. Open the PeopleCode for REFRESH_BTN, FieldChange.

There’s no code there!

4. Add the following code:

Local Rowset &Rowset;

&Rowset = GetRowset(SCROLL.PSU_STU_ENROLL);

&Rowset.Select(RECORD.PSU_STU_ENROLL, "Where COURSE = :1 and SESSION_NBR = :2", DERIVED_ED_SVCS.COURSE, DERIVED_ED_SVCS.SESSION_NBR);

Testing

1. Test using the following course sessions:

• Course 1001, Session 4.

• Course 1002, Session 32.

2. Select View All.

Notice that all the students from the first select are still there, along with all the students from the second select.

Why?

3. Compare your Get Enrollments page with the following results:

Results These are the enrollments for Course 1001, Session 4 and Course 1002, Session 32. Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 89: Peoplecode Activity Guide

L e s s o n 1 5 U s i n g D a t a B u f f e r M e t h o d s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 8 3

Get Student Enrollments page

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 90: Peoplecode Activity Guide

U s i n g D a t a B u f f e r M e t h o d s L e s s o n 1 5

8 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 25: Adding the Flush Method In this activity, you will review the activity overview and add a Flush statement to your PeopleCode program on the Get Enrollments component.

See PeopleCode: Activity Guide, “Using Data Buffer Methods,” Activity 25: Adding the Flush Method.

Slide 258 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will add a Flush statement to your PeopleCode program on the Get Enrollments component.

Adding the Flush Method

In this activity you will:

1. Add a Flush statement.

2. Test.

Adding a Flush Statement

Add the following statement to the PeopleCode program you wrote for the PSU_GET_ENROLL component in the last activity:

&Rowset.Flush();

Your completed program should look like this.

Local Rowset &Rowset;

&Rowset = GetRowset(SCROLL.PSU_STU_ENROLL);

&Rowset.Flush();

&Rowset.Select(RECORD.PSU_STU_ENROLL, “Where COURSE = :1 and SESSION_NBR = :2”, DERIVED_ED_SVCS.COURSE, DERIVED_ED_SVCS.SESSION_NBR);

Testing

1. Test using the following course sessions:

• Course 1001, Session 4.

• Course 1002, Session 32.

2. Select View All.

Notice that only the students from the second select are displayed.

3. Compare your Get Enrollments page with the following results: Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 91: Peoplecode Activity Guide

L e s s o n 1 5 U s i n g D a t a B u f f e r M e t h o d s

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 8 5

Results: These are the enrollments for Course 1002, Session 32.

Get Student Enrollments page

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 92: Peoplecode Activity Guide

U s i n g D a t a B u f f e r M e t h o d s L e s s o n 1 5

8 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 93: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 8 7

L e s s o n 1 6

Executing SQL in PeopleCode

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 94: Peoplecode Activity Guide

E x e c u t i n g S Q L i n P e o p l e C o d e L e s s o n 1 6

8 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 26: Updating Effort Spent With a SQLExec Statement In this activity, you will review the activity overview and write a SQLExec statement that automatically updates the Effort Spent field whenever the Refresh button is pushed.

See PeopleCode: Activity Guide, “Executing SQL in PeopleCode,” Activity 26: Updating Effort Spent With a SQLExec Statement.

Slide 273 ______________________________________________________________________________________________________

Activity Overview

It just doesn’t make sense that users have to manually update the Effort Spent field. That’s a perfect job for PeopleCode.

In this activity you will add a push button to the page and write a SQLExec statement that automatically calculates the Effort Spent field whenever the Refresh button is clicked.

Updating Effort Spent With a SQLExec Statement

To update Effort Spent with a SQLExec statement:

1. Open the PSU_TASK page in Application Designer.

a. Make the Effort Spent field display only.

b. Add a “Refresh” push button associated with the record field DERIVED_ED_SVCS.REFRESH_BTN.

2. Add the following PeopleCode:

[PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange]

/* Update Effort_Spent whenever the user chooses to refresh it using the pushbutton to reflect actual values in Effort_Amt */

SQLExec("Select Sum(EFFORT_AMT) from PS_PSU_TASK_EFFORT where TASK = :1", PSU_TASK_TBL.TASK, PSU_TASK_TBL.EFFORT_SPENT);

3. Test.

a. Navigate to the Task page.

b. Note the value of the Effort Spent field when you first open the component.

c. Click the Refresh pushbutton and observe the change.

The Effort Spent field should now reflect the sum of all effort amounts recorded for this task on the Task Resources page.

This concludes the activity. Do not continue. Oracle

Internal &

OAI U

se O

nly

Oracle In

ternal & O

AI Use

Only

Page 95: Peoplecode Activity Guide

L e s s o n 1 6 E x e c u t i n g S Q L i n P e o p l e C o d e

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 8 9

Activity 27: Creating a SQL Definition In this activity, you will review the activity overview and create a SQL definition, then replace the SQL string in a SQLExec statement with the SQL definition you created.

See PeopleCode: Activity Guide, “Executing SQL in PeopleCode,” Activity 27: Creating a SQL Definition.

Slide 275 ______________________________________________________________________________________________________

Activity Overview

Many of the early limitations of SQLExec are resolved by using SQL definitions in your SQLExec functions. No more “black box” string literals that cannot be maintained by PeopleTools, plus SQL definitions add platform independence and code reusability.

In this activity, you will create a new SQL definition in Application Designer. Then you will substitute that SQL definition for the quoted SQL statement in the SQLExec you created earlier to select the sum of Effort Amount entries for a given task.

Creating a SQL Definition

In this activity you will:

1. Create a SQL definition to sum Effort Amounts for all resources assigned to a task.

2. Explore the features of the SQL Editor.

3. Replace the SQL string in a SQLExec statement with the SQL definition you created.

Creating a new SQL Definition

To create a new SQL definition:

1. In Application Designer, select File, New.

2. For the definition type, choose SQL.

3. Select OK.

4. Add the SQL statement below. If you copy and paste from PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange PeopleCode, be sure to add the %Table Meta-SQL.

Select Sum(EFFORT_AMT) from %Table(PSU_TASK_EFFORT) where TASK = :1

5. Save your definition as PSU_EFFORT_SUM.

Exploring the SQL Editor

While you’re here, take a minute to look at some other features of the SQL Editor.

1. Select the dropdown under the title bar.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 96: Peoplecode Activity Guide

E x e c u t i n g S Q L i n P e o p l e C o d e L e s s o n 1 6

9 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

You can write database-specific SQL and associate it with the appropriate platform in the SQL definition. Along with meta-SQL, this gives you another level of database-independence.

2. Right-click in the editor pane and choose Resolve Meta-SQL from the popup menu.

Notice the output window shows what the SQL looks like when it executes. In this case, it resolves the record name in %Table by adding “PS_” as a prefix to it.

This handy bit of meta-SQL allows the use of record names instead of table names in the SQL definition, which is a huge plus at upgrade time. The “black box” problem we encountered with quoted literals is eliminated.

3. Select the Properties button (or ALT+ENTER, or right-click and choose Definition Properties), choose the Advanced tab, and select the Show Effective Date checkbox. OK.

SQL Definitions are effective-dated. By showing the effective date in the Editor window, you can effective-date versions of your code.

Using a SQL Definition in PeopleCode

Many of the early limitations of SQLExec are resolved by using SQL definitions in your SQLExec functions. No more “black box” string literals that cannot be maintained by PeopleTools, plus platform independence and code reusability.

To rewrite a SQLExec statement to use the SQL definition you created:

1. Open the program you created in the previous activity, in PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange.

It should look like this:

SQLExec("Select Sum(EFFORT_AMT)from PS_PSU_TASK_EFFORT where TASK = :1", PSU_TASK_TBL.TASK, PSU_TASK_TBL.EFFORT_SPENT);

2. Modify the PeopleCode to use the SQL definition instead of the SQL statement in a quoted literal.

SQLExec(SQL.PSU_EFFORT_SUM, PSU_TASK_TBL.TASK, PSU_TASK_TBL.EFFORT_SPENT);

3. Test using the new PeopleCode.

4. Select Set Up Training, Training Tasks, Task Table.

Verify that the Effort Spent field is updating properly.

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 97: Peoplecode Activity Guide

L e s s o n 1 6 E x e c u t i n g S Q L i n P e o p l e C o d e

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9 1

Activity 28: Using a SQL Object In this activity, you will review the activity overview and modify the PeopleCode you created in PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange to use a SQL object.

See PeopleCode: Activity Guide, “Executing SQL in PeopleCode,” Activity 28: Using a SQL Definition with a SQL Object.

Slide 280 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will modify the PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange PeopleCode program to use a SQL object instead of a SQLExec statement.

Using a SQL Object

To modify your PeopleCode to use a SQL object:

1. In Application Designer, open PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN.FieldChange and edit the code so it looks like this:

/* Whenever the refresh button is invoked, update EFFORT_SPENT to reflect actual values in EFFORT_AMT */

/* Declare the SQL object */

Local SQL &SelectEffort;

Local Number &Spent;

/* Instantiate the SQL object using the SQL Definition */

&SelectEffort = GetSQL(SQL.PSU_EFFORT_SUM, PSU_TASK_TBL.TASK);

If &SelectEffort.Fetch(&Spent) Then

PSU_TASK_TBL.EFFORT_SPENT.value = &Spent;

DERIVED_TRAIN.EFFORT_TO_GO.Value = PSU_TASK_TBL.EFFORT_TOTAL.value - PSU_TASK_TBL.EFFORT_SPENT.value;

End-If;

2. Test.

This concludes the activity. Do not continue. Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 98: Peoplecode Activity Guide

E x e c u t i n g S Q L i n P e o p l e C o d e L e s s o n 1 6

9 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 29: Choosing the Best SQL Option In this activity, you will review the activity overview and list the pros and cons of the different ways to execute SQL in PeopleSoft.

See PeopleCode: Activity Guide, “Executing SQL in PeopleCode,” Activity 29: Choosing the Best SQL Option.

Slide 287 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will discuss as a class the advantages and disadvantages of using the various options you have learned for executing SQL in PeopleSoft. Bear in mind that the Component Processor is also using SQL to select and update data in the database.

Choosing the Best SQL Option

If there was one best way to do everything, you wouldn’t need choices. PeopleSoft gives you several choices for executing SQL because each option has its pros and cons in different situations.

Fill in the tables below with the pros and cons of each option.

Component Processor

Pros Cons

SQL Definition

Pros Cons

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 99: Peoplecode Activity Guide

L e s s o n 1 6 E x e c u t i n g S Q L i n P e o p l e C o d e

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9 3

SQLExec

Pros Cons

SQL Object

Pros Cons

Record Object

Pros Cons

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 100: Peoplecode Activity Guide

E x e c u t i n g S Q L i n P e o p l e C o d e L e s s o n 1 6

9 4 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 30: Executing SQL in PeopleCode In this activity, you will review the activity overview and upgrade a SQLExec to use object-oriented PeopleCode. Then you will use a Record object to keep Effort Spent current.

See PeopleCode: Activity Guide, “Executing SQL in PeopleCode,” Activity 30: Executing SQL in PeopleCode.

Slide 289 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will use two of the techniques you have learned to execute SQL statements from within PeopleCode.

Use the appropriate SQL technique to accomplish the following tasks:

1. Upgrading a SQLExec to Object-Oriented PeopleCode.

Earlier in this lesson you saw an example of a SQLExec that was used in SavePostChange to update the Student Table, PSU_STUDENT_TBL, when an address was changed on the Customer Table, PSU_CUST_TBL.

For this activity, you will:

• Create a new SQL definition, add the SQL statement to it, and Save As PSU_UPDATE_STUDENT.

• Modify the code in the PSU_CUST component to use a SQL object and your new SQL definition.

• Test. Change an address on the Customer Table. The change should appear on the Student Table for a student who works for that customer and has Same Address as Customer checked.

2. Using a Record Object to Keep Effort Spent Current.

In this lesson you wrote some SQL that updated Effort Spent on the Task Table.

The problem with that is that Effort Spent is never updated until a user opens that page, which can lead to a data integrity problem.

For instance, if someone were to use Effort Spent in a report, it would not necessarily be accurate.

Modify your application so that Effort Spent will always be current.

Use a record object in your solution.

Executing SQL in PeopleCode

Following are potential solutions to the activity.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 101: Peoplecode Activity Guide

L e s s o n 1 6 E x e c u t i n g S Q L i n P e o p l e C o d e

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9 5

Upgrading a SQLExec to Object-Oriented PeopleCode

Earlier in this lesson you saw an example of a SQLExec that was used in SavePostChange to update the Student Table, PSU_STUDENT_TBL, when an address was changed on the Customer Table, PSU_CUST_TBL.

1. Create a new SQL definition, add the SQL statement to it, and Save As PSU_UPDATE_STUDENT.

[PSU_UPDATE_STUDENT.0 (SQL Definition)]

UPDATE %Table(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'

2. Modify the code in the PSU_CUST component to use a SQL object and your new SQL definition.

[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(SQL.PSU_UPDATE_STUDENT, 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;

Using a Record Object to Keep Effort Spent Current.

In this lesson you wrote some SQL that updated Effort Spent on the Task Table.

The problem with that is that Effort Spent is never updated until a user opens the Task Table page, even though it may have been changed on the Task Resources page. This can lead to a data integrity problem.

For instance, if someone were to use Effort Spent in a report, it would not necessarily be accurate.

Modify your application so that Effort Spent will always be current.

Use a record object in your solution.

[PSU_TASK_EFFORT.EFFORT_AMT-SavePostChange]

Local Field &Amt;

Local Record &TaskRec;

&Amt = GetField();

If &Amt.IsChanged Then

SQLExec("Select Sum(EFFORT_AMT) from PS_PSU_TASK_EFFORT where TASK = :1", PSU_TASK_EFFORT.TASK, &EffortSum);

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 102: Peoplecode Activity Guide

E x e c u t i n g S Q L i n P e o p l e C o d e L e s s o n 1 6

9 6 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

&TaskRec = CreateRecord(Record.PSU_TASK_TBL);

&TaskRec.TASK.Value = PSU_TASK_EFFORT.TASK;

&TaskRec.EFFORT_SPENT.Value = &EffortSum;

&TaskRec.Update();

End-If;

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 103: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9 7

L e s s o n 1 7

Final Course Activity

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 104: Peoplecode Activity Guide

F i n a l C o u r s e A c t i v i t y L e s s o n 1 7

9 8 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Activity 31: Using a Standalone Rowset to Track Overtime Hours In this activity, you will review the activity overview and write a PeopleCode program that tracks overtime hours using a standalone rowset.

See PeopleCode: Activity Guide, “Final Course Activiy,” Activity 31: Using a Standalone Rowset to Track Overtime Hours.

Slide 293 ______________________________________________________________________________________________________

Activity Overview

In this activity, you will have the opportunity to bring together some of the concepts you have learned.

A requirement has been identified to place a field on the Task page that will track overtime hours for each task.

To accomplish this, you will need to create a standalone rowset that contains all the efforts for a task. Then loop through that rowset and check each row for effort amount. If the effort is greater than 8, add the amount over 8 to an accumulator.

(You may think of another way to accomplish this. Try it first using a standalone rowset, then when this is working, try it your way.)

Display the accumulator on the Task page. Include a button on the Task page to refresh the Total Overtime field.

After you get your SQL working with a quoted literal, store the SQL statement in a SQL definition and modify your program to use the SQL definition.

Using a standalone rowset to track overtime hours

To place a field on the Task page that will track total overtime hours for a each task, perform the following tasks:

1. Display the accumulator on the Task page.

2. Create a standalone rowset.

3. Populate the rowset using a data buffer method.

4. Loop through the rows in the rowset to check overtime hours.

Displaying the accumulator on the Task page.

To display the accumulator on the Task page:

1. Create a new number field, TOTAL_OT.

2. Add TOTAL_OT to the DERIVED_TRAIN record definition.

3. Place a display-only field on the page and associate the field with DERIVED_TRAIN.TOTAL_OT.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 105: Peoplecode Activity Guide

L e s s o n 1 7 F i n a l C o u r s e A c t i v i t y

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 9 9

4. Put a button on the Task page to refresh the Total Overtime field.

5. Associate it with the field DERIVED_ED_SVCS.REFRESH_BTN.

Creating a standalone rowset

To create a standalone rowset, enter the following code on the PSU_TASK_TBL component.

[PSU_TASK.GBL.DERIVED_ED_SVCS-RowInit]

and

[PSU_TASK.GBL.DERIVED_ED_SVCS.REFRESH_BTN-FieldChange]

Local Rowset &TaskEffort;

Local number &N, &OT, &I;

&TaskEffort = CreateRowset(Record.PSU_TASK_EFFORT);

Populating the rowset using a data buffer method

Add the following code to the programs you wrote in the previous step.

&N = &TaskEffort.Fill("Where TASK = :1", PSU_TASK_TBL.TASK);

Looping through the rows in the rowset to check overtime hours.

Loop through your rowset and check each row for Effort Amount. If the effort is greater than 8, add the amount over 8 to an accumulator.

Add the following code to the programs you wrote in the previous step.

DERIVED_TRAIN.TOTAL_OT.SetDefault();

For &I = 1 To &N

&OT = &TaskEffort(&I).PSU_TASK_EFFORT.EFFORT_AMT.Value - 8;

If &OT > 0 Then

DERIVED_TRAIN.TOTAL_OT = DERIVED_TRAIN.TOTAL_OT + &OT;

End-If;

End-For;

This concludes the activity. Do not continue.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 106: Peoplecode Activity Guide

F i n a l C o u r s e A c t i v i t y L e s s o n 1 7

1 0 0 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 107: Peoplecode Activity Guide

P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l 1 0 1

L e s s o n 1 8

Course Review

This lesson has no activities.

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 108: Peoplecode Activity Guide

C o u r s e R e v i e w L e s s o n 1 8

1 0 2 P e o p l e S o f t P r o p r i e t a r y a n d C o n f i d e n t i a l

Notes

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________

______________________________________________________________________ Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only