Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Oracle E-Business Suite R12 Core Development and Extension Cookbook

You're reading from   Oracle E-Business Suite R12 Core Development and Extension Cookbook Building extensions in Oracle E-Business Suite is greatly simplified when you follow the step-by-step instructions in this book. Whether novice or pro, this is a great tutorial with over 60 recipes and stacks of screenshots.

Arrow left icon
Product type Paperback
Published in May 2012
Publisher Packt
ISBN-13 9781849684842
Length 480 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Andy Penver Andy Penver
Author Profile Icon Andy Penver
Andy Penver
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Oracle E-Business Suite R12 Core Development and Extension Cookbook
Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Creating Concurrent Programs FREE CHAPTER 2. Oracle Forms 3. Advanced Oracle Forms 4. Forms Personalization 5. Workflow 6. Utilities

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.

You have been reading a chapter from
Oracle E-Business Suite R12 Core Development and Extension Cookbook
Published in: May 2012
Publisher: Packt
ISBN-13: 9781849684842
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime