Friday, 18 August 2017
Technical

FND_REQUEST or FND_DELIVERY to Email Oracle Concurrent Request Output

Emailing concurrent request output is a common requirement in any business. You can email a concurrent request output in Oracle Apps using Delivery Options while submitting the request or using API FND_REQUEST.ADD_DELIVERY_OPTION or FND_DELIVERY. You should use this API when you are submitting a concurrent request from backend using PL/SQL.

I will explain how to use fnd_request.add_delivery_option and fnd_delivery option, before that, I recommend reading below articles.

FND_REQUEST.ADD_DELIVERY_OPTION

We use fnd_request.submit_request API to submit concurrent program. We can set delivery option before submitting concurrent program using fnd_request.add_delivery_option.

fnd_request.add_delivery_option syntax

Below is the signature of add_delivery_option function in fnd_request package.



FUNCTION add_delivery_option(
type IN VARCHAR2,
p_argument1 IN VARCHAR2 DEFAULT NULL,
p_argument2 IN VARCHAR2 DEFAULT NULL,
p_argument3 IN VARCHAR2 DEFAULT NULL,
p_argument4 IN VARCHAR2 DEFAULT NULL,
p_argument5 IN VARCHAR2 DEFAULT NULL,
p_argument6 IN VARCHAR2 DEFAULT NULL,
p_argument7 IN VARCHAR2 DEFAULT NULL,
p_argument8 IN VARCHAR2 DEFAULT NULL,
p_argument9 IN VARCHAR2 DEFAULT NULL,
nls_language IN VARCHAR2 DEFAULT NULL)
RETURN BOOLEAN;
Arguments
Type - Delivery type Email, Printer, Fax etc.
p_argument1 - p_argument9 - Options specific to the delivery type
nls_language - Add only for this language

Either hard-code type value or use built-in constants defined in FND_DELIVERY package. Type parameter has below values,

  • Email – ‘E’ or FND_DELIVERY.TYPE_EMAIL
  • IPP printer – ‘P’ or FND_DELIVERY.TYPE_IPP_PRINTER
  • FAX – ‘F’ or FND_DELIVERY.TYPE_IPP_FAX
  • FTP – ‘T’ or FND_DELIVERY.TYPE_FTP
  • SFTP – ‘S’ or FND_DELIVERY.TYPE_SFTP
  • HTTP – ‘H’ or FND_DELIVERY.TYPE_HTTP
  • WebDav – ‘W’ or FND_DELIVERY.TYPE_WEBDAV
  • Custom  – ‘C’ or FND_DELIVERY.TYPE_CUSTOM
  • Burst – ‘B’ or FND_DELIVERY.TYPE_BURST

 

Example 1 – set delivery option email using fnd_request.add_delivery_option

DECLARE
l_request_id NUMBER;
l_bol_delivery BOOLEAN;
BEGIN
fnd_global.apps_initialize (user_id=>1121
,resp_id=>20419
,resp_appl_id=>0);
l_bol_delivery := fnd_request.add_delivery_option (TYPE             => 'E', -- EMAIL
p_argument1      => 'Concurrent Program Output',-- Email Subject
p_argument2      => [email protected]',-- From Address
p_argument3      => [email protected]',   -- To Address
p_argument4      => [email protected]'    -- CC
);
l_request_id := fnd_request.submit_request ( application => 'FND'
, program => 'FNDCPPGD'
, description => 'Report of Concurrent Program details'
, start_time => sysdate
, sub_request => FALSE
, argument1 => 'MSC'
, argument2 => 'MSCHUBA'
);
COMMIT;
IF l_request_id = 0 THEN
dbms_output.put_line('Request not submitted error '|| fnd_message.get);
ELSE
dbms_output.put_line('Request submitted successfully request id ' || l_request_id);
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Unexpected error ' || SQLERRM);   
END;

 

FND_DELIVERY.ADD_EMAIL

fnd_delivery API is a wrapper created on fnd_request.add_delivery_option package. It simplifies setting of different delivery options. Below is the list of available functions to set different delivery option.

  • add_email
  • add_ipp_printer
  • add_fax
  • add_ftp
  • add_webdav
  • add_http

Let’s see how to use add_email function to set the email as a delivery option.

fnd_delivery.add_email Syntax

function add_email (subject in varchar2,
from_address in varchar2,
to_address in varchar2,
cc in varchar2 default null,
lang in varchar2 default null) return boolean;

Example 2 – set delivery option email using fnd_delivery.add_email

DECLARE
l_request_id NUMBER;
l_bol_delivery BOOLEAN;
BEGIN
fnd_global.apps_initialize (user_id=>1121
,resp_id=>20419
,resp_appl_id=>0);
l_bol_delivery := fnd_delivery.add_email (subject => 'Concurrent Program Output',-- Email Subject
from_address => [email protected]',-- From Address
to_address  => [email protected]',   -- To Address
cc => [email protected]'    -- CC
);
l_request_id := fnd_request.submit_request ( application => 'FND'
, program => 'FNDCPPGD'
, description => 'Report of Concurrent Program details'
, start_time => sysdate
, sub_request => FALSE
, argument1 => 'MSC'
, argument2 => 'MSCHUBA'
);
COMMIT;
IF l_request_id = 0 THEN
dbms_output.put_line('Request not submitted error '|| fnd_message.get);
ELSE
dbms_output.put_line('Request submitted successfully request id ' || l_request_id);
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Unexpected error ' || SQLERRM);   
END;

This submits a concurrent program. Navigate to request window -> View Details -> Delivery Opts. You can clearly see the value set by API is visible here.

concurrent-request-delivery-option

fnd_request.add_delivery_option or fnd_delivery is very useful API to set delivery method for ouput of concurrent program.

I hope you find this useful. Do let me know in the comments section below.

 

One Comment

Leave a Reply