Solved

Automate printing of Purchase Requisition pdf

  • 26 February 2024
  • 5 replies
  • 56 views

Userlevel 4
Badge +9

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.

icon

Best answer by jdoherty 27 February 2024, 12:19

View original

5 replies

Userlevel 3
Badge +10

You could create a custom event on the purchase_requisition_tab table.  Then use the Purchase_Requisition_RPI to create the data needed for the report.  Then if my memory is correct, there is a method call in Report_sys for creating the PDF from the data.

Userlevel 4
Badge +9

Thanks, I tried capturing the SQL that is sent to the server in the console window when a Requisition is printed but it doesn’t really give me what I want. This is the link I got the code from that enabled me to create a Purchase Order pdf manually, it would be great if I could find something similar for Purchase Requisition. 

 

Userlevel 4
Badge +9

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;

 

Userlevel 3
Badge +10

I am not sure what the cloud version is like, but IFS 10 requires more values sent to Print_Job_API.New.

      Error_SYS.Check_Not_Null(lu_name_, 'PRINT_JOB_ID', newrec_.print_job_id);
      Error_SYS.Check_Not_Null(lu_name_, 'STATUS', newrec_.status);
      Error_SYS.Check_Not_Null(lu_name_, 'EXPIRE_DATE', newrec_.expire_date);
      Error_SYS.Check_Not_Null(lu_name_, 'USER_NAME', newrec_.user_name);
      Error_SYS.Check_Not_Null(lu_name_, 'PRINT_JOB_OWNER', newrec_.print_job_owner); 

Userlevel 4
Badge +9

I am not sure what the cloud version is like, but IFS 10 requires more values sent to Print_Job_API.New.

      Error_SYS.Check_Not_Null(lu_name_, 'PRINT_JOB_ID', newrec_.print_job_id);
      Error_SYS.Check_Not_Null(lu_name_, 'STATUS', newrec_.status);
      Error_SYS.Check_Not_Null(lu_name_, 'EXPIRE_DATE', newrec_.expire_date);
      Error_SYS.Check_Not_Null(lu_name_, 'USER_NAME', newrec_.user_name);
      Error_SYS.Check_Not_Null(lu_name_, 'PRINT_JOB_OWNER', newrec_.print_job_owner); 

 

Thanks for your reply, the code I posted is doing what I require though.

Reply