Book Image

Oracle E-Business Suite R12 Core Development and Extension Cookbook

By : Andy Penver
Book Image

Oracle E-Business Suite R12 Core Development and Extension Cookbook

By: Andy Penver

Overview of this book

Oracle's suite of applications is used by many major businesses and public sector organizations throughout the world. The book will show you how to build different types of extensions with different toolsets with Oracle E-Business Suite R12. It will take you from start to finish with fully working examples. This book will show you how to extend Oracle E-Business Suite Release 12. You will learn highly desirable skills on how to extend the application and develop your expertise. The book will provide detailed information about why things have to be done in certain ways, and will take you through the process of how to get started, what tools are needed, how to develop working examples, and how to deploy them within the application. Learn how to extend Oracle E-Business Suite (EBS) Release 12. There are detailed examples to work through, such as how various components are configured and how we can extend standard functionality. The book focuses on core development and extension and each chapter will introduce a topic before going through working examples from start to finish. There are plenty of detailed screen shots throughout each chapter giving clear instructions of what we are doing and why. Each recipe will develop a solution that will utilize core components to that topic. The Oracle E-Business Suite R12 Core Development and Extension Cookbook focuses on starting an extension right from the beginning, to deploying it within E-Business Suite. At the end of each chapter the reader will have a good understanding of what they need to do for each area to take away, and start using it in practice. Each chapter will detail how to build an extension in the supported manner and also comes with complete fully tested code, and scripts that can be downloaded.
Table of Contents (12 chapters)
Oracle E-Business Suite R12 Core Development and Extension Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Adding messages to the concurrent program log file


In this recipe, we are going to write to the log file to show the values of parameters that are passed into the executable. This is useful as we need a way of debugging and logging activity when a program is being executed. We can also write other messages to the log file of the concurrent program to report activity when the executable runs.

The tasks we are going to perform in this recipe are as follows:

  • Create a profile option to turn logging on or off

  • Set the profile option value

  • Add a procedure to write to the log file

  • Writing to the log file

  • Running the concurrent program

  • Viewing the log file

Create a profile option to turn logging on or off

Firstly we are going to create a profile option. This profile option is a simple profile that can be set to 'Y' or 'N'. If it is set to 'Y' then we can use it to write to the log file and if it is set to 'N' then we can choose not to write to the log file.

How to do it...

To create a new profile, perform the following:

  1. 1. Log in to Oracle with the Application Developer responsibility.

  2. 2. Navigate to Profile and the Profiles window will open, as shown in the following screenshot:

  3. 3. Enter data as shown in the following table:

    Item name

    Item value

    Name

    XXHR_WRITE_LOGFILE

    Application

    XXHR Custom Application

    User Profile Name

    XXHR Write to Concurrent Program Logfile

    Description

    XXHR Write to Concurrent Program Logfile

    SQL Validation

    SQL="SELECT MEANING \"Yes or No\", LOOKUP_CODE

    INTO :visible_option_value,

    :profile_option_value

    FROM fnd_common_lookups

    WHERE lookup_type = 'YES_NO'"

    COLUMN="\"Yes or No\"(*)"

  4. 4. Click the Save button in the toolbar (or Ctrl + S) to save the record.

How it works...

We have created a profile which will allow users to turn logging information on or off. Profile options can be a really useful way of setting values in our code without having to hard code.

There's more...

There are often a number of ways to implement extensions or ways of doing things. As an example we could have created an additional parameter that uses a Yes/No value set that allows the user to write to the log file at runtime by setting a parameter value. It really depends upon how you want the program to run.

Set the profile option value

We will now set the profile to 'Yes' so that we can add code to our program that writes information to a log file.

How to do it...

