Skip to content

Instantly share code, notes, and snippets.

@damithsj
Last active April 23, 2023 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damithsj/237945357bfd96c813d6d977cf57e401 to your computer and use it in GitHub Desktop.
Save damithsj/237945357bfd96c813d6d977cf57e401 to your computer and use it in GitHub Desktop.
Create and print IFS report via schedule job
DECLARE
result_key_ NUMBER;
report_attr_ VARCHAR2(32000);
parameter_attr_ VARCHAR2(32000);
message_attr_ VARCHAR2(2000);
archiving_attr_ VARCHAR2(2000);
distribution_list_ VARCHAR2(32000);
print_attr_ VARCHAR2(32000);
next_execution_date_ DATE;
schedule_name_ VARCHAR2(200);
schedule_id_ NUMBER;
seq_no_ NUMBER;
start_date_ DATE := SYSDATE;
report_id_ VARCHAR2(100) := 'SHOP_ORD_WI_REP';
pdf_archiving_ VARCHAR2(5) := 'FALSE';
printer_id_ VARCHAR2(1000);
BEGIN
CLIENT_SYS.Add_to_Attr('REPORT_ID', report_id_, report_attr_);
CLIENT_SYS.Add_To_Attr('ORDER_NO', 'SO001' , parameter_attr_);
CLIENT_SYS.Add_To_Attr('RELEASE_NO', '1' , parameter_attr_);
CLIENT_SYS.Add_To_Attr('SEQUENCE_NO', '1' , parameter_attr_);
schedule_name_ := Report_Definition_API.Get_Translated_Report_Title(report_id_);
printer_id_ := Printer_Connection_API.Get_Report_User_Printer(Fnd_Session_Api.Get_Fnd_User, report_id_, Fnd_Session_API.Get_Language);
Client_SYS.Add_To_Attr('MESSAGE_TYPE', 'PRINTER', message_attr_);
Client_SYS.Add_To_Attr('PRINTER_ID', printer_id_, message_attr_);
Client_SYS.Add_To_Attr('PDF_ARCHIVING', pdf_archiving_, archiving_attr_);
--Create the new scheduled report.
Batch_SYS.New_Batch_Schedule(schedule_id_,
next_execution_date_,
start_date_,
NULL,
schedule_name_,
'Archive_API.Create_And_Print_Report__',
'TRUE',
'ASAP', -- any valid schedule expression can be given here
NULL,
NULL,
report_id_);
Batch_SYS.New_Batch_Schedule_Param(seq_no_, schedule_id_, 'REPORT_ATTR', report_attr_);
Batch_SYS.New_Batch_Schedule_Param(seq_no_, schedule_id_, 'PARAMETER_ATTR', parameter_attr_);
Batch_SYS.New_Batch_Schedule_Param(seq_no_, schedule_id_, 'MESSAGE_ATTR', message_attr_);
Batch_SYS.New_Batch_Schedule_Param(seq_no_, schedule_id_, 'ARCHIVING_ATTR', archiving_attr_);
Batch_SYS.New_Batch_Schedule_Param(seq_no_, schedule_id_, 'DISTRIBUTION_LIST', distribution_list_);
End;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment