You are on page 1of 9

A Simple Application Engine Program By Derek Tomei

A Simple Application Engine Program


Looping Through Employees and Sending Emails

By Derek Tomei DMT Solutions, Inc. www.PsoftPros.net

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

Notice: This is a Free Report and Can Be Freely Distributed and Given Away. However, You DO NOT have Permission To Sell This Report In Any Way.

About the Author


Derek Tomei is a PeopleSoft Consultant and President of DMT Solutions, Inc. Derek has been involved with PeopleSoft software since version 5 through the most recent versions of HRMS 8.3 and Financials 8.4. He has seen and worked through the progression from PeopleSoft client-server 2-tier, 3-tier, and n-tier. He has worked on small private companies to large fortune 500 corporations implementing, upgrading, installing, enhancing, and maintaining PeopleSoft Financial and HRMS software. Derek is considered one of the PeopleSoft industry's top technical consultants with the ability to perform in all areas of technical expertise including but not limited to development, architecture, database administration, system administration, web development, employee and manager self-service, and project management.

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

Since the inception of PeopleTools version 8, many new features and tools related enhancements have been introduced. One of the best enhancements we have found is inside the Application Engine. PeopleSoft has made the application engine very powerful toolset with a wide range of capabilities. Prior to version eight Many powerful application were written using COBOL and SQR. However, PeopleSoft is beginning to convert most of the COBOL and SQR programs into application engine programs. Prior to version eight Peoplesofts application engine was not built into the application designer toolset. It was very cumbersome and difficult to use. Since adding the application engine into the application designer, there are many more options and capabilities. For example, you can now use PeopleCode objects and SQL objects within your application engine program. Designing Application Engine programs has become easier than ever, and is a definite candidate to replace SQR programs. Our favorite feature is the ability to include PeopleCode within your App engine programs. With that said, I
www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

want to show you a quick and easy way to send emails from within an Application Engine program.

If you want to efficiently write useful application engine code, then you will find this code example, extremely useful. Did you know you could easily send email messages from within your app engine programs? Well you can with just a few lines of code. You may find it useful to send an email message to your PS administrator when a certain process is completed. Or perhaps you want to send an email to all employees indicating that their paychecks are available to be viewed via the Employee Self Service ePay application. Either way, you can easily create a simple application engine program that will send your email message with these few lines of code that I am about to show you. And, once you complete your application, you can easily add the AE program to a PS job stream so that it will execute after your Pay Confirm process.

You will first need to create a New Application Engine program. Here is how to do this..
www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

From the Application Designer choose 1) File New and select Application Engine.

2) You will see new definition created for you containing the MAIN section with a step entitled STEP01.

3) Simply right click your mouse on the step (STEP01) and choose Insert Action.

4) A new action will be inserted and will default to SQL.

5) Change this action to PeopleCode.

6) Save your program

7) Then double click on the PeopleCode action.

Now you are ready to insert the code below. I will fully explain this code.

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

REM **********************************************; REM ** Instantiate the record and SQL objects to obtain data *; REM **********************************************;

&MY_DATA_REC = CreateRecord(Record.EMPLOYEES); &MY_DATA_SQL = CreateSQL("%selectall(:1) WHERE PAYGROUP = :2"); &MY_DATA_SQL.Execute(&MY_DATA_REC, "OUR_PAYGROUP");

REM **********************************************; REM ** Loop through all of the data one row at a time for *; REM ** all rows *; REM **********************************************;

While &MY_DATA_SQL.Fetch(&MY_DATA_REC);

REM **********************************************; REM ** Set all necessary email parameters REM **********************************************;

&MAIL_FLAGS = 0; &MAIL_TO = &MY_DATA_REC.EMAILID.Value; &MAIL_CC = ""; &MAIL_BCC = ""; &MAIL_SUBJECT = "Pay check is Available Online for Viewing"; &NAME = &MY_DATA_REC.NAME.Value; &MAIL_TEXT_BODY = "Dear " | &NAME | ", Your paycheck is now available for viewing online."; &MAIL_FILES = ""; &MAIL_TITLES = "";

REM **********************************************; REM ** Send the email message for the current employee; REM **********************************************;

&RET_CODE = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT_BODY, &MAIL_FILES, &MAIL_TITLES);

REM ********************************************************;

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei


REM ** Check the status code to ensure the mail was sent successfully; REM ********************************************************;

If Not (&RET_CODE = 0) Then WinMessage("Return status from mail = " | &RET_CODE); End-If;

End-While;

REM ** Dont forget to close the SQL stream **; &MY_DATA_SQL.Close();

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

As you can see from the above code, it is extremely simple to loop through data with your set criteria and send email messages from within your application Engine program. Basically, I have used PeopleCode to create a record MY_DATA_REC from the EMPLOYEES table. After this, I created a SQL statement that basically selects from the record PS_EMPLOYEES where the PAYGROUP is some value. Next, I use a while loop to fetch each row from the record, one by one. As I grab the employees data I build my email message and use the SendMail PeopleCode function. Notice the Parameters that get passed to the SendMail command. You can send file attachments by simply giving a file path/name to the &MAIL_FILES variable. This is a very basic example of how to send emails. Once, you determine what you need to do, you can always, add more functionality and get more creative with your code.

If you want to find out more about the Application Engine in PeopleSoft version 8 and beyond, including the Syntax, structure, and features, I highly recommend that you purchase the following books.

www.dmtsolutions.com

A Simple Application Engine Program By Derek Tomei

A Guide To Programming Object Scroll Peoplecode Application Engine - Component Interface Developing With PeopleSoft Application Engine 8 Advanced Tips and Tricks for PeopleSoft Application Engine

To Your Success,

Derek Tomei www.PsoftPros.net

www.dmtsolutions.com

You might also like