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

7 Responses to “Step-by-Step: App Engine for Testing PeopleCode”

  1. Arrays Question « PSST0101 Says:

    […] also decided to use my step-by-step that I just completed.  So, this answer will build on that […]

  2. Explorations in Component Interface: PeopleCode « PSST0101 Says:

    […] 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. […]

  3. Explorations in Component Interface: Handling Component Interface Errors « PSST0101 Says:

    […] see the App Engine test post for instructions on how to run the program.  Then, look in the log file generated by the […]

  4. » Explorations in Component Interface: Handling Component Interface Errors PSST0101 Says:

    […] see the App Engine test post for instructions on how to run the program.  Then, look in the log file generated by the […]

  5. » Arrays Question PSST0101 Says:

    […] also decided to use my step-by-step that I just completed.  So, this answer will build on that […]

  6. nida Says:

    good post


Leave a comment