34998438-peoplesoft-application-engine-program.pdf

17
Page 1 of 17 Application Engine Exercise #3: Archiving Records Do Select vs. Set Processing In this exercise, you will create an AppEngine program that accesses the course catalog table to archive all courses that have EFF_STATUS = “I” (inactive). The records will be read from the course catalog table with a Do Select, INSERTed into an archive record you will create and then DELETEd from the course catalog table (but not really deleted!). Then you will create another AppEngine program that performs the same function by utilizing set processing. The trace timings file for each type of processing will be reviewed and compared. Table name: PS_CRSE_CATALOG Web navigation: Manage Student Records > Establish Courses > Use > Course Catalog First, you will need a project. You may open an existing project or create a new one. If you need instructions on how to do either of those operations, please refer to Exercise #1 or Exercise #2. As in Exercise #2 you will need a state record. However, instead of using the state record to accept runtime parameters from the user, you will use a state record to temporarily hold field values as you transfer them from the PS_CRSE_CATALOG table to an archive table you will create. The state record is necessary because you will be passing information between steps in your AppEngine program. The first thing you should do is create the archive record that you will use to store the records archived from the PS_CRSE_CATALOG table. 1. You will need to insert all of the fields you wish to save from PS_CRSE_CATALOG into your new archive record. The easiest way to do that is to add PS_CRSE_CATALOG to your project so you can drop-and-drag the fields you want onto the new record. 2. Insert all the fields you need in your archive record. For this exercise you do not need to insert all the fields in CRSE_CATALOG (please include at least CRSE_ID, EFFDT, DESCR, and CRSE_CONTACT_HRS), and you will need to use the same key structure so you’ll need to verify that they are both CRSE_ID and EFFDT are marked as keys. 3. Once you have all the fields inserted and have verified that CRSE_ID and EFFDT are marked as “Keys”, and then you need to save your new archive record.

Upload: saurabh-mehta

Post on 14-Apr-2015

67 views

Category:

Documents


1 download

DESCRIPTION

ps

TRANSCRIPT

Page 1: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 1 of 17

Application Engine

Exercise #3: Archiving Records Do Select vs. Set Processing

In this exercise, you will create an AppEngine program that accesses the course catalog table to archive all courses that have EFF_STATUS = “I” (inactive). The records will be read from the course catalog table with a Do Select, INSERTed into an archive record you will create and then DELETEd from the course catalog table (but not really deleted!). Then you will create another AppEngine program that performs the same function by utilizing set processing. The trace timings file for each type of processing will be reviewed and compared. Table name: PS_CRSE_CATALOG Web navigation: Manage Student Records > Establish Courses > Use > Course Catalog First, you will need a project. You may open an existing project or create a new one. If you need instructions on how to do either of those operations, please refer to Exercise #1 or Exercise #2. As in Exercise #2 you will need a state record. However, instead of using the state record to accept runtime parameters from the user, you will use a state record to temporarily hold field values as you transfer them from the PS_CRSE_CATALOG table to an archive table you will create. The state record is necessary because you will be passing information between steps in your AppEngine program. The first thing you should do is create the archive record that you will use to store the records archived from the PS_CRSE_CATALOG table.

1. You will need to insert all of the fields you wish to save from PS_CRSE_CATALOG into your new archive record. The easiest way to do that is to add PS_CRSE_CATALOG to your project so you can drop-and-drag the fields you want onto the new record.

2. Insert all the fields you need in your archive record. For this exercise you do not

need to insert all the fields in CRSE_CATALOG (please include at least CRSE_ID, EFFDT, DESCR, and CRSE_CONTACT_HRS), and you will need to use the same key structure so you’ll need to verify that they are both CRSE_ID and EFFDT are marked as keys.

3. Once you have all the fields inserted and have verified that CRSE_ID and EFFDT

are marked as “Keys”, and then you need to save your new archive record.

Page 2: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 2 of 17

Click on File, Save As… or Click on . Type a name for your state record (please follow established naming conventions explained in UNTSP Standards document found in the Shared Documents section of the EIS Developer Forum website), and then click on OK (or press ENTER).

4. You must “build” the record since this will be a physical SQL table. With the record definition open on the screen, click on Build, then on Current Object.

