Export PowerBuilder Library to Source Code - Oracle to SQL Server Migration

A PowerBuilder library (.pbl file) is a binary file containing PowerBuilder objects such as DataWindows and functions.

Although you can browse all objects in PowerBuilder, and edit the source code when you convert the application from Oracle to SQL Server, it is useful to export a libary to source code and then use a tool to automate the conversion.

For example, you can use SQLExtract tool to extract all SQL statements from PowerBuilder source code for assessment, analysis, or conversion.

A PowerBuilder library contains PowerBuilder objects that exported to the following files:

  • .sra - Application Object (The entry point to the application)
  • .srd - DataWindow Object (Retrieves, represents and modifies data in the database)
  • .srw - Window Object
  • .sru - User Object
  • .srm - Menu Object (List of commands and handlers)
  • .srf - Function Object
  • .srs - Structure Object (Structure definition)
  • .srq - Query Object

How to Export a Library

Open a workspace in PowerBuilder IDE, select a library, then select an object and right-click Export option:

Then Save dialog appears that shows the file name and file extension. For example, when exporting the application object:

You have to repeat this operation for each object in all libraries.

Export Using Library Painter

You can use Library Painter to speed up export a little bit. It still requires confirmation to save each object, but at least now you can select all objects within a library and click single Export.

Go to Tools → Library Painter, select a libary on disk, select all object in the library, and right-click Export:

Write PowerScript to Export Library

You can also write a PowerScript program to automate export of objects from a library (.pbl file). PowerBuilder provides LibraryExport and FileWrite functions.

For example, to export the DataWindow object d_countries from pb_demo1.pbl library, and save it to d_countries.srd file, you can use the following script:

   String ls_dw
   Integer li_FileNum
 
   // Export the DataWindow object to string
   ls_dw = LibraryExport("d:\demo\pb_demo1.pbl", "d_countries", ExportDataWindow!)
 
   // Save to the file
   li_FileNum = FileOpen("d:\export\pb_demo1\d_countries.srd", TextMode!, Write!, LockWrite!, Replace!)
   FileWrite(li_FileNum, ls_dw)

Additionally, you can use LibraryDirectory function to get a list of the objects in a PowerBuilder library, and then call LibraryExport for each object.

Resources

Resources to assist you with Oracle to SQL Server migration for PowerBuilder applications:

SQLines Services

SQLines offers services to convert PowerBuilder applications from Oracle to Microsoft SQL Server. For more information, please Contact Us.

You could leave a comment if you were logged in.