To set the profile option value, perform the following:

  1. 1. Log in to Oracle with the System Administrator responsibility.

  2. 2. Navigate to Profile | System and the Find System Profile Values window will open as shown in the following screenshot:

  3. 3. In the Profile field type XXHR Write to Concurrent Program Logfile and click the Find button.

    Note

    You could have also just typed XXHR% and clicked the Find button. Then you would retrieve all of the profile options beginning with XXHR. You can use the wildcard (%) to search for specific text such as %HR%Write%Log%, which will also be just as acceptable and will help if you cannot remember the full name of the profile you are looking for. Just remember it is also case sensitive.

  4. 4. Set the Profile Option Name at Site level to Yes, as shown in the following screenshot:

  5. 5. Click the Save button in the toolbar (or Ctrl + S) to save the record.

How it works...

We have now created a profile option that we can use to turn logging on or off after we have added code to our program to use the profile option value.

Add a procedure to write to the log file

We are now going to add the code to the executable, which is our package called XXHREEBS. If you wish to view the code then it can be found in the files XXHREEBS_1_5.pks and XXHREEBS_1_5.pkb. You can compile the package provided or use the following instructions to add the code manually.

How to do it...

To add a new procedure, perform the following steps:

  1. 1. Open SQL Developer and connect to the apps user.

  2. 2. Navigate to Packages and select the XXHREEBS package.

  3. 3. Now edit the package specification.

  4. 4. Declare a constant variable called cv_write_to_log and assign to it the value of the profile option XXHR_WRITE_LOGFILE, shown as follows:

    Note

    Note that it is the Profile Option Name that we use and not the User Profile Option Name which is what we see when we set the profile option value.

  5. 5. Compile the package specification.

  6. 6. Edit the package body.

  7. 7. Add a procedure called write_log, shown as follows:

  8. 8. Compile the package body.

How it works...

We have added a procedure to our program that will allow us to write messages to the concurrent program log file. This can be switched on or off by changing a profile option value.

Writing to the log file

Now we can add some messages to the First_Concurrent_Program procedure to write to the log file. We have already set the profile option to 'Yes' so every time we call the write_log procedure, the executable will write a message to the log file. So now we will add some messages to the log file. A good place to start would be to display the values that are being passed in as parameters.

How to do it...

To add messages to the log file perform the following steps:

  1. 1. Open SQL Developer and connect to the apps user.

  2. 2. Navigate to Packages and select the XXHREEBS package.

  3. 3. Now edit the package body.

  4. 4. Write to the log file with calls to write_log in our First_Concurrent Program procedure as follows:

  5. 5. Compile the package body.

How it works...

We have added code to write messages to the log file. We have also written the values of the parameters that are passed in to the program to the log file, so that a developer will find it easy to debug the program if there are errors.

Run the concurrent program

Now we want to run the concurrent program testing that the code we have just added writes messages to the log file.

How to do it...

To run the concurrent program, do the following:

  1. 1. Log in to Oracle with the XXEBS Extending e-Business Suite responsibility.

  2. 2. Navigate to Submit Requests and submit a single request.

  3. 3. Select the XXHR First Concurrent Program concurrent program and leave the Run Date parameter to the default date (which is the current date).

  4. 4. Select Vision Corporation from the list of values for the Organization parameter and then click OK.

  5. 5. Select an employee record from the list of values for the Person parameter and then click OK.

  6. 6. Click on the Submit button and when prompted to submit a new request select No and the form will close down.

  7. 7. Navigate to View Requests and click on the Find button (to find all requests).

  8. 8. You should see that the concurrent program we just submitted has completed successfully. (If it is still Pending then click the refresh button until the status is Completed.)

How it works...

We have run the concurrent program again to test that the log messages are written to the log file.

Viewing the log file

Once the concurrent program has completed successfully we can view the log file. Let's now have a look at the log file and see the messages that have been written to it.

How to do it...

To view the messages written to the log file perform the following:

  1. 1. Click on the View Log button in the View Requests screen and a browser window will open.

  2. 2. You will see that the messages we put into the First_Concurrent_Program package have been written to the log file as highlighted in the following image:

How it works...

The messages have been written to the log file, providing valuable information about events that have occurred at runtime.