5. Verify that the boxes for “Create Tables” is checked and the radio button for

“Execute and build script” is selected, then click on the button labeled “Build”. Once the build process has completed, verify that you received no errors and no warnings in the “Build” messages window at the bottom of the screen.

The next thing you should do is create the state record to be used in this exercise.

1. The key field (and the only key field) for a state record should be the field called “PROCESS_INSTANCE” (do not use the field “PROCESSINSTANCE”). To insert the field into your record, on the menu bar click on Insert, then on Field…

2. You will also need a field on your state record for each of the fields that will be

written from the source record to the archive record. You can use the same drag-and-drop technique that you used in Step “e” above to insert the fields from CRSE_CATALOG or GBUT_xx_EX3_ARC into your state record. When completed the state record should contain PROCESS_INSTANCE and all the fields in your archive record. Your state record should look something like this:

In this example, only CRSE_ID, EFFDT, DESCR, and CRSE_CONTACT_HRS are being pulled from CRSE_CATALOG to be stored on the archive record.

Save As GBUT_xx_EX3_ARC (where xx is replaced by your computer number)

GBUT_xx_EX3_ARC

Page 3: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 3 of 17

Note: PROCESS_INSTANCE must be the key (and the only key) on the state record. If you drag-and-drop CRSE_ID and EFFDT from another record, verify that they are not marked as keys on the state record. Also notice that one additional field is included on this state record, COUNTER. This field will be used to count how many records are archived from the CRSE_CATALOG table. More about that later…

3. Now you need to save your state record definition. Click on File, Save As… or

Click on . Type a name for your state record (please follow established naming conventions explained in UNTSP Standards document found in the Shared Documents section of the EIS Developer Forum website), and then click on OK (or press ENTER).

4. Do you need to “build” this state record? Should this program be restartable?

Now you are ready to create the program you will use to “archive” records.

1. Click on File, New… or click on

2. In the “New” window first choose an Object Type of “App Engine Program”, then click on “OK”.

3. You should now see a “skeleton” AppEngine program containing a “MAIN” section and one step labeled “Step01” displayed in the Object workspace

Save As GBUT_xx_EX3_AET

GBUT_xx_EX3_AET

Page 4: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 4 of 17

4. Open the AppEngine Program Properties window:

a. Click on or b. Click on File, Object properties or c. Press ALT-ENTER on your keyboard

5. Click on the “Advanced” tab and “check” the “Disable Restart” box. It is

important to disable restart of a program while testing to prevent problems with rerunning the job. Once the program is tested, “Disable Restart” may be “unchecked” to test restart processing. Click OK to close the Program Properties window.

Page 5: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 5 of 17

6. Now, save this AppEngine program with a new unique name. Click on File, Save As. Type a unique name for your program (please follow established naming conventions explained in UNTSP Standards document found in the Shared Documents section of the EIS Developer Forum website), and then click on OK (or press ENTER).

7. Now you need to add some Actions to your program (so it will actually do something!). To insert an Action (without inserting another Step along with the Action), either

d. Right-click on the area to the left of “Step01” and click on “Insert Action”. or

e. Click once on “Step01” to highlight it and click on

8. The default action is “SQL”. Change the action to “Do Select” by choosing it from the drop-down list.

Right-click in this area and click on Insert Action

Save As GBUT_xx_EX3

GBUT_XX_EX3

Page 6: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 6 of 17

9. Double-click in the area to the left of the “Do Select” action to open the SQL Editor.

10. The SQL need to perform two functions. The first is to populate the fields in your state record using a %Select (meta-SQL) command. The second is to SELECT the records to be archived from the CRSE_CATALOG table. The SQL should look like this:

%Select(CRSE_ID, EFFDT, DESCR, CRSE_CONTACT_HRS) SELECT A.CRSE_ID , %DateOut(A.EFFDT ) , A.DESCR , A.CRSE_CONTACT_HRS FROM PS_CRSE_CATALOG A

WHERE A.EFF_STATUS = 'I'

11. Click on to check the syntax of the SQL statement. Important note – this will not validate that your SQL is correct (i.e., correct table name, correct field names, etc). It will basically reformat your SQL the way it wants it to look. Misspelling names or misplaced commas or parentheses will cause runtime errors.

