FUNCTION xx_attachment_url(p_po_header_id IN NUMBER
,p_vendor_id IN NUMBER
)
RETURN CHAR
IS
ln_gfm_id NUMBER;
lc_gfm_agent VARCHAR2 (250);
lc_url VARCHAR2 (2000);
ln_media_id NUMBER;
begin
SELECT DISTINCT dt.media_id
INTO ln_media_id
FROM fnd_attached_documents ad
,fnd_documents_tl dt
WHERE(
(entity_name = 'PO_HEADER'
AND pk1_value = :p_po_header_id
AND pk2_value = '1'
)
OR (entity_name = 'PO_HEADERS'
AND pk1_value = :p_po_header_id
)
OR (entity_name = 'PO_VENDORS'
AND pk1_value = :p_vendor_id))
AND ad.document_id=dt.document_id
AND dt.language = USERENV('LANG')
AND ROWNUM<2
;
lc_gfm_agent := fnd_web_config.gfm_agent;
ln_gfm_id := ln_media_id;
lc_url := fnd_gfm.construct_download_url (lc_gfm_agent, ln_gfm_id, FALSE);
RETURN lc_url;
EXCEPTION
WHEN OTHERS THEN
RETURN(NULL);
END;
To hanks for sharing. Keep posting.
ReplyDelete