How to use Webutil in Oracle Forms 11g to save a file on Oracle AS 11g

Stics Post in oracle, oracle forms,Tags: ,
0

Before you go into any development download and try the Webutil Demo first and see how that works in your environment!

1. Add the Webutil library to the form

2. Create a Data Block “COMMAND_LINE”

3. Create a new layout with the following parameters:

cmd = command-line parameters (data block only)
filename = filename to be entered
browse = browse for file destination
ok_btn = ok button
cancel_btn = cancel button

4. Create a Function that will populate the parameters retrieved (this is used later on)

FUNCTION build_parameter_list(p_user varchar2, p_report varchar2)
RETURN varchar2 IS

v_res varchar2(5000);

cursor c1 is
select *
from report_parameters
where user_code = p_user
and report_code = p_report;

v_rec      c1%rowtype;
v_filename varchar2(400);

BEGIN
v_filename := :command_line.filename;
v_res      := 'report=' || p_report || '.rdf';

v_res := v_res || ' userid=' || get_application_property(USERNAME) || '/' ||
get_application_property(PASSWORD) || '@' ||
get_application_property(CONNECT_STRING);

v_res := v_res ||
' server=ReportsServer_DOMAIN-NAME_asinst_1 destype=file desformat=RTF desname="' ||
v_filename || '" P_USER=''' || p_user || '''';

return v_res;
end;

5. Create a trigger on the Browse button (WHEN_BUTTON_PRESSED)

DECLARE
Var_Filename VARCHAR2(256) ;

BEGIN
:command_line.filename :=  client_GET_FILE_NAME('c:\temp',null,
'Microsoft Word Files (*.doc)|*.doc|' || 'Rich Text Format Files (*.rtf)|*.rtf|',
'Select a Destination',"SAVE_FILE", TRUE);
message(:command_line.filename);
End;

6. Create a trigger on the OK button (WHEN_BUTTON_PRESSED)

declare
AppID    PLS_INTEGER;
frm_name varchar2(300);
vCopied  boolean;
l_success       boolean;
l_bare_filename varchar2(50);

begin
frm_name := get_application_property(calling_form);

if frm_name = 'TESTER_FORM_NAME' then
:parameter.p_rep := 'TEST_REPORT_NAME';
end if;

:parameter.p_user := get_application_property(username);

if :command_line.filename is null then
message('Please enter or specify a filename.');
elsif upper(:command_line.filename) not like '%.DOC' and
upper(:command_line.filename) not like '%.RTF' then
message('File can only be of type .RTF or .DOC');
else
:command_line.cmd := build_parameter_list(:parameter.p_user,
:parameter.p_rep);

AppID := DDE.App_Begin('rwclient.exe ' || :command_line.cmd,
DDE.App_Mode_Normal);

l_success := webutil_file_transfer.AS_to_Client_with_progress(
clientFile       => :command_line.filename,
serverFile       => 'c:\temp\downloaded_from_as.doc',
progressTitle    => 'Download from Application Server in progress',
progressSubTitle => 'Please wait');

exit_form(no_validate);
end if;
end;

7. Create a trigger on the Cancel button to exit the form

exit_form (no_validate);

 NOTES:

If you get the error: Exception in thread “main” java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path

1. Make sure the property file c:\Program Files\Java\jre6\webutil.DOMAIN_NAME.webutil.properties

exists on the client (this is downloaded from the server automatically) and has the library entry of

jacob-1.14.3-x86.dll as follows: syslib.jacob-1.14.3-x86.dll=1.14.3

2. Also, it should exist in c:\Oracle\Middleware\as_1\forms\webutil\win32\jacob-1.14.3-x86.dll on the server but if you still get the error above, then also add it to

c:\Oracle\Middleware\as_1\forms\webutil\jacob-1.14.3-x86.dll  on the server

3. Try downloading the dll directly from the server if you having access problems:

Delete the files (d2kwut60.dll, jacob.dll, JNIsharedstubs.dll) if they exist on the client’s JRE dir, so they can be re-downloaded as needed from the server again.

4. Check the library entry in webutil.cfg  (C:\Oracle\Middleware\as_1\forms\server\webutil.cfg) on the server (this should match with version on the client):

*= dll filename | filesize | library version | true/false

install.syslib.0.7.1=jacob-1.14.3-x86.dll|102400|1.14.3|true

 

« Prev: :Next »

Leave a Reply

You must be logged in to post a comment.