In this article, I show you that how we can generate PDF File from oracle forms using command line keywords. For this, we need to understand what are command line keywords and their purpose. I already posted detail information about command line keyword click to view the page. Also view, what is rwrun and how it works?
Now first create simple report based on EMP table with DEPT parameter in order to filter report department-wise.
Now create module with control block "B" having one list item :DEPT, one text item :FNAME, one button to view report PB_VU_REP and one button for generating report in PDF format PB_GEN_REPORT.
As mentioned in below images.
Now create record group in order to populate Department list.
For e.g.
SELECT DNAME||' - '||TO_CHAR(DEPTNO),TO_CHAR(DEPTNO) FROM DEPT
After creating record group, create a new trigger on form level to populate the list.
DECLARE
LST NUMBER:=0;
BEGIN
LST := POPULATE_GROUP('DEPTS');
CLEAR_LIST('B.DEPT');
POPULATE_LIST('B.DEPT', 'DEPTS');
END;
Now create trigger WHEN-BUTTON-PRESSED on view report button.
If :B.Dept is Null Then
Message('Please select department from list');
Message('Please select department from list');
Raise Form_Trigger_Failure;
End If;
WEB.SHOW_DOCUMENT ('http://localhost/reports/rwservlet?destype=cache&desformat=pdf'
||'&userid=SCOTT/TIGER@DBWARE'
||'&report=D:\SAMPLE\SAMPLE.RDF&DEPT='||:B.DEPT);
Now create trigger WHEN-BUTTON-PRESSED on generate report button.
If :B.Dept is Null Then
Message('Please select department from list');
Message('Please select department from list');
Raise Form_Trigger_Failure;
End If;
If :B.FName is Null Then
Message('Please mention file name');
Message('Please mention file name');
Raise Form_Trigger_Failure;
End If;
host('rwrun server=<your_report_server> report=D:\Sample\Sample.rdf userid=scott/tiger@dbware desformat=pdf DESTYPE=file DESNAME=D:\Sample\'||:B.FName||'.pdf dept='||:B.Dept);
If Not Form_success then
Message('Error- '||Error_Text);
Message('Error- '||Error_Text);
Raise Form_Trigger_Failure;
Else
Message('Report Created on D:\Sample\'||:B.FName);
Message('Report Created on D:\Sample\'||:B.FName);
End If;
Now compile and run the module.
Click to download complete sample package.
Note:
1) Sample package coding is set on D:\ drive. If you are using it, must be extracted in D:\ drive
2) Change report server name in generate report's button trigger.
Now first create simple report based on EMP table with DEPT parameter in order to filter report department-wise.
Now create module with control block "B" having one list item :DEPT, one text item :FNAME, one button to view report PB_VU_REP and one button for generating report in PDF format PB_GEN_REPORT.
As mentioned in below images.
Now create record group in order to populate Department list.
For e.g.
SELECT DNAME||' - '||TO_CHAR(DEPTNO),TO_CHAR(DEPTNO) FROM DEPT
After creating record group, create a new trigger on form level to populate the list.
DECLARE
LST NUMBER:=0;
BEGIN
LST := POPULATE_GROUP('DEPTS');
CLEAR_LIST('B.DEPT');
POPULATE_LIST('B.DEPT', 'DEPTS');
END;
Now create trigger WHEN-BUTTON-PRESSED on view report button.
If :B.Dept is Null Then
Message('Please select department from list');
Message('Please select department from list');
Raise Form_Trigger_Failure;
End If;
WEB.SHOW_DOCUMENT ('http://localhost/reports/rwservlet?destype=cache&desformat=pdf'
||'&userid=SCOTT/TIGER@DBWARE'
||'&report=D:\SAMPLE\SAMPLE.RDF&DEPT='||:B.DEPT);
Now create trigger WHEN-BUTTON-PRESSED on generate report button.
If :B.Dept is Null Then
Message('Please select department from list');
Message('Please select department from list');
Raise Form_Trigger_Failure;
End If;
If :B.FName is Null Then
Message('Please mention file name');
Message('Please mention file name');
Raise Form_Trigger_Failure;
End If;
host('rwrun server=<your_report_server> report=D:\Sample\Sample.rdf userid=scott/tiger@dbware desformat=pdf DESTYPE=file DESNAME=D:\Sample\'||:B.FName||'.pdf dept='||:B.Dept);
If Not Form_success then
Message('Error- '||Error_Text);
Message('Error- '||Error_Text);
Raise Form_Trigger_Failure;
Else
Message('Report Created on D:\Sample\'||:B.FName);
Message('Report Created on D:\Sample\'||:B.FName);
End If;
Now compile and run the module.
Click to download complete sample package.
Note:
1) Sample package coding is set on D:\ drive. If you are using it, must be extracted in D:\ drive
2) Change report server name in generate report's button trigger.
2 comments:
Thank you Sir for this valuable post.
Please could you post any real example on how call report from Oracle Forms 10g / 11g using
RUN_REPORT_OBJECT to pass user parameter list and also to pass the username / password @ connect_string (please hide username / password @ connect_string ) and also use WEB.SHOW_DOCUMENT to show output to end-user.
https://hasanjawaid.blogspot.com/2017/04/hide-encrypt-username-and-password.html
Post a Comment