Tuesday, February 15, 2011

How to Print Oracle Report To A Network Shared Printer

In this post I will demonstrate how to send Oracle Report print job direct to a network shared printer.(WINDOWS ONLY)

Assuming you are running your application on Oracle Application Server 10g.




WHEN-BUTTON-PRESSED

DECLARE
  pl_id ParamList;
  lv_repid REPORT_OBJECT;
  lv_report VARCHAR2(100);
BEGIN
   pl_id := Get_Parameter_List('tmpdata');
  IF NOT Id_Null(pl_id) THEN
    Destroy_Parameter_List( pl_id );
  END IF;
  pl_id := Create_Parameter_List('tmpdata');
  Add_Parameter(pl_id,'P_1',TEXT_PARAMETER,:STUDENTS.STDCODE);
  Add_Parameter(pl_id, 'PARAMFORM', TEXT_PARAMETER, 'NO');
  lv_repid:=FIND_REPORT_OBJECT('std_ledger');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_FILENAME, 'c:\apps\reports\std_ledger1.rep');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_EXECUTION_MODE, RUNTIME);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_COMM_MODE , SYNCHRONOUS);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESTYPE ,PRINTER);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESNAME ,'\\192.168.101.69\hpLaserJ');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESFORMAT ,'hpl.prt');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_SERVER , 'rep_localhost_oracleas');
  lv_report := RUN_REPORT_OBJECT (lv_repid,pl_id);
END;

Note:
In my case I am using HP Laserjet printer. hpl.prt is the name of printer file shipped with oracle and located in your ORACLE_ASHOME/reports/printer directory.

9 comments:

Shop Towel said...

Another great article. I like that you are very honest and direct to the point.

Anonymous said...

I would like to say this is an excellent blog that I have ever come across. Very informative. Please write more so that we can get more details.





Web Design

sms message said...
This comment has been removed by a blog administrator.
athletic clothing said...

oracle report is nice stuff

Anonymous said...

how i can get printer name

Kazi Iqbal said...

Your code not execute.

Anonymous said...

how can i create .prt file for my printers?

Unknown said...

I am very happy to be able to find this good article
Honestly, this is one article that gives me incredible information and is very useful and very helpful
maybe I will visit this site again to find other articles that can be useful for me :)

Cara Menghilangkan Miom Di Rahim Secara Alami Cara Menghilangkan Bisul Pantat Cara Menyembuhkan Eksim Secara Alami Cara Menghilangkan Benjolan Di Leher Cara Mengeluarkan Batu Ginjal Obat Sesak Napas Cara Menghilangkan Nyeri Pinggang Saat Hamil Cara Menyembuhkan ISK Cara Mengatasi Rasa Nyeri Di Dada Sebelah Kiri Cara Mengatasi Kulit Kering & Bersisik Pada Selangkangan

Qamar Abbas said...

Thanks Bersama, sure you can visit any time or email me for oracle related queries.