Tuesday, May 4, 2010

To giving URL link for the Attachments

function CF_attach return Char is
l_gfm_id NUMBER;
gfm_agent VARCHAR2 (255);
l_url VARCHAR2 (1000);
MED_ID number;
begin

SELECT DISTINCT DT.MEDIA_ID INTO MED_ID
FROM FND_ATTACHED_DOCUMENTS AD,
FND_DOCUMENTS_TL DT
WHERE((entity_name = 'PO_HEAD' and pk1_value = :POH_PO_HEADER_ID and
pk2_value = '1') OR
(entity_name = 'PO_HEADERS' and pk1_value = :POH_PO_HEADER_ID) OR
(entity_name = 'PO_VENDORS' and pk1_value = :POH_VENDOR_ID))
AND AD.DOCUMENT_ID=DT.DOCUMENT_ID
AND DT.LANGUAGE = USERENV('LANG')
AND ROWNUM=1;

gfm_agent := fnd_web_config.gfm_agent;
--DBMS_OUTPUT.put_line (gfm_agent);
l_gfm_id := MED_ID; --media id
--DBMS_OUTPUT.put_line (l_gfm_id); -- MEDIA_ID
l_url := fnd_gfm.construct_download_url (gfm_agent, l_gfm_id, FALSE);
--DBMS_OUTPUT.put_line (l_url);

return l_url;

EXCEPTION WHEN OTHERS THEN
RETURN(NULL);
end;

No comments: