The challenge with today’s developers is creating multiplatform applications. Developers come from different backgrounds and need to skill themselves to create applications and deploy them in multiple target runtimes.
Enterprise Generation Language (EGL) is designed to meet these challenges, which provides a common high-level language throughout the software development lifecycle of a multiplatform application. Developers can now focus on the business problem rather than the technicalities of the target platforms to develop leading edge business applications. This blog provides an insight on how to generate Java and COBOL from EGL using Business Developer application (workbench).
Before you start to write the EGL code, you need to understand EGL projects and types of EGL projects that can be created in the application workbench. All the projects that are created and its resources are associated with a workspace. A workspace is a parent folder that groups related projects together and every development session in application workbench starts with creating or opening a workspace. There are mainly four types of projects in Business Developer workbench and are as follows:
“.eglbld” and contains build options and symbolic parameters. Build descriptor options specify how to generate and prepare EGL output, and a subset of the build descriptor options can cause other build parts to be included in the generation process. Symbolic parameters are variables that are replaced with values at generation time. EGL Deployment descriptor files has the extension “.egldd" and specify where EGL applications are to be deployed.
EGL to Java Generation in Business Developer
To create a new EGL project, navigate to New on the menu bar and click the EGL project. In the EGL Project menu, provide the Project name and select the type of EGL project to be created. Select General Project as the project type and then click Next. In this application window as shown in Figure 1, select Java as the Target runtime platform. Leave the default selection for Build descriptor options and click Finish.
Now you can see the EGL project created in Project Explorer view (Figure 2). By default, the descriptor files are created in the EGLSource folder.
Now let us create an EGL program file and write an EGL program to display a “Hello World” message.
Right-click the project and navigate to New -> Program in the context menu.
A New EGL Program window opens where you must enter the details for package and program file name. Source filename is mandatory, whereas package is optional and if not entered the program file is created in the default package.
After the details are entered, click Finish.
In the Editor view, you can view the program created with a basic template with a function main.
Enter the below statement in the main function to print the “Hello World” message in the console and press Ctrl +S to save the file.
Once the file is saved, you will notice the EGLGen/JavaSource folder. A java file is generated with the class name, which is same as the EGL file name. To run this program, right-click the java program and navigate to Run As -> Java Application in the context menu. A “Hello World” message is displayed in the Console view.
If any of the views are not visible or open, select menu bar “window” and navigate to Show view >. Here you can add the views to the workbench.
EGL to COBOL Generation in Business Developer
As you see, it is easy to create a simple Java program. Similarly, you can generate COBOL code to display the “Hello World” message using the same EGL code that was written before. To generate code for COBOL runtime, you need to create a new EGL project with COBOL as the target platform. Follow the same process to create an EGL Project, but this time select COBOL as the Target runtime platform. Once the project is created, create a new EGL program file and write the same code to print “Hello World” message in the main function. To generate COBOL code, you need to mention some options in the build descriptor like genDirectory, system, and prep options.
The generation of EGL to COBOL has two stages.
1. COBOL code is generated from EGL code
2. The generated COBOL code is sent over to host for compilation.
If the prep option is set to NO, then the first stage is executed. If the prep option is set to YES, then both the stages are executed.
Open the Build descriptor file (double-click on the “*.eglbld” file). Then select the “COBOLBuildOptions” from the Outline view (Figure 3).
The value for genDirectory is the location where the COBOL files are generated. Select system as ZOSbatch and prep as NO. If prep is selected as YES, you need to mention host details like destHost, destPassword, destPort, and destUserID.
Now, let’s generate the EGL program. Right-click the EGL project and select Generate. Once the output is generated, ensure that the “egl” files are ticked in green in the EGL Generation Results view (Figure 3). Go to the folder mentioned in the genDirectory and you can see the generated COBOL file.
Now that you have successfully generated EGL to Java and COBOL respectively, you can see how developers can leverage Business Developer application workbench using EGL as a common language to develop and deploy their business applications across various runtimes.
Sagar Ramananda Hegde
Technical Lead at HCL Software