2 Replies Latest reply on Oct 21, 2012 5:47 AM by parapr

    How to print report From Oracle form directly on printer

    parapr
      Hi,

      I am running report from form and output should be directly printed on printer.

      Database: 11g Release2
      Forms version : 11.1.2
      Report version : 11.1.2
      OS: windows 7 professional 32 Bit

      Written following code:

      declare
      pl_id ParamList;
      varno number;
      x VARCHAR2(150);
      y NUMBER;
      repid REPORT_OBJECT;
      v_rep VARCHAR2(100);
      begin                
      pl_id := Get_Parameter_List('tmpdata');
      IF NOT Id_Null(pl_id) THEN
      Destroy_Parameter_List( pl_id );
      END IF;
      repid := FIND_REPORT_OBJECT('SALEBILLNEW'); -- report object name
      pl_id := Create_Parameter_List('tmpdata');
      Add_Parameter(pl_id,'copies',TEXT_PARAMETER,'1');
      Add_Parameter(pl_id,'background',TEXT_PARAMETER,'Yes');
      Add_Parameter(pl_id,'mode',TEXT_PARAMETER,'Character');
      Add_Parameter(pl_id,'printjob',TEXT_PARAMETER,'YES');
      Add_Parameter(pl_id,'VCOMPANY',TEXT_PARAMETER,:block50.coname);
      Add_Parameter(pl_id,'VCOde',TEXT_PARAMETER,:block50.code);
      Add_Parameter(pl_id,'VOURBILLNO',TEXT_PARAMETER,:BLOCK50.FROMBILL);
      Add_Parameter(pl_id,'PARAMFORM',TEXT_PARAMETER,'NO');
      Add_Parameter(pl_id,'DESTYPE',TEXT_PARAMETER, 'PRINTER') ;
      Add_Parameter(pl_id,'DESNAME',TEXT_PARAMETER, 'OKI MICROLINE 391 TURBO (COPY1) on NILESH-PC') ; --default printer name

      SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
      SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
      SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,PRINTER);
      SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_adminserver_inorasrv-pc_asinst_3');

      y := LENGTH ('rep_adminserver_inorasrv-pc_asinst_3') + 2;
      x := RUN_REPORT_OBJECT (repid, pl_id);

      WEB.SHOW_DOCUMENT('http://inorasrv-pc:7001/reports/rwservlet/getjobid'||SUBSTR(x,y)||'?server=rep_adminserver_inorasrv-pc_asinst_3&userid=scott/tiger@winorasr');
      Destroy_parameter_list('tmpdata');
      end;

      Above code giving following error:
      REP-52251: The output of job ID 111 requested on Thu Oct 18 18:37:20 IST 2012 cannot be retrieved.<P>REP-51026: No output is generated for job 111.

      Need help..

      Thanks in advance.
        • 1. Re: How to print report From Oracle form directly on printer
          François Degrelle
          Hello,

          I think you have to wait the report is finished:
          report_message := run_report_object(report_id);
          rep_status := report_object_status(report_message);
          IF rep_status=’FINISHED’ THEN
            vjob_id :=substr(report_message,length(report_server_name)+2,length(report_message));
            WEB.SHOW_DOCUMENT(reports_servlet||’/getjobid’||vjob_id||’?server=’||
            report_server_name,’ _blank’);
          ELSE
            --handle errors
            null;
          END IF;
          <p>See that document</p>
          Francois
          • 2. Re: How to print report From Oracle form directly on printer
            parapr
            Hi,
            I have change the printer name to OKI
            Add_Parameter(pl_id,'DESNAME',TEXT_PARAMETER, '\\Nilesh-pc\OKI') ;
            Add_Parameter(pl_id,'DESFORMAT',TEXT_PARAMETER, 'dflt.prt');

            SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESNAME,'\\Nilesh-pc\OKI');
            SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'dflt.prt');

            code which i have posted above unable to reach at default printer and gives following error
                 
            The report generated successfully but distribution to destinations failed.


            Modified above code to take default printer from registry.
            Added below code

            rtn_Registry := CLIENT_WIN_API_ENVIRONMENT.Read_Registry('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows','Device');
            rtn_defaultPrinter := substr(rtn_Registry,1,instr(rtn_Registry,',',1)-1);

            Add_Parameter(pl_id,'DESNAME',TEXT_PARAMETER, 'rtn_defaultPrinter') ;

            It is giving error
            CLIENT_WIN_API_ENVIRONMENT.Read_Registry must be declare.

            Edited by: parapr on Oct 20, 2012 10:47 PM