12. Close the SQL editor window.

13. Save your program again.

14. Now add another Action within Step01 by

a. right-clicking on the area to the left of the “Do Select” action and clicking on “Add Action” or

b. by clicking once on the “Do Select” action to highlight it and clicking on

the “Insert Action” button on the toolbar

15. This new action should be “PeopleCode” so choose that from the drop-down box. Since you put this “PeopleCode” action in the same Step as the “Do Select” action, the PeopleCode will fire for each record processed in the “Do Select”.

16. Double-click in the area to the left of the “PeopleCode” action to open the PeopleCode Editor.

17. Type the following code:

GBUT_xx_EX3_AET.COUNTER = GBUT_xx_EX3_AET.COUNTER + 1;

This code will add one to the counter on our state record for each record processed in the “Do Select”. After all records are processed, you will write the counter out in a Log Message to let the user know how many records were archived.

Double-click in this area to open the SQL Editor

Page 7: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 7 of 17

18. Save your program again.

19. Now you need to add the INSERT logic that will write a record to your archive table. This could be done within the same Section/Step, but because you should use modularity in your program you will create a new Section to perform that operation. The reasons for this will become more obvious later (hopefully).

a. To insert a new Section, right-click in the area to the left of either the Main

Section, Step01, the “Do Select” action, or the “PeopleCode” action and click on Insert Section or

b. Click on the Insert Section button on the toolbar .

20. The new Section is inserted with a default name of “Section1”. To make this more meaningful in the flow of our program, rename the Section to “Insert” so that it describes the action taking place. Just click on the box containing the name and type over “Section1”.

21. The new “Insert” Section needs a Step and an Action so

a. Right-click in the area to the left of the “Insert” Section and click on Insert Step/Action or

b. Click on the Insert Step/Action button on the toolbar

22. The default action is “SQL” which is just what you want. Double-click in the area to the left of the “SQL” action to open the SQL Editor. Type in the following SQL: INSERT INTO PS_GBUT_xx_EX3_ARC

VALUES (%Bind(CRSE_ID) , %Bind(EFFDT) , %Bind(DESCR) , %Bind(CRSE_CONTACT_HRS))

This code will populate the fields in your archive table from the fields in the state record using the %Bind command and insert a record into the table.

23. Because you would want to DELETE the records from CRSE_CATALOG after

they are successfully written to the archive table (because that is the purpose of archiving records, right?), you will need to add another Section to perform the DELETE function. Since it doesn’t really matter where the new Section is inserted (all Sections other than Main must be called specifically…you’re going to add those actions soon), just click on the Insert Section button on the toolbar

. Name this new Section “Delete”.

24. The “Delete” Section needs a Step/Action so

a. Right-click in the area to the left of the “Delete” Section you just added and click on Insert Step/Action or

Page 8: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 8 of 17

b. Click on the Insert Step/Action button on the toolbar

25. The default action is “SQL” which is just what you want. Double-click in the area to the left of the “SQL” action to open the SQL Editor. Type in the following SQL: DELETE

FROM PS_CRSE_CATALOG A WHERE A.CRSE_ID = %Bind(CRSE_ID)

AND A.EFFDT = %Bind(EFFDT)

This SQL will delete only the record that was just INSERTed into the archive record from the state record because we are matching on the keys from the source record that were stored in the state record during processing.

26. Now you need to add actions that will cause two new Sections you added (“Insert” and “Delete”) to be executed. In order for each record chosen for archival in the Do Select statement to be INSERTed into the archive table, the “Insert” Section must be in the same step as the “Do Select” action so that it will be called once for each iteration of the loop. Add a new action to the Main Section/Step01 by right-clicking on the “PeopleCode” action (or the “Do Select” action since it doesn’t really matter if you increment the counter before or after the “Insert” Section is performed), and clicking on “Insert Action”. Alternately, you may highlight the action you want to insert a new action after and click on the Insert Action button

in the toolbar .

27. The newly inserted action should be “Call Section” so choose that from the drop-down box. Then tab to the box labeled “Section Name:” (it will appear as soon as you’ve tabbed off the action type) and use the drop-down list to select “Insert”. Notice that the drop-down list contains all the sections in your AppEngine program. If you needed to call a Section in a different AppEngine program (like a subroutine used by many different programs), you would be required to enter the “Program Name:” as well as the Section Name. In this exercise, the program name is filled in for you.

