以下程式碼範例是用來在PO (採購單)裡加入附件迴紋針說明的用法,分享給各位讀者:
Create PROCEDURE PO_SHORTTEXT(I_ORGANIZATION_ID IN NUMBER,
I_PO_HEADER_ID IN NUMBER,
I_TITLE IN VARCHAR2, --PGM_NAME
I_DESCRIPTION IN VARCHAR2, --TITLE DESCRIPTION
I_TEXT IN VARCHAR2,
O_DOCUMENT_ID OUT NUMBER,
O_ATTACHED_DOC_ID OUT NUMBER,
O_MEDIA_ID OUT NUMBER)
IS
T_ROWID ROWID;
T_SEQ_NUM NUMBER;
T_FND_USER_ID NUMBER := 0; --DEFAULT SYSADMIN
T_SHORT_DATATYPE_ID NUMBER := 1; --SHORT_TEXT
T_CATEGORY_ID NUMBER := 1000504; --Documents
BEGIN
FND_PROFILE.GET('USER_ID',T_FND_USER_ID);
--
SELECT A.CATEGORY_ID
INTO T_CATEGORY_ID
FROM FND_DOCUMENT_CATEGORIES_TL A
WHERE A.USER_NAME = 'Documents';
--
IF T_FND_USER_ID IS NULL THEN
T_FND_USER_ID := 0;
END IF;
--
SELECT NVL(MAX(FAD.SEQ_NUM),0)+1
INTO T_SEQ_NUM
FROM FND_ATTACHED_DOCUMENTS FAD
WHERE 1=1
AND FAD.PK1_VALUE = TO_CHAR(I_PO_HEADER_ID);
--
FND_DOCUMENTS_PKG.INSERT_ROW(
X_Rowid => T_ROWID,
X_document_id => O_DOCUMENT_ID,
X_creation_date => SYSDATE,
X_created_by => T_FND_USER_ID,
X_last_update_date => SYSDATE,
X_last_updated_by => T_FND_USER_ID,
X_datatype_id => T_SHORT_DATATYPE_ID,
X_create_doc => 'Y',
X_category_id => T_CATEGORY_ID,
X_security_type => 1,
X_security_id => I_ORGANIZATION_ID,
X_description => I_DESCRIPTION,
X_media_id => O_MEDIA_ID,
X_title => I_TITLE,
X_language => 'US',
X_publish_flag => 'N', --This flag allow the file to share across multiple organization
X_usage_type => 'S');
--
IF O_MEDIA_ID IS NOT NULL THEN
INSERT INTO FND_DOCUMENTS_SHORT_TEXT(MEDIA_ID,SHORT_TEXT)
VALUES(O_MEDIA_ID,I_TEXT);
--
SELECT FND_ATTACHED_DOCUMENTS_S.NEXTVAL
INTO O_ATTACHED_DOC_ID
FROM DUAL;
--
INSERT INTO FND_ATTACHED_DOCUMENTS(
ATTACHED_DOCUMENT_ID,
DOCUMENT_ID,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
SEQ_NUM,
ENTITY_NAME,
PK1_VALUE,
AUTOMATICALLY_ADDED_FLAG,
CATEGORY_ID)
VALUES(
O_ATTACHED_DOC_ID,
O_DOCUMENT_ID,
SYSDATE,
T_FND_USER_ID,
SYSDATE,
T_FND_USER_ID,
T_SEQ_NUM,
'PO_HEADERS',
TO_CHAR(I_PO_HEADER_ID),
'N',
T_CATEGORY_ID);
END IF;
END;
沒有留言:
張貼留言