What and where to find Attachment in Oracle Application and it’s tables & API
What is attachment in oracle application?
The attachments feature in oracle application enables users to link unstructured data, such as images, word-processing documents, spreadsheets, or text to their application data. For example, users can link images to items or video to operations as operation instructions.
Where to find an attachment?
There is an attachment icon in the oracle application toolbar that indicates whether the Attachments feature is enabled in a form block. When the button is dimmed, the Attachment feature is not available. When the Attachment feature is enabled in a form block, the icon becomes a solid paper clip like this image below :
The icon switches to a paper clip holding a paper when the Attachment feature is enabled in a form lock and the current record has at least one attachment like this image below :
Attachment types:
An attached document can be:
1- Short Text
Text stored in the database containing less than 2000 characters.
2- Long Text
Text stored in the database containing 2000 characters or more.
3- Image
An image that Oracle Forms can display, including: bmp, cals, jfif, jpeg, gif, pcd, pcx, pict, ras, and tif.
4- OLE Object
An OLE Object that requires other OLE server applications to view, such as Microsoft Word or Microsoft Excel.
5- Web Page
A URL reference to a web page which you can view with your web browser.
Tables Involved:
For Importing Attachments in oracle application one has to populate following tables.
1. FND_DOCUMENTS
2. FND_ATTACHED_DOCUMENTS
3. FND_DOCUMENTS_TL
4. FND_DOCUMENT_DATATYPES.
5. FND_DOCUMENT_CATEGORIES
6. FND_DOCUMENTS_LONG_TEXT (Long text type attachment).
7. FND_DOCUMENTS_SHORT_TEXT (Short text type attachment).
8. FND_DOCUMENTS_LONG_RAW
9. FND_LOBS (File type attachments).
FND_DOCUMENTS:
FND_DOCUMENTS stores language-independent information about a document. For example, each row contains a document identifier, a category identifier, the method of security used for the document (SECURITY_TYPE, where 1=Organization,2=Set of Books, 3=Business unit,4=None), the period in which the document is active, and a flag to indicate whether or not the document can be shared outside of the security type (PUBLISH_FLAG).
Other specifications in this table include: datatype (DATATYPE_ID, where 1=short text,2=long text, 3=image, 4=OLE object), image type, and storage type (STORAGE_TYPE, where 1=stored in the database, 2=stored in the file system).
The document can be referenced by many application entities and changed only in the define document form (USAGE_TYPE=S); it can be used as a fill-in-the-blanks document, where each time you use a template, you make a copy of it (USAGE_TYPE=T); or it can be used only one time (USAGE_TYPE=O).Images and OLE Objects cannot be used as templates.
FND_ATTACHED_DOCUMENTS:
FND_ATTACHED_DOCUMENTS stores information relating a document to an application entity. For example, a record may link a document to a sales order or an item. Each row contains foreign keys to FND_DOCUMENTS and FND_DOCUMENT_ENTITIES. There is also a flag to indicate whether or not an attachment was created automatically.
FND_DOCUMENTS_TL:
FND_DOCUMENTS_TL stores translated information about the documents in FND_DOCUMENTS. Each row includes the document identifier, the language the row is translated to, the description of the document, the file in which the image is stored, and an identifier (MEDIA_ID) of the sub-table in which the document is saved (FND_DOCUMENTS_SHORT_TEXT, FND_DOCUMENTS_LONG_TEXT, or FND_DOCUMENTS_LONG_RAW).
FND_DOCUMENT_DATATYPES:
FND_DOCUMENT_DATATYPES stores the document datatypes that are supported. Initial values are: short text, long text, image, and OLE Object (DATATYPE_ID=1, 2, 3, or 4). Customers can add datatypes to handle documents stored outside of Oracle and use non-native Forms applications to view/edit their documents. The table uses a “duplicate record” model for handling multi-lingual needs. That is, for each category there will be one record with the same CATEGORY_ID and CATEGORY_NAME for each language.
FND_DOCUMENT_CATEGORIES:
FND_DOCUMENT_CATEGORIES stores information about the categories in which documents are classified. For example, documents may be considered “Bill of Material Comments”, “WIP Job Comments”, etc. Document categories are used to provide a measure of security on documents. Each form that enables the attachment feature lists which categories of documents can be viewed in the form. This table uses a “duplicate record” model for handling multi-lingual needs.
FND_DOCUMENTS_LONG_TEXT:
FND_DOCUMENTS_LONG_TEXT stores information about long text documents.
FND_DOCUMENTS_SHORT_TEXT:
FND_DOCUMENTS_SHORT_TEXT stores information about short text documents.
FND_DOCUMENTS_LONG_RAW:
FND_DOCUMENTS_LONG_RAW stores images and OLE Objects, such as Word Documents and Excel spreadsheets, in the database.
FND_DOCUMENT_ENTITIES:
FND_DOCUMENT_ENTITIES lists each entity to which attachments can be linked. For example, attachments can be linked to Items, Sales Orders, etc. Since the table uses a “duplicate record” model for handling multi-lingual needs, for each document entity there will be one record with the same DOCUMENT_ENTITY_ID and DATA_OBJECT_CODE for each language.
FND_LOBS:
FND_LOBS stores information about all LOBs managed by the Generic File Manager(GFM).Each row includes the file identifier, name, content-type, and actual data.
FILE_ID: Identifier that uniquely identifies the file this refer to media_id field in attachment form (from : examine)
FILE_NAME: User’s name for the file as provided during the uploading process
FILE_CONTENT_TYPE:
FILE_DATA: The uploaded data itself, which is a binary LOB.
Queries:
1- To find all Long Text attachments:
select fad.seq_num "Seq Number" ,fdat.user_name "Data Type" ,fdct.user_name "Category User Name" ,fad.attached_document_id "Attached Document Id" ,fdet.user_entity_name "User Entity" ,fd.document_id "Document Id" ,fad.entity_name "Entity Name" ,fd.media_id "Media Id" ,fd.url "Url" ,fdt.title "Title" ,fdlt.long_text "Attachment Text" from fnd_document_datatypes fdat ,fnd_document_entities_tl fdet ,fnd_documents_tl fdt ,fnd_documents fd ,fnd_document_categories_tl fdct ,fnd_attached_documents fad ,fnd_documents_long_text fdlt where fd.document_id = fad.document_id and fdt.document_id = fd.document_id and fdct.category_id = fd.category_id and fd.datatype_id = fdat.datatype_id and fad.entity_name = fdet.data_object_code and fdlt.media_id = fd.media_id and fdat.name = 'LONG_TEXT';
2- To find all Short Text attachments:
select fad.seq_num "Seq Number" ,fdat.user_name "Data Type" ,fdct.user_name "Category User Name" ,fad.attached_document_id "Attached Document Id" ,fdet.user_entity_name "User Entity" ,fd.document_id "Document Id" ,fad.entity_name "Entity Name" ,fd.media_id "Media Id" ,fd.url "Url" ,fdt.title "Title" ,fdst.short_text "Attachment Text" from fnd_document_datatypes fdat ,fnd_document_entities_tl fdet ,fnd_documents_tl fdt ,fnd_documents fd ,fnd_document_categories_tl fdct ,fnd_attached_documents fad ,fnd_documents_short_text fdst where fd.document_id = fad.document_id and fdt.document_id = fd.document_id and fdct.category_id = fd.category_id and fd.datatype_id = fdat.datatype_id and fad.entity_name = fdet.data_object_code and fdst.media_id = fd.media_id and fdat.name = 'SHORT_TEXT';
Attachments can also be uploaded through an oracle provided API called FND_ATTACHED_DOCUMENTS_PKG.It consist of three procedures
1) Insert Row
2) Update Row
3) Lock Row
Names of these procedures are self explanatory. insert row is used to insert a new row for attachment data, update row is used to update existing row for a particular row and Lock Row is used to lock a existing row for further modification.
OE_ATCHMT_UTIL
This is an API which can be used to add, copy and delete attachments it has procedures
Add_Attachment: Can be used to attach a new attachment to an order
It’s parameters are:
P_API_VERSION IN (Mandatory)
P_ENTITY_CODE IN (Mandatory)
P_ENTITY_ID IN (Mandatory)
P_DOCUMENT_DESC IN default null,
P_DOCUMENT_TEXT IN default null,
P_CATEGORY_ID IN default null,
P_DOCUMENT_ID IN default null,
X_ATTACHMENT_ID OUT
X_RETURN_STATUS OUT
X_MSG_COUNT OUT
X_MSG_DATA OUT
Copy_Attachments : Can be used to attach an existing attachment to an
Order.
It’s parameters are:
P_ENTITY_CODE IN (Mandatory)
P_FROM_ENTITY_ID IN (Mandatory)
P_TO_ENTITY_ID IN (Mandatory)
P_MANUAL_ATTACHMENTS_ONLY IN default ‘N’
X_RETURN_STATUS OUT
Delete_Attachments: Can be used to delete an attachment of an order
It’s parameters are:
P_ENTITY_CODE IN (Mandatory)
P_ENTITY_ID IN (Mandatory)
X_RETURN_STATUS OUT
Apply_Automatic_Attachments :
It’s parameters are:
P_INIT_MSG_LIST IN default fnd_api.g_false
P_ENTITY_CODE IN (Mandatory)
P_ENTITY_ID IN (Mandatory)
P_IS_USER_ACTION IN default ‘Y’
X_ATTACHMENT_COUNT OUT
X_RETURN_STATUS OUT
X_MSG_COUNT OUT
X_MSG_DATA OUT
hope this helpful 🙂