Omnis Technical Note TNPR0009 December 2007

Storing Report Job Setup Parameters

For Omnis Studio 4
By Dr. Michael Hufschmidt


Omnis Studio includes a very powerful report generator which allows you to create many different database reports, including labels using data from an address database and a suitable report class. Many settings are stored in the report class including page format, page borders or label sizes but the Job Setup is not stored - this allows the user to select the printer, paper tray, and so on.

Job setup

However you may want to enable users to be able to save the print job settings as well, so they can always use the same paper tray for label printings and to start printing directly, without a Job Setup dialog being displayed.


With a little trick (originally worked out by my colleague Andreas Pfeiffer) it is possible in Omnis to call the Job Setup dialog from within your application, to store the setup files and to reuse them for printing other reports.

How to create and store Job Setup data

There is no 4GL command to directly call the job setup dialog. However, a "Modify Report" field has a suitable method you can use. To do this, create a window and drag the "Modify Report" field from the Component Store onto your window.

Modify report field

The user does not need to see this field, therefore you can set its $visible property to kFalse. Enter a meaningful name for this field, such as "ModifyReport".

Job Setup data can only be stored in a report class or in a report instance. For this you need to use a dummy report which contains no other methods or fields. Create a new report class called "rDummy" - you can assign its name to the Modify Report field at runtime in your code. You can call the Job Setup dialog in this window by sending the message $pagesetup() to this field. The complete code to create and store Job Setup files should now be:

Do $cinst.$objs.ModifyReport.$classname.$assign('rDummy')
Do $cinst.$objs.ModifyReport.$pagesetup() ;; Open Job Setup Dialog
Save class {rDummy}

You can insert this code in the $event method of a pushbutton in this window. When the user clicks on this button the simplified job setup dialog will appear:

Job setup

When this dialog is confirmed with OK the job setup data is stored in the class rDummy.

Using stored job setup data

In order to send any report (in this case "rTest") to the printer using your previously stored job setup data, first set the $pagesetupdata property of this report equal to the appropriate property of the dummy report and print the required report. The code looks like this:

Do $cdevice.$assign(kDevPrinter)
Do $reports.rTest.$pagesetupdata.$assign($reports.rDummy.$pagesetupdata)
Do $reports.rTest.$open('*',Param1,param2)

Storing in binary variables

If you want to use several different job setups you can create several different dummy reports and use those as above. Alternatively, you can store different job setups in different binary variables which can be stored either in binary files or as BLOBs in a database. Assuming "setupData" is a variable of Binary type, the code to fill the binary variables would look like this:

Do $cinst.$objs.ModifyReport.$classname.$assign('rDummy')
Do $cinst.$objs.ModifyReport.$pagesetup() ;; Open Job Setup dialog
Calculate setupData as $clib.$reports.rDummy.$classdata

And the code to use this data would be:

Do $reports.rDummy.$classdata.$assign(setupData)
Do $cdevice.$assign(kDevPrinter)
Do $reports.rTest.$pagesetupdata.$assign($reports.rDummy.$pagesetupdata)
Do $reports.rTest.$open('*',param1,param2)

Note that such binary variables only contain about 7k of data so do not take up much space in your database.

Search Omnis Developer Resources


Hit enter to search