28. Now you need to add a new action to execute the “Delete” Section. This action

should be added within the “Insert” Section so that after each INSERT, a DELETE will be performed. However, since “SQL” actions and “Call Section” actions are mutually exclusive, the “Call Section” must be placed within its own step after the step containing the “SQL” action.

29. Insert a new Step/Action below the “SQL” action that performs the INSERT.

Choose “Call Section” and choose “Delete” for the Section Name.

Page 9: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 9 of 17

30. You should now add an action to write out a Log Message that tells the user how many records were archived. Since you do not want the Log Message to be performed for every record processed, you should not put the Log Message in the same step as the “Do Select” action. Therefore, add another Step/Action to the Main section so that you will now have Step02.

31. Change the default action to “Log Message”, type in 20101 for the Message Set

and 3 for the Message Number (this message has already been added to the Message Catalog). Type the following in the “Parameters:” box so that the counter field from the state record will be put into the message:

%Bind(COUNTER)

32. Save your program again.

33. The last modification necessary is to link the state record you created to the AppEngine program. This is done in the Program Properties.

Open the AppEngine Program Properties window:

f. Click on or g. Click on File, Object properties or h. Press ALT-ENTER on your keyboard

34. Click on the “State Records” tab. In the box labeled “Qualify Search”, you can

type a partial name or the full name of your state record and click on the button labeled “Get List”. DO NOT PRESS ENTER…that will close the Program Properties window.

35. Click once on your state record to highlight it and click on the button labeled “Add”. You will now see your state record listed in the “Selected” window on the right. It is automatically selected as the “default” state record because it is the only one you are using. If you were using more than one state record with your AppEngine program, you would continue to add then using the same process just described.

Special Note: Since you don’t really want to delete courses from the CRSE_CATALOG table since others may be using it, you should “inactivate” the step that does the “Call Section” for section name “Delete” by unchecking the “Active” box on the step containing the action (probably labeled “Step02”). If the step is not active, it will not be executed and the program will never really call the “Delete” section.

Page 10: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 10 of 17

Now, you are almost ready to test your AppEngine program! In order to run an AppEngine program, you must first create a Run Control Page and a Component to contain the page. Since this exercise does not accept input from the user, you can clone the PRCSRUNCNTL page delivered from PeopleSoft. See Exercise #1 for detailed steps on setting up the Run Control Page, Component, Menu, and Security. Then notify the instructor that you are ready to have the Component added to a Menu and the Security set for the Component.

The last step before you can run the AppEngine program you’ve created is to create a Process Definition for the PeopleSoft Process Scheduler. This step must be completed whether you are running the AppEngine program two-tier, three-tier, or n-tier. To create a Process Definition:

1. On the web, navigate to PeopleTools > Process Scheduler Manager > Use > Process Definitions

2. Click on the hyperlink “Add a New Value”

3. Click on the lookup icon and then click on Lookup 4. Click on the hyperlink “Application Engine” 5. Type in the Process Name – This must match your AppEngine program

name! 6. Click on Add 7. Click on the “Process Definition Options” tab 8. In the Component section of the form, click on the Lookup icon and select your

Component (this will be the Component that contains your Run Control Page) 9. In the Process Groups section of the form, click on the Lookup icon and select the

permission list used with this AppEngine program (in this exercise use ALLPANLS)

10. Click on Save Believe it or not, you are finally ready to run your AppEngine program! First, create and run a query to determine how many courses are marked as “Inactive” (EFF_STATUS = “I”). This can be accomplished either by running a query in SQL+ that uses the COUNT(*) parameter or by writing a simple query through Query Manager. To execute your AppEngine program via the web:

1. Navigate to the Menu Item you added. When you click the menu item a Run Control Search Page will be displayed.

2. If you have an existing Run Control ID you want to use, you can type the name

(or partial name) and click on Find. If you want to add a new one, click on the hyperlink “Add a New Value” then type a value for the Run Control ID and click on Add. This can be any value you wish…it does not need to match the AppEngine program name and can be reused.

