Sunday, October 23, 2011

Control Hints in OAF


Main purpose of Control hints is to centralize certain UI settings across clients. For Example, Label Text control hint is used to give same Field Name/Column Name on all pages where an attribute of a View Object is being displayed. It greatly reduces the amount of UI coding in ADF and thus is frequently used there.
But in OAF it greatly increases the amount of coding needed on UI.


Following screenshot gives an example of where we set control hints:



Following is an example how we get the value of control hints:

OAViewObject vo = (OAViewObject)pageContext.getRootApplicationModule().findViewObject("VOInstanceName");
AttributeDef[] attrDef = vo.getAttributeDefs();
attrdef[i].getName();
// This will give the name of the Attribute; Below image shows the Attribute Name along with other properties.
attrDef[i].getUIHelper().getLabel(pageContext.getRootApplicationModule().getSession().getLocaleContext());
// This will give the value of Lable set in the control hints screen.




When you add control hints, a message bundle file gets created.

Saturday, October 22, 2011

DBC File


  • DBC stands for database connect descriptor file.
  • The .dbc file is used to define database parameters used to connect to database, it authenticate users against database in FND_USER table. 
  • It provides runtime database connection, authentication and authorization in Jdeveloper.
  • Default Location for the file is $FND_TOP/secure directory.
  • Profile option "Applications Database ID" contains name of the DBC file.
  • Oracle Apps Login also uses DBC file.
Alternate way to find correct DBC file used in Apps:
  1. Go on About this Page.
  2. Navigate to "Java System Properties" tab.
  3. Check the value of System Property "DBCFILE".
Following image shows Jdev properties where we need to specify the correct DBC file in order to run a page from it:


Important entries in DBC file are:

GUEST_USER_PWD - Guest Userand Its Password
APPL_SERVER_ID - Server ID in FND_NODES table against respective Server
APPS_JDBC_URL - Database connection details
DB_HOST - DB hostname
GWYUID - Gateway User ID and password - database user APPLSYSPUB and password
FNDNAM - Central oracle application schema name, usually its APPS. echo $FNDNAM for the value.
TWO_TASK - It is set to the location where ORACLE server can be found and will normally be the name of the database instance.
By Setting TWO_TASK instead of:
$ sqlplus scott/tiger@some_db

Following will also work:
$ setenv TWO_TASK some_db
$ sqlplus scott/tiger


How DBC files is used  in Login?
  • Self-service login uses Guest password from DBC file to verify the user password.
  • User Login will not work if this password is incorrect.
  • Guest user is used to obtain apps information.
  • Applsyspub schema is responsible for password checking, default password is pub.
  • Oracle applications first connects to this public schema, APPLSYSPUB, public oracle username and password for authentication.
  • This schema has sufficient privileges to perform the authentication of an Applications User (FND user).
  • Once authenticated you get connected to APPS.
DBC file generation, Securing the Apps are DBA responsibility area.
More on Apps Login process security will soon be covered in coming blog.

Note:
DBC is so closely related to Security that going into more details on DBC file requires understanding of Encryption/Decryption of passwords, APPS, APPLSYS, APPLSYSPUB, FND_USER password storage, APPS password storage etc.

Wednesday, October 12, 2011

Multiple Browser Sessions with Oracle Apps Server

A while back we faced an issue with the multiple browser sessions with Oracle Apps Server with same IP Address from Internet Explorer. The sessions were getting merged. It was not allowing us to login to apps with two different users from one computer using IE.

Few days back again I saw the same issue being discussed, so sharing following link on the issue details and resolution:

http://oracleajidba.blogspot.com/2010/04/oracle-apps-multiple-sessions-problem.html

Wednesday, October 5, 2011

Attachments in OAF Pages: A Simple Case study




In Oracle Apps, we enable the attachments at logical entity level. This entity is different that entity in ER diagram or Entity Objects. An entity is an object within Oracle E-Business Suite data, such as an item, an order, or an order line. In the context of attachments, an entity can be considered either a base entity or a related entity.

A base entity is the main entity of the region. A related entity is an entity that is usually related to the region by a foreign-key relationship.
  • Attachments are linked with the VO’s primary key (could be combination of columns).
When an attachment is stored, the values of these primary keys and the Entity ID are stored so the attachments can be uniquely retrieved. (We’ll discuss in details about the storage of this information a little later).

Attachment Styles in a Region

There are four attachment styles that you can render in a region:
  • Display a View List Link and Add Button in a Single Row Region
      
  • Display an Attachments Table on the Page of a Single Row Region













  • Display In-line Links of Attachments in a Single Row Region
      
  • Display an Attachments Column in a Multi-Row Table Region
           


