2 Replies Latest reply: Dec 15, 2013 7:24 AM by Ahmed_Jed RSS

    APEX_UTIL.GET_PRINT_DOCUMENT Error Unable to get the document

    Ahmed_Jed

      Hi,

         I am working on Oracle APEX 4.1 to send the report as an attachment through mail  I am unable to get the document while calling the APEX_UTIL.get_print_document. I have created a report query and report template (rtf template) so as to send the report as an email attachment. The report works fine individually upon clicking of button so there is no issue in BI publisher configuration. I am sure there is something very trivial which I am missing out here. Any help will be appreciated.

       

       

      Declare
         l_id number;
         l_document BLOB;
         l_error_msg varchar2(2000);
      BEGIN

         l_document := APEX_UTIL.GET_PRINT_DOCUMENT
                                                 (
               p_application_id=>'123',
               p_report_query_name=>'Sample_Report',   
               p_report_layout_name=> 'Sample_Report',
               p_report_layout_type=>'RTF',
               p_document_format=>'PDF',
               p_print_server => 'f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=Sample_Report'
               );

         IF l_document is null
         THEN
             dbms_output.put_line( ' no report returned');
            l_error_msg:='<html> <body> <h1 > Apologies the report was not returned from the apex , as there is some printing issues </h1> </body> </html> ';

         ELSE
            l_error_msg:=null;

         END IF;
         --
         IF l_error_msg IS NULL THEN

             l_id := APEX_MAIL.SEND(
             p_to => 'xyz@xyz.com',
             p_from => 'noreply@xyz.com',
             p_subj => 'APEX_MAIL with attachment',
             p_body => 'Please review the attachment.',
             p_body_html => '<b>Please</b> review the attachment' || l_error_msg);

       

            dbms_output.put_line(l_id);

            IF l_document is not null then

               APEX_MAIL.ADD_ATTACHMENT (
                          p_mail_id => l_id,
                          p_attachment => l_document,
                          p_filename => 'Sample_Report.pdf',
                          p_mime_type => 'application/pdf');

            END IF;
           --

      END IF;

      END;

       

      Here the output says no report returned.


      Thanks & Regards

      Ahmed