Explorations in Component Interface: Handling Component Interface Errors

This page has moved.  Please update your links:
http://psst0101.digitaleagle.net/2011/01/10/tip-comparing-trace-files/

This is a continuation of the following posts:

The plan this time is to try to see how well we can handle errors.  I have been having trouble with some of my production programs crashing when I have taken all the necessary steps to trap and handle the error.  So, we’ll see how this goes …

Read the rest of this entry »

Advertisements

Explorations in Component Interface: PeopleCode

This page has moved.  Please update your links:
http://psst0101.digitaleagle.net/2011/01/10/tip-comparing-trace-files/

This is a continuation of the following posts:

Now, we need to write some code to use the Component Interface.  Let’s use the Application Engine program from this step by step post.

Read the rest of this entry »

Explorations in Component Interface

This is part one of a multi-part series exploring some quirks in using Component Interfaces with Application Engine programs.  If nothing else, hopefully, these will give new developers some insight into how to use a Component Interface.  My goal is to expose a bug in the Application Engine tool that maybe Oracle will see and fix.

This first part will simply walk you through creating a Component Interface.  This part is just a map to associate the fields on the screen (or really in the component’s buffer) with an API property that can be accessed with code.

First, we create a new definition in Application Designer.  You can either use the Ctrl + N keyboard shortcut or the File > New menu.  Choose Component Interface from the list:

Selection_804

Next, have no fear — you will see the open dialog making it look like you want to open a component.  Really, Application Designer is just asking you which component you want to map.  In this example, we will use the “PERSONAL_DATA” component, which is the Modify a Person screen (Workforce Administration > Personal Information > Modify a Person):

Selection_805

Next, Application Designer asks you if you want to default the properties.  I almost always say yes to this questions because it will make Application Designer do all the work for you in generating the map.  The properties will be given names based on their field names in the buffer:

Selection_806

Now, you should have a new component interface generated for you.  Notice that the left side is the Component Structure.  It is the same as the Structure tab on the Component itself.  The right side is the map of record/field to property name.  In this screenshot, I have the component open in the background and I drew a line to show how the structure is the same.  Then, I drew a line from the structure to the property generated for one of the fields:

Selection_807

Finally, save the component interface.  You can either use the Ctrl + S keyboard shortcut, or you can use the File > Save menu.  I gave it the name BLG_PERS_DTA_CI.

Selection_808

While your at it, you may also want to add it to the project.  You can use the F7 keyboard shortcut or the Insert > Current Definition Into Project menu.

This concludes creating the Component Interface.  Please stay tuned for the next steps …

Step-by-Step: App Engine for Testing PeopleCode

This is a how-to post that I intend to refer back to from time to time.  The goal is to create a simple Application Engine program into which we can drop some PeopleCode and see how it works.  Assuming we don’t need any of the online pieces, this is much easier than going through all of the steps to create a page and register it so we can see it online.

Step 1: Create a new Application Engine Program

In Application Designer, click Ctrl + N or use the File > New menu option.  This will open the “New” dialog, and you can choose Application Engine program from the list.

Selection_548

You new program should look like this:

Selection_549

Step 2: Disable Restart

This step is very important.  If you don’t disable the restart and your program crashes, you will have to go through a few extra steps before you can rerun it.

First, click on the properties button while your program is in focus (you can also use the File > Definition Properties menu):

Selection_550

This should bring up the Properties dialog.  Then, go to the Advanced tab.  Check the “Disable Restart” option.

Selection_551

Step 3: Add an Action

First, click on the “Step 1” step to select it.  I usually click anywhere in the gray, and this should turn it black.

Selection_552

Next, click on the Add Action button, or you can use the Insert > Action menu.

Selection_553

Finally, change the type from SQL to PeopleCode.

Selection_554

Step 4: Save the program

At this point, you need to save before you can add PeopleCode.  You can use Ctrl + S, click on the Save icon on the toolbar, or you can use the File > Save menu.

