foreach Examples Distribution XML File Examples

20-22 Publishing Reports to the Web with Oracle Reports Services

20.5.2.4 E-Mail with External File as Body and Report as Attachment

The contents of the body for this email will be an external file, and the report will go along as an attachment. The path to the file is expressed differently for Windows and UNIX.

20.5.2.4.1 Windows

mail id=XQRSN to=accountingmycompany.com subject=Salaries body srcType=file include src=c:\mail\body.html body attach format=pdf name=salaries.pdf srcType=report include src=report attach mail

20.5.2.4.2 UNIX

mail id=XQRSN to=accountingmycompany.com subject=Salaries body srcType=file include src=mailbody.html body attach format=pdf name=salaries.pdf srcType=report include src=report attach mail

20.5.2.5 E-Mail with Whole Report and Grouped Sections Attached

In this example, recipients receive one e-mail with multiple attachments: one attachment for each group instance and an additional attachment that contains the entire report. If the report is grouped on department_id and there are four departments, recipients will receive five attachments: one for each department and one whole report. mail id=grx90 to=salesmycompany.com body srcType=textAttached you will find the summary report and breakdown by department of weekly totals. body attach format=rtf name=myAttach.rtf srcType=report include src=report attach foreach attach format=pdf name=myattach.pdf srcType=report instance=this include src=mainSection attach foreach mail

20.5.2.6 E-Mail to Relevant Manager and Department

In this example, the manager for department 10 gets department 10s report; the manager for department 20 gets department 20s report; and so on. For this tag set to be valid, the variable must refer to a column that is included in the repeat on group used with the attached section. That is, if the section repeats on G_department_id, manager must be a column in that group. foreach mail id=mgr1090 to=amp;lt;managergt;mycompany.com attach format=pdf name=attach.pdf srcType=report instance=this include src=mainSection Creating Advanced Distributions 20-23 attach mail foreach Oracle Reports 11g Release 1 11.1.1 supports PDF encryption in distribution and bursting of reports. With this feature, you can secure Reports output through PDF Security in the following way: foreach mail id=mgr1090 to=amp;lt;managergt;mycompany.com property name=pdfuser value=amp;lt;managergt; attach format=pdf name=attach.pdf srcType=report instance=this include src=mainSection attach mail foreach

20.5.3 file Examples

Whenever you burst and distribute grouped reports to files, be sure to specify filenames with variable values based on the repeating group or some other variable information. Otherwise, you run the risk of having each successive file that is created overwrite the previously created file. For example, if you specify an output filename of department.pdf, and you output separate instances of each departments report, the second department.pdf file will overwrite the first department.pdf file; the third will overwrite the second, and so on. You will end up with only one report, that of the final department. Instead, with grouped reports that you want to output separately according to each group instance, use variable values to specify filenames, for example: name=department_amp;lt;department_idgt;.pdf. The examples in this section include: ■ File for Whole Report ■ File for Combined Report Sections ■ File for Each Group of Combined Sections ■ File for Each Report Group Instance

20.5.3.1 File for Whole Report

This example will yield one file named report.pdf that contains the entire report.

20.5.3.1.1 Windows

file id=a1 name=c:\reports\report.pdf format=pdf include src=report file

20.5.3.1.2 UNIX

file id=a1 name=reportsreport.pdf format=pdf include src=report file

20.5.3.2 File for Combined Report Sections

This example will yield one file named sections.pdf that contains a report consisting of the header section and the main section of the report. file id=a2 name=sections.pdf format=pdf 20-24 Publishing Reports to the Web with Oracle Reports Services include src=headerSection include scr=mainSection file

20.5.3.3 File for Each Group of Combined Sections

In this example, a separate file will be created for each repeating group. Each file will contain a report that combines the relevant group main and trailer sections. The main and trailer sections must repeat on the same group, and the variable file name must refer to a column contained within the repeat on group. That is, if the report repeats on department_id, and you have four departments, 10 through 40, then one file will contain the main and trailer sections of department 10, the next will contain the main and trailer sections of department 20, and so on. The variable value under name must refer to a column that is within the G_department_id group. foreach file id=file9 name=department_amp;lt;department_idgt;.pdf instance=this include src=mainSection include src=trailerSection file foreach

20.5.3.4 File for Each Report Group Instance

In this example, assuming the report is grouped on department_id and there are four departments, 10 through 40, you will end up with four files respectively named: department_10.pdf, department_20.pdf, department_30.pdf, and department_40.pdf. foreach file id=a20 name=department_amp;lt;department_idgt;.pdf instance=this include src=report file foreach

20.5.4 printer Examples

The examples in this section include: ■ Print Whole Report ■ Print Two Sections of a Report ■ Print Grouped Report ■ Print Combined Sections for Each Group Instance ■ Print Relevant Instance of a Report to Its Relevant Printer The way printer names are specified, differs between Windows and UNIX. Each example demonstrates both ways.

20.5.4.1 Print Whole Report

In this example, the entire report will be sent to the specified printer.

20.5.4.1.1 Windows

printer id=a80 name=\\neptune\prtr20 include src=report printer Creating Advanced Distributions 20-25

20.5.4.1.2 UNIX

printer id=a80 name=10th_floor_printer include src=report printer

20.5.4.2 Print Two Sections of a Report

In this example, two sections of a report will be sent to the printer.

20.5.4.2.1 Windows

printer id=a1 name=\\neptune\prtr20 include src=headerSection include src=mainSection printer

20.5.4.2.2 UNIX

printer id=a1 name=10th_floor_printer include src=headerSection include src=mainSection printer

20.5.4.3 Print Grouped Report

In this example, one report will be printed. The report will be grouped by, for example, department_id. For this to work, all sections of the report must repeat on the same group.

20.5.4.3.1 Windows

foreach printer id=prt20 name=\\neptune\prtr20 instance=all include src=report printer foreach

20.5.4.3.2 UNIX

foreach printer id=prt20 name=10th_floor_printer instance=all include src=report printer foreach

20.5.4.4 Print Combined Sections for Each Group Instance

This example will yield a number of print jobs: one for each group instance. The combined sections must repeat on the same group. If the report repeats on department_id, and you have four departments, 10 through 40, you will end up with four print jobs: one for department 10; one for department 20; and so on. The main and trailer sections must both repeat on department_id.

20.5.4.4.1 Windows

foreach printer id=prt20 name=\\neptune\prtr20 instance=this include src=mainSection include src=trailerSection printer foreach