Oracle Application Express Forms Converter — Save 50%
Convert your Oracle Forms applications to Oracle APEX successfully using this book and eBook
In this article by Douwe Pieter Van Den Bos, we will see what we need to get things ready for our Forms Conversion project. We need to gather all our original Forms, Reports, Menus, and Libraries so that we can generate the APEX project. We will need to get the XML sources by using the tools in the Oracle Developer Suite. Of course, we will learn to understand these newly created sources and what they mean to us. Before we can create our APEX applications using the Forms Conversion tool, it would be nice to design and implement the target database.
When we are participating in a Forms Conversion project, it means we take the source files of our application, turn them into XML files, and upload them into the Forms Conversion part of APEX. This article describes what we do before uploading the XML files and starting our actual Forms Conversion project.
Get your stuff!
When we talk about source files, it would come in very handy if we got all the right versions of these files. In order to do the Conversion project, we need the same components that are used in the production environment. For these components, we have to get the source files of the components we want to convert. This means we have no use of the runtime files (Oracle Forms runtime files have the FMX extension). In other words, for Forms components we don't need the FMX files, but the FMB source files.
These are a few ground rules we have to take into account:
- We need to make sure that there's no more development on the components we are about to use in our Conversion project. This is because we are now going to freeze our sources and new developments won't be taken into the Conversion project at all. So there will be no changes in our project.
- Put all the source files in a safe place. In other words, copy the latest version of your files into a new directory to which only you, and perhaps your teammates, have access.
- If the development team of your organization is using Oracle Designer for the development of its applications, it would be a good idea to generate all the modules from scratch. You would like to use the source on which the runtime files were created only if there are post-generation adjustments to be made in the modules.
We need the following files for our Conversion project:
- Forms Modules: With the FMB extension
- Object Libraries: With the OLB extension
- Forms Menus: With the MMB extension
- PL/SQL Libraries: With the PLL extension
- Report Files: With the RDF, REX, or JSP extensions
When we take these source files, we will be able to create all the necessary XML files that we need for the Forms Conversion project.
Creating XML files
To create XML files, we need three parts of the Oracle Developer Suite. All of these parts come with a normal 10g or 9i installation of the Developer Suite. These three parts are the Forms Builder, the Reports Builder, and the Forms2XML conversion tool. The Forms2XML conversion tool is the most extensive to understand and is used to create XML files from Form modules, Object Libraries, and Forms Menus. So, we will first discuss the possibilities of this tool.
The Forms2XML conversion tool
This tool can be used both from the command line as well as a Java applet. As the command line gives us all the possibilities we need and is as easy as a Java applet, we will only use the command-line possibilities. The frmf2xml command comes with some options. The following syntax is used while converting the Forms Modules, the Object Libraries, and the Forms Menus to an XML structure:
frmf2xml [option] file [file]
In other words, we follow these steps:
- We first type frmf2xml.
- Alternatively, we give one of the options with it.
- We tell the command which file we want to convert, and we have the option to address more than one file for the conversion to XML.
We probably want to give the OVERWRITE=YES option with our command. This property ensures that the newly created XML file will overwrite the one with the same name in the directory where we are working. If another file with the same name already exists in this directory and we don't give the OVERWRITE option the value YES (the default is NO), the file will not be generated, as we see in the following screenshot:
If there are any images used in modules (Forms or Object Libraries), the Forms2XML tool will refer to the image in the XML file created, and that file will create a TIF file of the image in the directory.
The XML files that are created will be stored in the same directory from which we call the command. It will use the following syntax for the name of the XML file:
- formname.fmb will become formname_fmb.xml
- libraryname.olb will become libraryname_olb.xml
- menuname.mmb will become menuname_mmb.xml
To convert the .FMB, OLB and, MMB files to XML, we need to do the following steps in the command prompt:
The following steps are done in order to convert the .FMB file to XML:
- We will change the working directory to the directory that has the FMB file. In my example, I have stored all the files in a directory called summit directly under the C drive, like this:
- Now, we can call the frmf2xml command to convert one of our Forms Modules to an XML file. In this example, we convert the orders.fmb module:
C:summit>frmf2xml OVERWRITE=YES orders.fmb
As we see in the following screenshot, this command creates an XML file called orders_fmb.xml in the working directory:
To convert the .OLB file to XML, the following steps are needed:
- We first change the working directory to the directory that the OLB file is in. It's done like this:
- Now we can call the frmf2xml command to convert one of our Object Libraries to an XML file. In this example, we convert the Form_Builder_II.olb library as follows:
C:summit>frmf2xml OVERWRITE=YES Form_Builder_II.olb
As we see in the following screenshot, the command creates an XML file calledForm_Builder_II_olb.xml and two images as .tif files in the working directory:
To convert the MMB file to XML, we follow these steps:
- We change the working directory to the directory that the .MMB file is in, like this:
- Now we can call the frmf2xml command to convert one of our Forms Menus to an XML file. In this example we convert the customers.mmb menu:
C:summit>frmf2xml OVERWRITE=YES customers.mmb
As we can see in the following screenshot, the command creates an XML file called customers_mmb.xml in the working directory:
In our example, we will convert the Customers Report from a RDF file to an XML file. To do this, we follow the steps given here:
- We need to open the Employees.rdf file with Reports Builder.
- Open Reports Builder from your Start menu. If Reports Builder is opened, we need to cancel the wizard that asks us if we want to create a new report.
- After this we use Ctrl+O to open the Report File (or in the menu, File | Open) which we want to convert to XML as we see in the following screenshot:
After this we use Shift+Ctrl+S (or in the File | Save As menu) to save the Report. We choose that we want to save the report as a Reports XML (*.xml) file and we click on the Save button as shown in the following screenshot:
To convert PL/SQL Libraries to an XML format, it's easiest to use the convert command that comes with the Report Builder. With this command called rwconverter, we define the source type, call the source, and define the destination type and the destination. In this way, we have control over the way we need to convert the original .pll file to a .pld flat file that we can upload into the APEX Forms converter. It is possible to convert the PL/SQL Libraries with the convert option in Forms Builder, but, personally, I think this option works better. The rwconverter command has a few parameters we give with it to execute. They are given as follows:
- stype: This is the type of source file we need to convert. In our situation, this will be a .pll file and so the value we need to set is pllfile.
- source: This is the name of the source file, including the extension. In our case, it is wizard.pll.
- dtype: This is the file type we want to convert our source file to. In our case, it is a .pld file and so the value becomes pldfile.
- dest: This is the name, including the extension, of the destination file. In our case, it is wizard.pld.
In our example, we use the wizard.pll file that's in our summit files directory. This PL/SQL Library that contains .pll files is normally used to create a PL/SQL Library in the Oracle Database. But this time, we will use it to create a .pld flat file that we will upload to APEX.
First, we change the directory to work directory which has the original .pll file. In our case, the summit directory directly under the C drive, shown as follows:
After this, we call rwconverter in the command prompt as shown here:
C:summit> rwconverter stype=pllfile source=wizard.pll dtype=pldfile dest=wizard.pld
When you press the Enter key, a screen will open that is used to do the conversion. We will see that the types and names of the files are the same as we entered them in the command line. We need to click on the OK button to convert the file from .pll to .pld.
The conversion may take a few seconds, but when the file has been converted we will see a confirmation that the conversion was successful. After this, we can look in the C:summit directory and we will see that a file wizard.pld is created.
|Convert your Oracle Forms applications to Oracle APEX successfully using this book and eBook|
eBook Price: $23.99
Book Price: $39.99
If we take a look inside the XML files we just created, we will notice a few things. I use SQL Developer of Oracle to look inside the XML files we just created. It's a free tool that we will need for several other tasks during our Conversion project and it does the job. But, of course, you can use a different XML editor to examine the XML files.
When we open SQL Developer, we can open the files we created earlier. The forms, menus, reports, and libraries are now all in XML or flat files. To open the files in SQL Developer, just click on file and then click on Open (or use the keyboard shortcuts Ctrl+O). Select the file you want to open from the dialog box that's shown in the following screenshot:
First, we take a look at the Forms Modules in the _fmb.xml files. As you can see, there's a lot of information there. But if we take a further look, we'll see that it's not new information. I will not discuss all of the information that's in the XML files here.
The following screenshot lets us see the contents of the orders_fmb.xml file that we created earlier. It shows us the name of the Forms Module (ORDERS), the Alerts, the Blocks, and much more.
If we take a closer look at one of the blocks in the XML file, for example the Items block, we can look for some of the information that APEX uses in the conversion. We can see the names of the Items used in this block. We can also look at the queries that are used in this data block and triggers.
Now, let's take a look at one of our Menu Modules, customers_mmb.xml. Because we can't convert a menu in a Forms to APEX conversion project, the information in here isn't that interesting. During conversion, we will create some horizontally oriented images that can be used as a menu. But the information held in the MenuItem Name tags is interesting to us. You will encounter a few names here that point to a certain form in our application. These names will be used in our conversion project.
In the XML that we created from our Oracle Reports application, we see a lot of information such as how the report is built, what font is used, some layout information about the building blocks of the reports page, and so on. But none of this information is useful for us. The only thing we need is the query. As we can see in the following screenshot, Employees.xml is a fairly big file:
The SQL query we're interested in is set in the select tags in this XML file. When we upload the file to the APEX conversion tool, we will use only this information:
The last things we will discuss in this section are the PL/SQL Libraries. In the following screenshot, we opened the wizard.pld file that we created earlier. As we can see, it's just a definition of the Wizard Package and Package body. To understand this function, it will be useful to look into this code:
The target database
In order to convert your Forms applications to APEX, we also need the database model on our target area. Using Oracle's SQL Developer, we will be able to do both an export and an import on the database of the database objects we need in our application. The import is also possible in APEX using the SQL Workshop that is a part of APEX.
First, we will create the .sql file, which contains the database objects we need in the application. In SQL Developer we select the objects, in our case the tables, from S_CUSTOMER to S_WAREHOUSE. When we have selected all the objects, we right-click and select Export DLL and then click on Save to File, as shown in the following screenshot:
To save the file that contains the code to create the selected database objects, we select the directory where we want to save it, give it an appropriate name, and then click on the Select button. After this, the DLL script will be created and saved in the directory we have chosen.
When we get the DLL script of our database objects, we will implement it on our target database. This can be done by using both Oracle SQL Developer and APEX.
First, we will do it in SQL Developer because we will be able to connect this IDE to any database we are connected to, and this works pretty easy with the appropriate user credentials.
We have to open the file we just created. Click on File | Open (or use the keyboard shortcut Ctrl+O). This opens a dialog box in which we can select the file, as shown in the following screenshot:
The file will open in a separate worksheet in SQL Developer. Now we can see the statements that create the database objects for which we created the DLL file. At this point, we want to run the script on the target database schema. In the following screenshot, we see the script in SQL Developer.
By pressing F5 on our keyboard, or by going to Run in the menu and clicking on Run exportsource_dll.sql, we will run this script:
Before the actual run of the script, we need to select a connection on which the script must run. In this example, we will run the script on the OMB database schema that I have saved in my SQL Developer preferences. To learn more about the possibilities SQL Developer offers, it would be smart to read the SQL Developer user guide. After selecting the correct connection, we click on OK and the script will run on the selected database schema using the username and password settings we saved. Look at the next screenshot:
It's also possible to run the script in APEX. This might come in handy if we don't have a connection saved in our SQL Developer settings, or we just don't have the database connection on our computer.
In APEX, we first go to the place where we can control our database objects, which is the SQL Workshop. In the SQL Workshop, we see a section called SQL Scripts. In this section of APEX, we can upload, create, save, edit, and run our .sql scripts.
In the SQL Scripts section of SQL Workshop, we have the possibility to upload our script. Click on the Upload button shown at the righthand side in the following screenshot. When we have done this, we browse to the file we created in SQL Developer and give it an appropriate name. In this example, we call it exportsource. Now we can upload the file. Click on the Upload button to upload the file and we are redirected to the SQL Scripts section of APEX.
Now, we want to run the script. Click on the script we just created in the SQL Scripts section. In this example, we click on the icon that is named exportsource. This will take us to the page shown in the following screenshot:
On the righthand side of this screen, there is a button called Run. Click on this and the script will run on the same database schema we are connected to as the APEX user.
We can repeat all the steps we took to implement the tables on a target database in order to implement other database objects such as views, procedures, packages, and more.
In this article, we learned everything we need to do to get ready for our Forms to APEX conversion project. Here are the necessary steps we went through before we started:
- We have seen what files we need. These are the .FMB (Forms Modules), .OLB (Object Libraries), .MMB (Menu Modules), .PLL (PL/SQL Libraries), and RDF, REX, or JSP (Reports) files.
- We have used the Forms2XML conversion tool—the rwconverter—and the Reports Builder in Oracle Developer Suite to create the right files that we need for the APEX conversion project. We have used Forms2XML in the command line to convert Forms Modules, Object Libraries, and Menu Modules to XML files. We have seen how to use the Reports Builder to save a Reports File as an XML File. We have also seen how the rwconverter command is used to create a flat file in the PL/SQL Library.
- Using SQL Developer, we have seen what data is contained in the XML files that we created. The XML files contained the same information that we have seen in the Forms and Reports Builder, but is now structured within XML tags.
- We have done an export of our database objects from the SQL Developer, and have implemented these database objects in our target database using the SQL Developer and the Application Express.
|Convert your Oracle Forms applications to Oracle APEX successfully using this book and eBook|
eBook Price: $23.99
Book Price: $39.99
About the Author :
Douwe Pieter van den Bos started working as an Oracle Developer using Oracle Designer and Oracle Forms. Soon he discovered the wondrous world of Oracle Application Express and was one of the first people in the Netherlands to be using this tool in real live applications. His first encounters with the development of APEX applications and, later on, his thoughts on web development and project management were written down on his own personal website, http://ome-b.nl. This web site became the only Dutch APEX related website and a knowledge base on everything APEX.