ATTACHMENTS AT FORM Level:
SELECT fds.short_text
FROM fnd_attached_documents fad,
fnd_documents_tl fdt,
fnd_documents_short_text fds
WHERE fad.pk1_value = :customer_trx_id or invoice_id
AND fad.entity_name = 'RA_CUSTOMER_TRX'
AND fad.document_id = fdt.document_id
AND fdt.language = 'US'
AND fdt.media_id = fds.media_id;
DECLARE
l_doc_category_id NUMBER;
l_document_id NUMBER;
l_attached_document_id NUMBER;
l_media_id NUMBER;
l_fnd_user_id NUMBER;
l_short_datatype_id NUMBER;
l_pk2_value VARCHAR2 (50) := '9023';
l_seq_num NUMBER;
BEGIN
-- Select User_id
SELECT user_id
INTO l_fnd_user_id
FROM apps.fnd_user
WHERE user_name = 'A14380';
-- Get Data type id for Short Text types of attachments
SELECT datatype_id
INTO l_short_datatype_id
FROM apps.fnd_document_datatypes
WHERE name = 'SHORT_TEXT';
-- Select Category id for "Vendor/To Supplier" Attachments
SELECT category_id
INTO l_doc_category_id
FROM apps.fnd_document_categories
WHERE name = 'Buyer';
-- Select nexvalues of document id, attached document id and
SELECT apps.fnd_documents_s.NEXTVAL,
apps.fnd_attached_documents_s.NEXTVAL,
apps.fnd_documents_short_text_s.NEXTVAL
INTO l_document_id, l_attached_document_id, l_media_id
FROM DUAL;
SELECT NVL (MAX (seq_num), 0) + 10
INTO l_seq_num
FROM fnd_attached_documents
WHERE pk2_value = l_pk2_value AND entity_name = 'MTL_SYSTEM_ITEMS';
INSERT INTO apps.fnd_documents (document_id,
creation_date,
created_by,
last_update_date,
last_updated_by,
datatype_id,
category_id,
security_type,
publish_flag,
usage_type,
media_id)
VALUES (l_document_id,
SYSDATE,
l_fnd_user_id,
SYSDATE,
l_fnd_user_id,
l_short_datatype_id, -- Datatype for 'SHORT_TEXT'
l_doc_category_id, -- Category_id
2, -- 'Organization' Level Security
'Y', -- Publish_flag
'O' , -- Usage_type of 'One Time'
l_media_id);
INSERT INTO apps.fnd_documents_tl (document_id,
creation_date,
created_by,
last_update_date,
last_updated_by,
language,
source_lang,
description,
media_id)
VALUES (l_document_id,
SYSDATE,
l_fnd_user_id,
SYSDATE,
l_fnd_user_id,
'US', -- language
'US', -- language
'DESCRIPTION', -- description
l_media_id -- media_id
);
INSERT INTO apps.fnd_attached_documents (attached_document_id,
document_id,
creation_date,
created_by,
last_update_date,
last_updated_by,
seq_num,
entity_name,
pk1_value,
pk2_value,
automatically_added_flag)
VALUES (l_attached_document_id,
l_document_id,
SYSDATE,
l_fnd_user_id,
SYSDATE,
l_fnd_user_id,
l_seq_num, -- Sequence Number of attachment.
'MTL_SYSTEM_ITEMS', -- Entity_name Table Name assoicated with attachment
576, -- Organization id for Inventory Item Master Org
l_pk2_value, -- Inventory Item Id
'N' -- Automatically_added_flag
);
INSERT INTO apps.fnd_documents_short_text (media_id, short_text)
VALUES (l_media_id, 'Sending details to buyer' );
COMMIT;
END;
/
No comments:
Post a Comment