1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Developer Report 10g - How to generate directly a file ( pdf, html, text etc. )

Discussion in 'Oracle Forms and Reports' started by ghulam.e.ahmed, Dec 4, 2013.

  1. hi all gurus,

    this is my first ever post, I am new in the development area and facing a problem.
    I am using Developer 10g, calling report through a Form Module and want to Directly save in file name specified but failed. My code to call report mentioned below for your ready reference. NO Parameter using in Report Module.

    This showing report on Screen instead of giving output file, user have to use Save As command and also there is no file name which I sent to Report Module.

    Code (Text):


    Declare
      rep_obj         REPORT_OBJECT;    
      v_rep           VARCHAR2(100);  
      rep_status      VARCHAR2(20);  
      v_rep_server    app_server_objects_detail.OBJECT_VALUE%type;
      v_p_action      app_server_objects_detail.OBJECT_VALUE%type;
      v_rep_getjobid  app_server_objects_detail.OBJECT_VALUE%type;
      v_rep_killjobid app_server_objects_detail.OBJECT_VALUE%type;
      v_rep_obj_path  app_server_objects_detail.OBJECT_VALUE%type;  
    BEGIN  
      --------------------------------- setting app server object properties ---------------------------------
      for rec in ( select object_code,object_value
                     from   itmis.app_server_objects_detail
                 )
      loop  
         if rec.object_code=1 then
            v_rep_server:=rec.OBJECT_VALUE;
         end if;

         if rec.object_code=11 then
            v_rep_obj_path:=rec.OBJECT_VALUE;
         end if;

         if rec.object_code=19 then
            v_rep_getjobid:=rec.OBJECT_VALUE;
         end if;

         if rec.object_code=20 then
            v_rep_killjobid:=rec.OBJECT_VALUE;
         end if;

         if rec.object_code=21 then
            v_p_action:=rec.OBJECT_VALUE;
         end if;
      end loop;    
      --------------------------------- -------------------------------------- ---------------------------------

      rep_obj := find_report_object('SHORT');  --- report name
       
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_EXECUTION_MODE,BATCH);  
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_COMM_MODE,SYNCHRONOUS);
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_DESTYPE,FILE);
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_DESFORMAT,:TEXT_BLOCK.REP_FORMAT); -- Form's Text Field
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_SERVER,v_rep_server);
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_DESNAME,:TEXT_BLOCK.FILE_NAME);  -- Form's Text Field
      SET_REPORT_OBJECT_PROPERTY(rep_obj,REPORT_OTHER,'paramform=no'||
                                                      ' P_SERVERNAME='||v_rep_server||
                                                      ' P_ACTION='||v_p_action);

      set_report_object_property(rep_obj,REPORT_FILENAME,v_rep_obj_path||lower('short.rdf'));

      v_rep             := RUN_REPORT_OBJECT(rep_obj);
      rep_status    := REPORT_OBJECT_STATUS(v_rep);

      WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
        LOOP
          rep_status := report_object_status(v_rep);
        END LOOP;

      IF rep_status = 'FINISHED' THEN
          WEB.SHOW_DOCUMENT(v_rep_getjobid||substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server='||v_rep_server,'_blank');
          WEB.SHOW_DOCUMENT(v_rep_killjobid||substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server='||v_rep_server,'_blank');
      ELSE  
        message('Error when running report', Acknowledge);  
      END IF;  

    EXCEPTION
       WHEN OTHERS THEN
            show_err_msg;
    END;

     
    Please help where I made mistake.

    Regards.
     
  2. mohammedasif

    mohammedasif Active Member

    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    100
    the below code is just a sample code, jus see for reference and in the des format area you can change formats like pdf,spreadsheet,xml etc


    declare
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    rep_status VARCHAR2(20);
    BEGIN
    repid := find_report_object('CALLREP');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'pdf');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'reportserver10g');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no P_EMPCODE='||:NBT_EMPCODE|| ' ' ||' P_LOCATION='||:BLOCK2.NBT_NBT_LOCATION);
    v_rep := RUN_REPORT_OBJECT(repid);
    rep_status := REPORT_OBJECT_STATUS(v_rep);
    WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
    LOOP
    rep_status := report_object_status(v_rep);
    END LOOP;
    IF rep_status = 'FINISHED' THEN WEB.SHOW_DOCUMENT('http://SHADY:8889/reports/rwservlet/getjobid'||
    substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=reportserver10g','_blank');
    /*the above code will help you to create in browser*/
    ELSE
    message('Error in report');
    END IF;
    END;