Is it possible to automate the printing process of a Purchase Requisition? Or at least the creation of the pdf? I can capture the output in the debug window when I select RMB-”Print Requisition” on the Requisition screen but there is too much code in the output, I can’t find the block that creates the pdf. I can do it for a Purchase Order but I want to do it for the requisition.
Solved
Automate printing of Purchase Requisition pdf
Best answer by jdoherty
Actually I think I can do it now. I found this link which shows how to do it for a Shop Order Work In Progress report and I was able to adjust it to do it for a Purchase Requisition (see code below link). When I run it, it creates a print job
https://gist.github.com/damithsj/70fccd01d46a7ac6de60a4f587ef1b20
DECLARE
report_id_ VARCHAR2(100) := 'PURCHASE_REQUISITION_REP'; -- Report ID
report_attr_ VARCHAR2(2000) ;
parameter_attr_ VARCHAR2(2000);
distribution_list_ VARCHAR2(2000):= '';
result_key_ NUMBER;
printer_id_ VARCHAR2(100);
print_job_attr_ VARCHAR2(2000);
job_contents_attr_ VARCHAR2(2000);
print_job_id_ NUMBER;
instance_attr_ VARCHAR2(32000);
lang_code_ VARCHAR2(2);
printer_id_list_ VARCHAR2(32000);
BEGIN
------------------------------------------------------
-- (1) Create Archive instance
------------------------------------------------------
-- Create the report attr
CLIENT_SYS.Add_To_Attr('REPORT_ID', report_id_, report_attr_);
-- Add report parameters
CLIENT_SYS.Add_To_Attr('REQUISITION_NO', '312969' , parameter_attr_);
-- Create Archive instance.
-- It will return the result key
Archive_API.New_Instance(result_key_, report_attr_, parameter_attr_);
------------------------------------------------------
-- (2) Create Print Job and contents
------------------------------------------------------
-- Get the user default printer.
printer_id_ := Printer_Connection_API.Get_Default_Printer(Fnd_Session_API.Get_Fnd_User, report_id_);
Client_SYS.Add_To_Attr('PRINTER_ID', printer_id_, print_job_attr_);
-- Create Print job
Print_Job_API.New(print_job_id_, print_job_attr_);
Client_SYS.Add_To_Attr('RESULT_KEY', result_key_, job_contents_attr_);
Client_SYS.Add_To_Attr('PRINT_JOB_ID',print_job_id_,job_contents_attr_);
PRINT_JOB_CONTENTS_API.New_Instance(job_contents_attr_);
------------------------------------------------------
-- (3) Print!
------------------------------------------------------
Print_Job_API.Print(print_job_id_);
commit;
END;
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.