Due to the architectural differences between PowerServer and native PB, you will not be able to use the solution in native PB (for example, use LibrayImport and AddToLibraryList) to dynamically load user-defined reports (DataWindow) from InfoMaker into PowerServer applications.
You will need to use the following workarounds to import DataWindows from InfoMaker. The main idea of the workaround is to directly create DataWindows using the DataWindow source.
Workaround #1: Save the DataWindow in InfoMaker to .PSR
After that, in PowerBuilder, assign the .PSR file to the DataWindow using dw.dataobject=’psr file name’.
Sample code:
String ls_psr_path, ls_psr_name // Select the PSR file. GetFileOpenName("Select File", ls_psr_path, ls_psr_name, "PSR", "PSR Files (*.PSR),*.PSR," + "All Files (*.*), *.*") dw_report.DataObject = ls_psr_path dw_report.SetTransObject(SQLCA) dw_report.Retrieve()
Workaround #2: Save the DataWindow in InfoMaker to .SRD
After that, in PowerBuilder, create the DataWindow with the source from the .SRD file.
Sample code:
String ls_srd_path, ls_srd_name, ls_errors, ls_dw_source Int li_filenum Long ll_bytes // Select the SRD file GetFileOpenName("Select File", ls_srd_path, ls_srd_name, "SRD", "SRD Files (*.SRD),*.SRD," + "All Files (*.*), *.*") // Open and read DW syntax li_FileNum = FileOpen (ls_srd_path, TextMode! ) ll_bytes = FileReadEx( li_filenum, ls_dw_source ) FileClose(li_filenum) // Create DW dynamically dw_report.Create( ls_dw_source, ls_errors) If Len(ls_errors) > 0 Then MessageBox ("Library Import", ls_errors) End If dw_report.SetTransObject ( SQLCA) dw_report.Retrieve ( )
Workaround #3: Use the PBL from InfoMaker
(1) Make sure the .PBL file is added as one of the PowerServer external files.
(2) In PowerBuilder, use the LibraryExport function to export the DataWindow source, and then create DataWindow with the source.
Sample code:
String ls_pbl_path, ls_pbl_name, ls_dwo_name, ls_errors, ls_dw_source // Select the PBL file GetFileOpenName("Select File", ls_pbl_path, ls_pbl_name, "PBL", "PBL Files (*.PBL),*.PBL," + "All Files (*.*), *.*") // Read DW syntax from PBL ls_dwo_name = "d_report_customer" ls_dw_source = LibraryExport(ls_pbl_path, ls_dwo_name, ExportDataWindow!) If ls_dw_source = "" Then MessageBox("LibraryExport", "Failed to find dwo: " + ls_dwo_name + " in " + ls_pbl_path + ".") Return -1 End If // Create DW dynamically dw_report.Create( ls_dw_source, ls_errors) If Len(ls_errors) > 0 Then MessageBox ("Library Import", ls_errors) End If dw_report.SetTransObject ( SQLCA) dw_report.Retrieve ( )