Streams for Background Jobs and Reports

Streams for Background jobs and Reports is an extension of the Streams concept which notifies end users of a completion of a background job/ report. The support for enabling Streams notifications for Background jobs and modifying the streams message which gets display to the end user have been exposed as an API. You could look at how this functionality is implemented for Task Schedules, Report schedules and Task Chain forms. These are to be considered as reference implementations which are using this API.

Contents

 

Opt-in to Streams for Background Jobs

Opting into Streams for Background jobs is a matter of passing the following optional parameters into TRANSACTION_SYS.Deferred_Call / BATCH_SYS.New_Batch_Schedule.

If you have existing calls into TRANSACTION_SYS.Deferred_Call  or BATCH_SYS.New_Batch_Schedule you may use the following overloads of these procedures to opt-in to this functionality

TRANSACTION_SYS.Deferred_Call:

TRANSACTION_SYS.Deferred_Call (
   id_              OUT NUMBER,
   procedure_name_   IN VARCHAR2,
   argument_type_db_ IN VARCHAR2,
   arguments_        IN VARCHAR2,
   description_      IN VARCHAR2,
   posted_date_      IN DATE DEFAULT sysdate,
   lang_indep_       IN VARCHAR2 DEFAULT 'FALSE',
   queue_id_         IN NUMBER DEFAULT NULL,
   total_work_       IN NUMBER DEFAULT NULL,
   stream_msg_on_completion_ IN VARCHAR2 DEFAULT 'FALSE',
   stream_notes_ IN VARCHAR2 DEFAULT NULL
   );

BATCH_SYS.New_Batch_Schedule:

BATCH_SYS.New_Batch_Schedule (
   schedule_id_            OUT    NUMBER,
   next_execution_date_    IN OUT NOCOPY DATE,
   start_date_             IN OUT NOCOPY DATE,
   stop_date_              IN     DATE,
   schedule_name_          IN     VARCHAR2,
   method_                 IN     VARCHAR2,
   active_db_              IN     VARCHAR2,
   execution_plan_         IN     VARCHAR2,
   lang_code_              IN     VARCHAR2 DEFAULT Nvl(Fnd_Session_API.Get_Language, 'en'),
   installation_id_        IN     VARCHAR2 DEFAULT NULL,
   external_id_            IN     VARCHAR2 DEFAULT NULL,
   check_executing_        IN     VARCHAR2 DEFAULT NULL, 
   stream_msg_on_completion_ IN VARCHAR2 DEFAULT 'FALSE',
   stream_notes_ IN VARCHAR2 DEFAULT NULL
 );
 

 

Modifying the Generated Streams Message via the Hooking API

The developer may also want to modify the message shown to the end-user with customized content relevant to the process that was carried out in the background. This could be achieved by calling the Transaction_SYS.Modify_Stream_Notification hooking API from within your background process.

Streams Message Structure

In a Streams Message a developer could customize the Header, Message and the URL. The note is entered by the end user and the Avatar is set depending on the Stream type.

The Hooking API

Transaction_SYS. Modify_Stream_Notification is the primary procedure for hooking to the Stream for Background job and Reports runtime. There are also several other helper procedures if you want to modify only a small set of parameters - Modify_Stream_Message , Modify_Stream_Reference  , Modify_Stream_URL, Modify_Stream_Error_Message.


Transaction_SYS. Modify_Stream_Notification (
   reference_ VARCHAR2 DEFAULT NULL,
   url_ VARCHAR2 DEFAULT NULL,
   trans_lu_name_ VARCHAR2 DEFAULT NULL,
   header_ VARCHAR2 DEFAULT NULL,
   message_ VARCHAR2 DEFAULT NULL,
   message_parameter_ VARCHAR2 DEFAULT NULL,
   error_header_ VARCHAR2 DEFAULT NULL, 
   error_message_ VARCHAR2 DEFAULT NULL, 
   error_message_parameter_ VARCHAR2 DEFAULT NULL
)

 

Using the Hooking API


The Hooking API could be used as follows:

PROCEDURE Background_Procedure()
IS
BEGIN

Transaction_SYS.Modify_Stream_Error_Message(lu_name,
	'STREAMERRORH: Background_Procedure Error'
	'STREAMERRORM: Background_Procedure terminated due to an unknown error');

   Background_Procedure_Body();
   
Transaction_SYS.Modify_Stream_Url('ifswin:Ifs.Application.InfoServices.ReportArchive?action=get'||'&'||'key1='|| result_key_);

Transaction_SYS.Modify_Stream_Message(lu_name_,
      'STREAMHEADER: Your Report Is Ready' , 
      'STREAMMSG: Report -  :P1 Is Now Ready ',
      Report_Definition_API.Get_Report_Title(report_id_));

END Background_Procedure;

 

For a concrete example you could look into how it’s implemented in Reporting Archive_API. Create_And_Print_Report__ 

There are also several helper API, if you want to modify only a small set of parameters- Modify_Stream_Message ,Modify_Stream_Reference ,Modify_Stream_URL,Modify_Stream_Error_Message.

Important Considerations

Useful Links