Script to enable attachments
for a custom Form in PO
You need to create records on fnd_attachment_functions,
fnd_doc_category_usages, fnd_attachment_blocks and
fnd_attachment_blk_entities for the custom form.
This one is for attachments on "PO_HEADERS" block, for
a form named "ANPO002". Work for 10.7 SC.
DECLARE
W_Attachment_function_id NUMBER := 0;
W_doc_category_usage_id NUMBER := 0;
W_attachment_blk_id NUMBER := 0;
W_attachment_blk_entity_id NUMBER := 0;
W_function_id NUMBER := 0;
W_Application_id NUMBER := 0;
W_Function_Name VARCHAR2(30) := NULL;
BEGIN
BEGIN
SELECT Fnd_Attachment_functions_s.NextVal
INTO W_Attachment_function_id
FROM Dual;
EXCEPTION
WHEN No_Data_Found THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_functions_s ');
WHEN Others THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_functions_s ');
END;
BEGIN
SELECT Function_Id, Function_name, Application_id
INTO W_Function_Id, W_Function_Name, W_Application_id
FROM fnd_form_functions
WHERE Function_Name = 'ANPO002';
EXCEPTION
WHEN No_Data_Found THEN
Raise_Application_Error(-20060,'ERROR: Function_Name
not exist in
Fnd_Form_Functions ');
WHEN Others THEN
Raise_Application_Error(-20060,'ERROR: Function_Name
not exist in
Fnd_Form_Functions ');
END;
BEGIN
INSERT into Fnd_Attachment_Functions(
ATTACHMENT_FUNCTION_ID,
FUNCTION_TYPE,
FUNCTION_ID,
FUNCTION_NAME,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
APPLICATION_ID,
SESSION_CONTEXT_FIELD,
ENABLED_FLAG)
VALUES(
W_ATTACHMENT_FUNCTION_ID,
'F',
W_FUNCTION_ID,
W_FUNCTION_NAME,
SYSDATE,
1,
SYSDATE,
1,
1,
W_APPLICATION_ID,
NULL,
'Y');
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
Raise_Application_Error(-20070,'ERROR: Duplicate Index
in
Fnd_Attachment_Functions ');
WHEN Others THEN
Raise_Application_Error(-20075,' Cannot insert in Fnd_Attachment_Functions');
END;
BEGIN
SELECT Fnd_Doc_Category_Usages_s.NextVal
INTO W_Doc_Category_Usage_id
FROM Dual;
EXCEPTION
WHEN No_Data_Found THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Doc_Category_Usages_s ');
WHEN Others THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Doc_Category_Usages_s ');
END;
BEGIN
INSERT into Fnd_Doc_Category_Usages(
DOC_CATEGORY_USAGE_ID,
CATEGORY_ID,
ATTACHMENT_FUNCTION_ID,
ENABLED_FLAG,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN)
VALUES(
W_DOC_CATEGORY_USAGE_ID,
34,
W_ATTACHMENT_FUNCTION_ID,
'Y',
SYSDATE,
1,
SYSDATE,
1,
1);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
Raise_Application_Error(-20070,'ERROR: Duplicate Index
in
Fnd_Doc_Category_Usages ');
WHEN Others THEN
Raise_Application_Error(-20075,' Cannot insert in Fnd_Doc_Category_Usages');
END;
BEGIN
SELECT Fnd_Attachment_blocks_s.NextVal
INTO W_attachment_blk_id
FROM Dual;
EXCEPTION
WHEN No_Data_Found THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_blocks_s ');
WHEN Others THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_blocks_s ');
END;
BEGIN
INSERT into Fnd_Attachment_blocks(
ATTACHMENT_BLK_ID,
ATTACHMENT_FUNCTION_ID,
BLOCK_NAME,
QUERY_FLAG,
SECURITY_TYPE,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
ORG_CONTEXT_FIELD,
SET_OF_BOOKS_CONTEXT_FIELD,
BUSINESS_UNIT_CONTEXT_FIELD,
CONTEXT1_FIELD,
CONTEXT2_FIELD,
CONTEXT3_FIELD)
VALUES(
W_attachment_blk_id,
W_ATTACHMENT_FUNCTION_ID,
'PO_HEADERS',
'N',
1,
SYSDATE,
1,
SYSDATE,
1,
1,
'PO_STARTUP_VALUES.ORG_ID',
NULL,
NULL,
'PO_HEADERS.SEGMENT1',
NULL,
NULL);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
Raise_Application_Error(-20070,'ERROR: Duplicate Index
in
Fnd_Attachment_Blocks ');
WHEN Others THEN
Raise_Application_Error(-20075,' Cannot insert in Fnd_Attachment_Blocks');
END;
BEGIN
SELECT Fnd_Attachment_Blk_Entities_s.NextVal
INTO W_attachment_blk_entity_id
FROM Dual;
EXCEPTION
WHEN No_Data_Found THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_Blk_Entities_s ');
WHEN Others THEN
Raise_Application_Error(-20065,'ERROR: Sequence does
not exist -
Fnd_Attachment_Blk_Entities_s ');
END;
BEGIN
INSERT into Fnd_Attachment_Blk_Entities(
ATTACHMENT_BLK_ENTITY_ID,
ATTACHMENT_BLK_ID,
DISPLAY_METHOD,
INCLUDE_IN_INDICATOR_FLAG,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
PK1_FIELD,
PK2_FIELD,
PK3_FIELD,
PK4_FIELD,
PK5_FIELD,
SQL_STATEMENT,
DATA_OBJECT_CODE,
INDICATOR_IN_VIEW_FLAG,
QUERY_PERMISSION_TYPE,
INSERT_PERMISSION_TYPE,
UPDATE_PERMISSION_TYPE,
DELETE_PERMISSION_TYPE,
CONDITION_FIELD,
CONDITION_OPERATOR,
CONDITION_VALUE1,
CONDITION_VALUE2)
VALUES(
W_attachment_blk_entity_id,
W_attachment_blk_id,
'M',
'Y',
SYSDATE,
1,
SYSDATE,
1,
1,
'PO_HEADERS.PO_HEADER_ID',
NULL,
NULL,
NULL,
NULL,
NULL,
'PO_HEADERS',
'N',
'Y',
'Y',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
Raise_Application_Error(-20070,'ERROR: Duplicate Index
in
Fnd_Attachment_Blk_Entities');
WHEN Others THEN
Raise_Application_Error(-20075,' Cannot insert in
Fnd_Attachment_Blk_Entities');
END;
COMMIT;
END;
/
Have a Oracle Question
Do
you have an Oracle Question?
Oracle Books
Oracle
Certification, Database Administration, SQL, Application, Programming Reference
Books
Oracle Application
Oracle
Application Hints and Tips
Oracle Home
Oracle
Database, SQL, Application, Programming Tips
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.erpgreat.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.erpgreat.com or the content authors.
|