Home End User

Report Explorer: Programatically Import/Export dtm

edited October 2002 in End User
With rb7/d6/Report Explorer:

I have a function that imports and exports report folders and children
to and from .rtm text files. I did this in my custom report explorer
fundamentally using the methods:

Export:
FReportExplorer.LoadReport(reportname, folderid); coupled with
FReportExplorer.Designer.Report.Template.SaveToFile;

and

Import:
FReportExplorer.Designer.Report.Template.LoadFromFile coupled with
FReportExplorer.SaveReport(reportname, folderid);


This worked well but I now also want to save and load datamodules and
codemodules (standalone rows in rb_items of type itData and itCode).
I have tried it with export of itData and it isn't working - I get an
empty report for the dtm. To get it that far I added
FReportExplorer.Designer.Report.Template.FileExtension := 'dtm';

How should I be doing this? and is there a code example available?

Many thanks,

Rick Matthews
Dartek Systems Inc.

Comments

  • edited October 2002
    Here is a simple example:

    http://www.digital-metaphors.com/tips/ReplaceDatamodule.zip


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited October 2002
    Thanks Jim,

    I had seen that but I am unclear how to deal with loading/saving the
    dtm when you use the report explorer. I think I not have been clear
    (or I am missing the obvious).

    I am not trying to load anything or replace anything into a report.

    I merely want to be able to select a report folder in the report
    explorer and save all templates (reports, data and code) to a disk
    folder as *.rtm, *.dtm and *.ctm files. Following that I want to load
    these disk files back into a (specified) report explorer folder. The
    designer is not part of this process.

    I am trying to automate the menu functions available in the designer
    of load from file and save to file for reports, datamodules (but not
    code modules I see).

    This is a method of backing up reports as well as loading reports (and
    data and code items) into a different report explorer database.

    Thanks,

  • edited October 2002
    You could use a custom report explorer form which adds the UI for this
    action. Ther eius an example in the Developer'sGuide, near the end. If you
    want to backup every report in a selected folder, then create a new query
    which returns all the records for that folder ID from the rbItem table.
    Then you can iterate through these records, loading the templates from
    database using the Report.Template.LoadFromDatabase method (see the
    Template's DataBaseSettings property to control the report that you want to
    load). Then you can saved the loaded template anywhere that you want, to
    file or database to a new folder. You'll have to set the folder ID of the
    new template record and configure all of the item fields correctly, such as
    the item type which is an integer field. See the help file on
    TppReportExplorer.ItemPipeline
    for a listing of the different item values that shoudl be set. You might
    have to build into the item record structure the folderId that it should
    restore itself to, of you can place it in a lookup table so that when you
    save down the new records, you save the info that is necessary to place the
    item back into the original folder.

    You can load the full report template, then breakout the datamodule that get
    loaded inside of the main template if you want to separate them, using the
    Datamodule.Template method sin the tip I posted for you earlier.

    See our tech-tips newsgroup for information on templates and using template
    events for further good information. By using template event, you


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.