Tuesday, November 28, 2017

Oracle Form 11g calling Report

Hi,
 Here we are discussing how to call report through form in 11g.
In your form you need to create a button , on that button put a trigger "when-button-pressed".
We discuss ipaddress you need to give your server ip where your fmx and rdf located , reportserverName you need to check name of your report server .
test is rdf report which you created.


Here is the code :


declare
  repid REPORT_OBJECT;
  v_rep      VARCHAR2(100);
  rep_status VARCHAR2(20);
  pi_id      paramlist; --- Added
begin
   repid := find_report_object('test');
     if  ( (  :BLOCK2.STRT_BRNCH_CD is not null
        and :BLOCK2.END_BRNCH_CD is not null
    --    and :BLOCK2.STRT_DT is not null
    --    and :BLOCK2.END_DT is not null
        and :BLOCK2.STRT_VNDR# is not null
        and :BLOCK2.END_VNDR# is not null
        and :BLOCK2.STRT_ITEM# is not null
        and :BLOCK2.END_ITEM# is not null    ) )
     then
    pi_id := create_parameter_list('INPUT_PARAMS');
--
    add_parameter(pi_id,'FR_RCNCL_DATE',TEXT_PARAMETER,to_char(:STRT_DT,'DD/MM/YYYY'));
    add_parameter(pi_id,'TO_RCNCL_DATE',TEXT_PARAMETER,to_char(:END_DT,'DD/MM/YYYY'));
--
    add_parameter(pi_id,'FR_VNDR#',TEXT_PARAMETER,to_char(:STRT_VNDR#));
    add_parameter(pi_id,'TO_VNDR#',TEXT_PARAMETER,to_char(:END_VNDR#));
--
    add_parameter(pi_id,'FR_ITEM#',TEXT_PARAMETER,to_char(:STRT_ITEM#));
    add_parameter(pi_id,'TO_ITEM#',TEXT_PARAMETER,to_char(:END_ITEM#));
--
    add_parameter(pi_id,'FR_BRANCH_CD',TEXT_PARAMETER,to_char(:STRT_BRNCH_CD));
    add_parameter(pi_id,'TO_BRANCH_CD',TEXT_PARAMETER,to_char(:END_BRNCH_CD));
--
 
    add_parameter(pi_id,'P_1',TEXT_PARAMETER,:parameter.P_USER_NO);
--
    add_parameter(pi_id,'PARAMFORM',TEXT_PARAMETER,'NO');
--   ** Now Run Report **
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'); -- PDF, HTMLCSS ...
  --SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'');
  SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_wls_reports_testapps_asinst_1');
  set_report_object_property(repid, report_other,' paraform=no FR_RCNCL_DATE='||to_char(:STRT_DT,'DD/MM/YYYY')||' '||'TO_RCNCL_DATE='||to_char(:END_DT,'DD/MM/YYYY')
  ||' '||'FR_VNDR#='||to_char(:STRT_VNDR#)
  ||' '||'TO_VNDR#='||to_char(:END_VNDR#)
  ||' '||'FR_ITEM#='||to_char(:STRT_ITEM#)
  ||' '||'TO_ITEM#='||to_char(:END_ITEM#)
  ||' '||'FR_BRANCH_CD='||to_char(:STRT_BRNCH_CD)
  ||' '||'TO_BRANCH_CD='||to_char(:END_BRNCH_CD)
  ||' '||'P_1='||:parameter.P_USER_NO
  );
--
    destroy_parameter_list(pi_id);
    else
        null;
    end if;
--
  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://ipaddress:9002/reports/rwservlet/getjobid'|| SUBSTR(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=reportserverName','_blank');
    /*the above code will help you to create in browser*/
  ELSE
    MESSAGE('Error in report');
  END IF;
end;

No comments:

Post a Comment