Add Attachment Page:

On Clicking Add Attachment, users are navigated to this page.

It is clearly displaying the three types of attachments supported:
  • URL
  • File
  • Text
Attention: All Text attachments are added as "Short Text" type, with a maximum length of 4000 bytes. If you need to add an attachment that is longer than 4000 bytes, put the text into a text file and add the attachment as a File.


Steps to add Attachments:
  1. Add the UI widget for attachments. Following are the widgets:
    • attachmentTable - for Attachments table
    • attachmentLink - for View List link and Add button
    • MessageInlineAttachment - for inline attachment links
    • attachmentImage - For Attachment column in Table and Advance Table
  1. Specify View Instance property
  1. Select the default entityMap that is created under the attachment region item, set the Entity value to some unique value which will be used to identify all attachments.
  1. Right Click on Entity Map and Add primary keys and specify the primary keys used to identify the attachment uniquely.

Some key SQL Queries:

Query 1: List of All Attachments
--------------------------------------------
select * from fnd_attached_documents where creation_date > sysdate - 1/24 ;/
// List of all Attachments attached in last 1 hr.

Query 2: List of All Attachments
--------------------------------------------
select * from fnd_attached_documents where entity_name = 'XXSL_GROUP' ;/
// List of all Attachments with entity_name = 'XXSL_GROUP'

Query 3: List of All Attachments
--------------------------------------------
select attached_document_id, -- Primary Key
document_id, -- foreign key for FND_DOCUMENTS
entity_name, -- Name of unique entity entered in OAF page's Attachment component
PK1_value, -- primary key attribute specified in OAF page's Attachment component.
-- There are 5 Primary Key columns here to store composite primary keys.
seq_num, -- sequence number of the attachment added.
category_id -- Category of the attachment, foreign key to FND_DOCUMENT_CATEGORIES
-- In case you are not able to see an attachment in the UI,
-- check the "Show All" property of the Entity Map
from fnd_attached_documents
WHERE ENTITY_NAME = '<your entity name>' and pk1_value = '<primary key of your VO>'; /

Query 4: Details of the document attached
---------------------------------------------------------

SELECT * FROM FND_DOCUMENTS where document_id in (7922696, 7922698, 7922700, 7922702); /
SELECT document_id, -- Primary Key
datatype_id, -- foreign key to FND_DOCUMENT_DATATYPES, tells about the type of attachment
category_id, -- Category of the attachment, foreign key to FND_DOCUMENT_CATEGORIES
url, -- URL field is populated in case of URL Type attachment
File_name, -- File name field is populated in case of a file type attachment
media_id -- Foreign key to fnd_lobs for datatype_id = 6
--
FROM FND_DOCUMENTS -- Attachment Title is stored in FND_DOCUMENTS_TL
where document_id in (select document_id from fnd_attached_documents where ENTITY_NAME = '<your entity name>' and pk1_value = '<primary key of your VO>');
/

Query 5: Types of Attachments
-------------------------------------------
select * from FND_DOCUMENT_DATATYPES;/
Short Text
Long Text
Image
OLE Object
Web Page
File
Document Reference
Oracle Files Folder/Workspace
Oracle File

select * from xxsl_lms_group_headers where group_id = 1722 ;/

Query 6: Types of File Attached
---------------------------------------------
--Record will be in FND_LOB only for datatype_id = 6
select * from fnd_lobs
where file_id in
(select media_id
from FND_DOCUMENTS
where document_id in
(select document_id from fnd_attached_documents where ENTITY_NAME = '<your entity name>' and pk1_value = '<primary key of your VO>' and datatype_id = 6)
); /
Query 7: for "Short Text" type:
------------------------------------------
-- Record will exist in FND_DOCUMENTS_SHORT_TEXT if datatype_id is 1
select * from FND_DOCUMENTS_SHORT_TEXT
where media_id in
(select media_id
from FND_DOCUMENTS
where document_id in
(select document_id from fnd_attached_documents where ENTITY_NAME = '<your entity name>' and pk1_value = '<primary key of your VO>' and datatype_id = 1)
); /



API Support:
For Api support refer to following packages - 
1. FND_DOCUMENTS_PKG,
2. FND_ATTACHED_DOCUMENTS_PKG
3. fnd_attached_documents2_pkg.delete_attachments (to delete attachments)


Followings are not covered in this post:
  • Security
  • Virus Scanning
  • Multiple entity support
  • Attachments to be visible on Forms as well as OAF. (FND_ATTACHMENT_FUNCTIONS)
  • Document Catelog