Friday, April 27, 2012

How to call a report in Forms 10g ?

Calling reports from forms isn't like forms version 6i, where you can call a report via RUN_PRODUCT.
I will talk another day if i think it's needed. Because Forms version 6i isn't supported by Oracle.com and it's uses is going to decreases.

Lets talk about version 10g Developer Suite. In development environment you need to run report server manually but at Application Server it's not needed.

How can we run report server manually ?
Just go to start menu >> run and type    
rwserver SERVER=myserver
Where myserver is the server name.
Now reports server runs.
 
In your form under Reports Node create an report object and give name MYREPORT
(Select Reports Node click on Create Icon(+), select Use Existing Report File then give
 a name in the box and click OK.
Re-name it to MYREPORT go to property and delete FILENAME property value.)  
  
Make changes(Report Name) on following code and  try this in a Button trigger 
 
DECLARE
 
v_repid REPORT_OBJECT;
v_rep VARCHAR2(100);
v_rep_status VARCHAR2(100);
v_param VARCHAR2(200) := NULL;
v_valor VARCHAR2(200);
v_url VARCHAR2(2000);
v_repserver varchar2(20) := 'myserver';
 
v_report varchar2(100) := 'D:\REPORT_NAME.REP';
v_PARAMETRO varchar2(100) := '';
 
BEGIN
 
v_repid := FIND_REPORT_OBJECT('MYREPORT'); -- report is an element from object navigator report
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_FILENAME, v_report);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_EXECUTION_MODE, BATCH);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_COMM_MODE, SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESTYPE, cache);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESFORMAT, 'pdf' );
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESNAME, v_report);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_SERVER, v_repserver);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_OTHER, 'paramform=no '||v_PARAMETRO);
v_rep := RUN_REPORT_OBJECT(v_repid);
v_rep_status := REPORT_OBJECT_STATUS(v_rep);
WHILE v_rep_status IN ('RUNNING','OPENING_REPORT','ENQUEUED') LOOP
v_rep_status := REPORT_OBJECT_STATUS(v_rep);
END LOOP;
IF v_rep_status = 'FINISHED' THEN
message(v_rep);
message(v_rep);
WEB.SHOW_DOCUMENT(v_url||'/reports/rwservlet/getjobid'||
SUBSTR(v_rep, INSTR(v_rep,'_', -1)+1)||'?'||'server='||v_repserver, '_blank');
END IF;
 
END;
 
Updated: 20/January/2013
  
For more Click Here
 
Hope this helps you all. 

Wednesday, April 11, 2012

How to Spell Check in Oracle Forms 6i ?

How will you feel if you able to check spelling in oracle forms?

Yea! Surely great…
Let’s try how we can do that.
This code uses the Microsoft Office spell checker, so you have installed Microsoft office suite. Now, create a procedure in forms under program units with the following code.

PROCEDURE spell_check (item_name IN VARCHAR2)
IS
   my_application   ole2.obj_type;
   my_documents     ole2.obj_type;
   my_document      ole2.obj_type;
   my_selection     ole2.obj_type;
   get_spell        ole2.obj_type;
   my_spell         ole2.obj_type;
   args             ole2.list_type;
   spell_checked    VARCHAR2 (4000);
   orig_text        VARCHAR2 (4000);
BEGIN
   orig_text := NAME_IN (item_name);
   my_application := ole2.create_obj ('WORD.APPLICATION');
   ole2.set_property (my_application, 'VISIBLE', FALSE);
   my_documents := ole2.get_obj_property (my_application, 'DOCUMENTS');
   my_document := ole2.invoke_obj (my_documents, 'ADD');
   my_selection := ole2.get_obj_property (my_application, 'SELECTION');
   ole2.set_property (my_selection, 'TEXT', orig_text);
   get_spell :=ole2.get_obj_property (my_application, 'ACTIVEDOCUMENT');
   ole2.invoke (get_spell, 'CHECKSPELLING');
   ole2.invoke (my_selection, 'WholeStory');
   ole2.invoke (my_selection, 'Copy');
   spell_checked := ole2.get_char_property (my_selection, 'TEXT');
   spell_checked :=SUBSTR (REPLACE (spell_checked, CHR (13), CHR (10)),1,LENGTH (spell_checked));
   COPY (spell_checked, item_name);
   args := ole2.create_arglist;
   ole2.add_arg (args, 0);
   ole2.invoke (my_document, 'CLOSE', args);
   ole2.destroy_arglist (args);
   ole2.RELEASE_OBJ (my_selection);
   ole2.RELEASE_OBJ (get_spell);
   ole2.RELEASE_OBJ (my_document);
   ole2.RELEASE_OBJ (my_documents);
   ole2.invoke (my_application, 'QUIT');
   ole2.RELEASE_OBJ (my_application);
END;

Now call the procedure in a Button passing the column name. Like
spell_check(‘Block_Name.Item_Name’);

Now all is yours…  :)

Say thanks, if it helps.