Page 11: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 11 of 17

3. When the Run Control Page is displayed, click on Run.

4. A page containing a list of all Process Definitions linked to this Component (via Security) is displayed. Since the Process Definition name must match your AppEngine program name, this provides the link that PeopleSoft will need to know which program to run. Click on OK to submit the Process Scheduler Request.

5. The display will return to the Run Control Page and display your Process

Instance. You can now click on the hyperlink “Process Monitor” to view the progress of your program execution. For more information on the “Process Monitor”, please see Exercise #1.

6. Verify that the message written to the message log contains the number of records you expected to be archived.

Now to illustrate how some of the options (specifically the “Reuse” option on SQL actions) in your AppEngine program can make a difference, you will run your program through the interactive debugger so that you can view the trace files. You will find the trace files on your hard drive under the following folder structure:

C:\Documents and Settings\Administrator\Local Settings\Temp\PS\LSTRA

The name of the trace files will be AE_ followed by a datetime stamp and with a .AET extension. To activate the interactive debugger, you can copy a batch program written by Philip Buehler that will ask you all the right questions and create a command line for you. The batch program can be found at

\\CC3\EIS\SharedDocuments\Technical\TrainingMaterial\AppEngine\AppEngineDebug.

bat

Copy the file to a location on your hard drive for execution. To execute the interactive debugger, use the Windows Command Prompt.

1. Click on Start, Programs, Accessories, Command Prompt. 2. When the window appears, change to the folder where you stored the

AppEngineDebug.bat file. 3. Type AppEngineDebug. 4. When prompted for Database name, type LSTRA and press ENTER 5. When prompted for Operator ID, type PS and press ENTER 6. When prompted for Password, type PS and press ENTER 7. When prompted for Run Control, type a run control ID and press ENTER (this

can be one that you’ve previously used or a new one)

Page 12: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 12 of 17

8. When prompted for the App Engine Program Name, type GBUT_xx_EX3 (or whatever you named your AppEngine program) and press ENTER

9. You will then be asked if you’ve entered all the above parameters correctly. If you have, type “Y” to begin execution. If you did not, type “N” and you will be able to enter them again.

10. When the program begins execution, it will stop at the first step (in this case GBUT_xx_EX3.MAIN.Step01). At this point, you can type a ? to see a list of commands. Since you don’t really need to step through the execution for this exercise, type G to complete execution of the program.

11. You will see the actions being performed in the Command Prompt windows. When the program completes, navigate to the trace file created. It will look something like this:

PeopleTools 8.18.07 -- Application Engine

Copyright (c) 1988-2003 PeopleSoft, Inc.

All Rights Reserved

Database: LSTRUL(Oracle)

15.18.46 2003-05-06 Tracing Application Engine program EXERCISE_3

15.18.47 .(EXERCISE_3.MAIN.Step01) (Do Select)

%Select(CRSE_ID, EFFDT, DESCR, CRSE_CONTACT_HRS) SELECT A.CRSE_ID ,

TO_CHAR(A.EFFDT,'YYYY-MM-DD') , A.DESCR , A.CRSE_CONTACT_HRS FROM

PS_CRSE_CATALOG A WHERE A.EFF_STATUS = 'I'

/

-- Buffers:

-- 1) 007180

-- 2) 1900-01-01

-- 3) Astrophysics

-- 4) 0

15.18.47 .(EXERCISE_3.MAIN.Step01) (PeopleCode)

15.18.47 .(EXERCISE_3.MAIN.Step01) (Call Section EXERCISE_3.INSERT)

15.18.49 ..(EXERCISE_3.INSERT.Step01) (SQL)

INSERT INTO PS_EXERCISE_3_ARC VALUES ('007180' ,

TO_DATE('1900-01-01','YYYY-MM-DD') , 'Astrophysics' , 0)

/

The above actions are repeated for each of the courses to be archived…

/

15.19.13 .(EXERCISE_3.MAIN.Step01) (Do Fetch)

-- Buffers:

-- 1) 002046

-- 2) 2003-05-06

-- 3) LSAT Test Preparation

-- 4) 0

Page 13: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 13 of 17

15.19.13 .(EXERCISE_3.MAIN.Step01) (PeopleCode)