Selection_555

Step 5: Enter the PeopleCode

First, open the PeopleCode program by double clicking anywhere on the gray of the PeopleCode action.  Or, you can right click on it and choose the “View PeopleCode” option.

Next, you will probably want to open a file to show output from your PeopleCode testing.  You can use this PeopleCode:

Local File &log;
&log = GetFile("c:\temp\log.txt", "W", "A", %Filepath_Absolute);

Then, you can print to that file with the writeline() method.  For now, we will just print Hello, World.

&log.WriteLine("Hello, World!");

Finally, you will probably want to close your file:

&log.Close();

Here is what it all looks like:

Selection_556

Make sure to save once you make these changes.

Step 6: Run the Program

Again, after you have saved, go back to the main program window where you can see the Main section, Step 1, and your new PeopleCode action.  Then, click the run icon.

Selection_557

In the dialog, Check the Output log to file and uncheck Run Minimized.  The output log to file allows you to see what happened.  Otherwise, the window will close before you see what happened.  The run minimized isn’t a big deal, but if the program doesn’t run minimized you see it pop up and go away better.  When the program goes away, you know it is done running.

Selection_559

Finally, when it is done, check the output.  If you used the paths that I did your output should be in the c:\temp directory.  You should have two files.  The first, is the main output from the program.  Check this to make sure the program ran to success:

Selection_560

The second is the log that your PeopleCode created.  For now, it should just say, “Hello, World”.

Selection_561

App Engine Action Types (AE_STMT_TYPE)

Here are the values for the AE_STMT_TYPE field.  This is useful if you are looking for an Application Engine with a certain type of action.

AE_STMT_TYPE:

  • H = Do When
  • N = Do Until
  • C = Call Section
  • W = Do While
  • X = XSLT
  • M = Log Message
  • S = SQL
  • P = PeopleCode
  • D = DoSelect

Log Messages in Application Engine

Here is some SQL that lists the Log Message actions in Application Programs:

SELECT A.AE_APPLID, A.AE_SECTION, A.AE_STEP,
M.AE_MESSAGE_PARMS, S.MESSAGE_SET_NBR, S.MESSAGE_NBR FROM
PSAESTMTDEFN A, PSAESTEPMSGDEFN M, PSAESTEPDEFN S
WHERE A.AE_APPLID = M.AE_APPLID
AND A.AE_APPLID = S.AE_APPLID
AND A.AE_SECTION = M.AE_SECTION
AND A.AE_SECTION = S.AE_SECTION
AND A.MARKET = M.MARKET
AND A.MARKET = S.MARKET
AND A.DBTYPE = M.DBTYPE
AND A.DBTYPE = S.DBTYPE
AND A.EFFDT = M.EFFDT
AND A.EFFDT = S.EFFDT
AND A.AE_STEP = M.AE_STEP
AND A.AE_STEP = S.AE_STEP
AND A.AE_STMT_TYPE = ‘M’

PeopleTools Reference: Meta-SQL %Table

%Table

Replaces with the actual table name of the given record.

Generally, this just means adding a “PS_” to the front of the record name. But, PeopleTools actually checks the alternate table name from the Record Type tab to see if a value is there first.

Two Uses:

  • Access a table with a reference or record object rather than embedding a table name in the SQL; PeopleTools will not index the table/record in a string literal.
  • Reference the Temporary table in an App Engine; %Table is the only way to reference the table because the table name is assign dynamically at run time.

Examples:

SELECT * FROM %Table(JOB) WHERE EMPLID = :1

SqlExec(“SELECT NAME FROM %Table(:1) WHERE EMPLID = :2”, Record.NAMES, &emplid, &name);

&sql = CreateSql(“SELECT * FROM %Table(:1) WHERE EMPLID = :2”, &MyRecord, &emplid);

INSERT INTO %Table(MYTEMP_TAO)
SELECT * FROM PS_MYDATATABLE