This discussion is archived
2 Replies Latest reply: Nov 19, 2012 6:31 AM by tony.g RSS

Printing report directly on printer or pnly displaying based on a parameter

974965 Newbie
Currently Being Moderated
Hi All,
I am running a report from Form Builder - 10g and intend to either preview a report or print it based on a parameter.

Have searched through this forum and got to use - CLIENT_WIN_API_ENVIRONMENT.Read_Registry in order to find the default printer at the client side.

This is my code -
PROCEDURE RUN_REPORT_DN (cID_PRINT_TYPE NATURAL,cListName varchar2)
IS
pl_id paramlist;
v_rep_id report_object;
v_rep_job_id varchar2(100);
v_rep_status varchar2(100);
v_server varchar2(100) := hpm_admin.getcontrolvalue('REPORT_SERVER');
vjob_id VARCHAR2(100);
V_PRINTER varchar2(100);
p_printer_name varchar2(100);


BEGIN

-- check whether the paralist name is ok, if not set it right ...
pl_id := get_parameter_list(cListName);
-- pl_id := GET_REPORT_RUNMODE( cID_PRINT_TYPE,cListName );
V_PRINTER := CLIENT_WIN_API_ENVIRONMENT.READ_REGISTRY('HKEY_CURRENT_USER\software\Microsoft\Windows NT\CurrentVersion\Windows','Device',TRUE);
p_printer_name := (substr(V_PRINTER, 1, instr(V_PRINTER, ',' , 1)-1 ));

-- run the report ...
if not id_null(pl_id) then
v_rep_id := find_report_object('REPORT126');      
if cID_PRINT_TYPE = 0 then ---- parameter to decide preview or print
set_report_object_property(v_rep_id,REPORT_DESTYPE,cache);
set_report_object_property(v_rep_id,REPORT_COMM_MODE,ASYNCHRONOUS);
Else
     set_report_object_property(v_rep_id,REPORT_DESTYPE,PRINTER);
     set_report_object_property(v_rep_id,REPORT_DESNAME,p_printer_name);      set_report_object_property(v_rep_id,REPORT_COMM_MODE,SYNCHRONOUS);
end if;


set_report_object_property(v_rep_id,REPORT_DESFORMAT,'PDF');
     set_report_object_property(v_rep_id,REPORT_SERVER,v_server);

v_rep_job_id := RUN_REPORT_OBJECT(v_rep_id,pl_id);     
message('v_rep_job_id - '||v_rep_job_id);pause;
vjob_id := substr(v_rep_job_id, length(v_server)+2 , length(v_rep_job_id));
message('vjob_id - '||vjob_id);pause;
v_rep_status := REPORT_OBJECT_STATUS(v_rep_job_id);

if v_rep_status in ('FINISHED', 'RUNNING','OPENING_REPORT','ENQUEUED') then      
     web.show_document ('/reports/rwservlet/getjobid'||vjob_id ||'?server='|| v_server,'_blank');
else      
     message ('Report failed with error message '||v_rep_status,acknowledge);
end if;
     
end if;
END;

---------------------
But I am getting the error - CLIENT_WIN_API_ENVIRONMENT.Read_Registry must be declared.

Wat setup/syntax is missing.

Can someone advise plz...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points