15.19.13 .(EXERCISE_3.MAIN.Step01) (Call Section EXERCISE_3.INSERT)

15.19.13 ..(EXERCISE_3.INSERT.Step01) (SQL)

INSERT INTO PS_EXERCISE_3_ARC VALUES ('002046' ,

TO_DATE('2003-05-06','YYYY-MM-DD') , 'LSAT Test Preparation' , 0)

/

15.19.13 .(EXERCISE_3.MAIN.Step01) (Do Fetch)

15.19.13 .(EXERCISE_3.MAIN.Step02) (Log Message)

COMMIT

/

15.19.14 Application Engine program EXERCISE_3 ended normally

15.19.14 Application Engine ended normally

PeopleSoft Application Engine Timings (All timings in seconds) 2003-05-06 15.19.14 C o m p i l e E x e c u t e F e t c h Total SQL Statement Count Time Count Time Count Time Time ------------------------------ ------- -------- ------- -------- ------- -------- -------- Application Engine COMMIT 0 0.0 1 0.2 0 0.0 0.2 LOGMSG 0 0.0 1 0.5 0 0.0 0.5 -------- 0.7 AE Program: EXERCISE_3 INSERT.Step01.S 108 0.0 108 23.6 0 0.0 23.6 MAIN.Step01.D 1 0.0 1 0.3 109 0.0 0.3 -------- 23.8 ------------------------------------------------------------------------------------------ Call Non-SQL SQL Total PeopleCode Count Time Time Time ------------------------------ ------- -------- -------- -------- AE Program: EXERCISE_3 MAIN.Step01 108 0.3 0.0 0.3 -------- -------- -------- 0.3 0.0 0.3 ------------------------------------------------------------------------------------------ Total run time : 36.0 Total time in application SQL : 24.5 Percent time in application SQL : 68.0% Total time in PeopleCode : 0.3 Percent time in PeopleCode : 0.9% Total time in cache : 8.6 Number of calls to cache : 4 ------------------------------------------------------------------------------------------ PeopleTools SQL Trace value: 31 (0x1f) PeopleTools PeopleCode Trace value: 31 (0x1f) Application Engine Trace value: 131 (0x83) Application Engine DbFlags value: 0 (0)

Notice that the SQL INSERT code was compiled each time it was executed.

Page 14: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 14 of 17

Now, modify your AppEngine program so that the SQL is reusable. This will send it to the database only once (since the SQL doesn’t change during the life of the program) and save processing time. On the “SQL” action in the “Insert” Section, you will see a box labeled “ReUse Statement:”. Change the value to “Yes”. If the “Delete” section were active, you would also want to change it to reusable. The option has no effect on the “Do Select” action because that is only sent to the database one time anyway and all the records that meet the selection criteria are placed in the cursor for processing. Once you’ve saved your program again, run it a second time through the interactive debugger and look at the trace file. The difference will be that instead of compiling the code 108 times, it only compiles once. Although you won’t see any difference in processing time in this example (since it didn’t even take a tenth of a second anyway), it could make a very big difference it there were more records to process. PeopleSoft Application Engine Timings (All timings in seconds) 2003-05-06 15.21.21 C o m p i l e E x e c u t e F e t c h Total SQL Statement Count Time Count Time Count Time Time ------------------------------ ------- -------- ------- -------- ------- -------- -------- Application Engine COMMIT 0 0.0 1 0.2 0 0.0 0.2 LOGMSG 0 0.0 1 0.3 0 0.0 0.3 -------- 0.5 AE Program: EXERCISE_3 INSERT.Step01.S 1 0.0 108 18.2 0 0.0 18.2 MAIN.Step01.D 1 0.0 1 0.2 109 0.0 0.2 -------- 18.4 ------------------------------------------------------------------------------------------ Call Non-SQL SQL Total PeopleCode Count Time Time Time ------------------------------ ------- -------- -------- -------- AE Program: EXERCISE_3 MAIN.Step01 108 0.2 0.0 0.2 -------- -------- -------- 0.2 0.0 0.2 ------------------------------------------------------------------------------------------ Total run time : 30.3 Total time in application SQL : 19.0 Percent time in application SQL : 62.6% Total time in PeopleCode : 0.2 Percent time in PeopleCode : 0.7% Total time in cache : 8.4 Number of calls to cache : 4 ------------------------------------------------------------------------------------------

