+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

HOWTO: Storing Report Definitions in a Database

(combit Team) #1
Valid from List & Label 7
The following article describes how to proceed when report definitions shall not be saved to a file but stored to a database.

Basically, List & Label always uses a file to read or write the report information. This report filename is being passed to the corresponding methods responsible for invoking the Designer to create / modify reports and to the methods responsible for performing the printout. Two examples are LlDefineLayout() and LlPrintWithBoxStart().

Hint for using the .NET Component:
Since version 16 of List & Label you can use Stream-Objects for the methods '.Design()' and '.Print()' to use report definitions. While design-time the menu items 'File > New', 'File > Open' and 'File > Save As' become automatically deactivated. Therefore no additional calls of ProhibitAction are necessary. And if you are using the DOM-API, you also can use Stream-Objects. With this feature it is no more necessary to temporarly buffer report definitions from database into the file system. Additional information can be found in the installed .NET Help.

Thus, if we want a report definition to be retrieved from a database then we'll have to create a temporary file in which we store the report information (being read from a BLOB or MEMO field).

This means that your application first has to offer all available reports in a list and let the end-users choose which one they want to modify. Let's call this dialog "report selection dialog". After that your application creates a temporary file with the selected report contents.

Now we have to avoid that the Designer displays that temporary filename in its titlebar (what would not only be irritating but also look quite unprofessional). This can be achieved by 'OR'ing the project type parameter of LlDefineLayout() with LL_NONAMEINTITLE.

Additionally we have to avoid that the end-user can use the menu items 'Open', 'New' and 'Save as' because this would cause the design results not to be stored to our temoporary file.

This can be done by hiding the menu items using LlDesignerProhibitAction() before starting the Designer:
LlDesignerProhibitAction(hJob, 524);
LlDesignerProhibitAction(hJob, 519);
LlDesignerProhibitAction(hJob, 515);
LlDefineLayout(hJob, hWnd, "Designer", LL_PROJECT_LIST | LL_NONAMEINTITLE , szTempFile);

When the Designer has been closed we just have to collect the temporary file and transfer its contents to our database and delete the file afterwards. That’s it.

You also could allow the creation of new reports:

The “report selection dialog” gets an additional “New Report” item in its list. When chosen, your application creates a temporary, not existing filename (without creating the file itself) and uses the code shown above.

If the end-users shall be able to create new reports using existing ones as a template then you could add a “New Report from Template…” item.

Hint: The Designer automatically stores the filename of the last saved report file to the registry key HKEY_CURRENT_USER\Software\combit\cmbtll<modulename>\LastFile (where corresponds to your application’s module name). This could be quite useful when you want to allow the end-users to ‘Save as’ but you want to process this file afterwards.

IDKBTE000593 KBTE000593