Big difference!

Page 15: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 15 of 17

PeopleTools SQL Trace value: 31 (0x1f) PeopleTools PeopleCode Trace value: 31 (0x1f) Application Engine Trace value: 131 (0x83)

Application Engine DbFlags value: 0 (0) Now you will create an AppEngine program that performs the same process (archiving “inactive” courses) using Set Processing. You will see a big improvement in performance over using the “Do Select” because Set Processing allows the database to handle the record processing all at once rather than one record at a time. Create a new AppEngine program with the following structure:

The “SQL” action in the “INSERT” step should contain the following code: INSERT INTO PS_GBUT_xx_EX3_ARC SELECT A.CRSE_ID , A.EFFDT , A.DESCR , A.CRSE_CONTACT_HRS FROM PS_CRSE_CATALOG A

WHERE A.EFF_STATUS = 'I'

Page 16: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 16 of 17

The “SQL” action in the “DELETE” step should contain the following code: DELETE FROM PS_CRSE_CATALOG WHERE A.EFF_STATUS = 'I'

Because we are using Set Processing, there is no need for a state record for this program. Therefore, you will need to change the parameters for the “Log Message” action to use the meta-SQL variable “SQLRows” as a counter of records processed rather than the state record COUNTER field we used previously. Before you can run the program again, you will need to “clean out” the archive table or you will receive “unique constraint” errors (duplicate records). The easiest way to do this is to “build” it again in AppDesigner. This will recreate the table thereby getting rid of the existing data. Now run the program you’ve just created that uses Set Processing and look at the trace file. Notice that processing time decreased dramatically and where you previously had 108 executions, you now have one. PeopleTools 8.18.07 -- Application Engine Copyright (c) 1988-2003 PeopleSoft, Inc. All Rights Reserved Database: LSTRUL(Oracle) 15.22.37 2003-05-06 Tracing Application Engine program EXERCISE_3B 15.22.38 .(EXERCISE_3B.MAIN.Step01) (SQL) INSERT INTO PS_EXERCISE_3_ARC SELECT A.CRSE_ID , A.EFFDT , A.DESCR , A.CRSE_CONTACT_HRS FROM PS_CRSE_CATALOG A WHERE A.EFF_STATUS = 'I' / 15.22.39 .(EXERCISE_3B.MAIN.Step02) (Log Message) COMMIT / 15.22.39 Application Engine program EXERCISE_3B ended normally 15.22.39 Application Engine ended normally PeopleSoft Application Engine Timings (All timings in seconds) 2003-05-06 15.22.39 C o m p i l e E x e c u t e F e t c h Total SQL Statement Count Time Count Time Count Time Time ------------------------------ ------- -------- ------- -------- ------- -------- -------- Application Engine COMMIT 0 0.0 1 0.2 0 0.0 0.2 LOGMSG 0 0.0 1 0.5 0 0.0 0.5 -------- 0.7 AE Program: EXERCISE_3B MAIN.Step01.S 1 0.0 1 0.3 0 0.0 0.3 -------- 0.3 ------------------------------------------------------------------------------------------ Call Non-SQL SQL Total

Please note that this step should not be active, so be sure to “uncheck” the Active box!!!

Page 17: 34998438-PeopleSoft-Application-Engine-Program.pdf

Page 17 of 17

PeopleCode Count Time Time Time ------------------------------ ------- -------- -------- -------- (none) ------------------------------------------------------------------------------------------ Total run time : 6.0 Total time in application SQL : 1.0 Percent time in application SQL : 15.9% Total time in PeopleCode : 0.0 Percent time in PeopleCode : 0.0% Total time in cache : 2.3 Number of calls to cache : 3 ------------------------------------------------------------------------------------------ PeopleTools SQL Trace value: 31 (0x1f) PeopleTools PeopleCode Trace value: 31 (0x1f) Application Engine Trace value: 131 (0x83) Application Engine DbFlags value: 0 (0)

The moral of the story is that if you can use Set Processing rather than a “Do Select” loop, you will save on processing. However, not all programs lend themselves to Set Processing…you will have to decide it is will work for your application.