Can I transform UML into COBOL?
Can I create a model using Unified Modeling Language (UML) and transform it into COBOL language to be deployed into z/OS®?
I have heard this question many times during presentations of IBM® development tools around the world. A very simple answer is: Yes, today you can transform UML into COBOL code. But the point is, how much of your application can you now develop doing UML transformation to COBOL? To illustrate the ease and benefit of this development proposition, I will show you an example here of UML to COBOL transformation using IBM tools.
Model Driven Development and WebSphere Developer for System z
Model Driven Development (MDD), together with its associated UML-based tools, has been around for more than a decade now. Several advanced organizations have successfully used MDD to substantially increase their competitive edge and market share through improved productivity, quality, and time-to-market.
Studies reveal that using MDD practices can improve productivity by a factor of two to four, compared to traditional document-driven and code-centric development (see Resources).
IBM WebSphere® Developer for System z V7 has wizards to automatically generate CICS® COBOL code that accesses a DB2® database from a given UML model. These wizards transform UML into COBOL and WSDL (Web Services Definition Language), as well as generate the JCL that will help you implement the code generated. The wizard assumes that the UML model is complete. IBM Rational® Software Architect can be used to define the UML model. See this architecture in Figure 1.
The generated COBOL consists of two main programs per DB2 table, along with auxiliary COBOL programs to perform the XML parsing, and so on. The first main COBOL program performs the standard CRUD (Create, Read, Update, Delete), operations set, acting on a single record. The second main program handles the search/list operation for multiple DB2 rows.
Similar transformations could be done by WebSphere Developer for System z from existing DB2 schema, but I am focusing in the UML transformation in this article.
Figure 1. Database application generator architecture
Working with the UML model
When working with UML, the current version of WebSphere Developer for System z (Version 7.0) transformation assumes:
- Any class in the UML model is treated as a DB2 table.
- Any property of a class is treated as a column of this table.
- Other UML items, including operations and methods in the class, are ignored in the transformation.
As you see, with the current implementation, there is no way to transform the UML model into COBOL business logic; it is a very database-oriented kind of transformation. Any operation in the UML class model is ignored.
The main steps you must perform to create and deploy the assets using the wizard are:
- Export the UML model from Rational Software Architect.
- Import the UML model to WebSphere Developer for System z.
- Use the Database Application Generator wizard to edit and configure the transformation parameters.
- Run the transformation.
- Create the z/OS DB2 tables that map the UML classes.
- Deploy the code generated to z/OS CICS.
- Configure and install the CICS Web services on z/OS.
- Test the Web services created.
Figure 2 shows a UML model that I used in one transformation example.
Figure 2. UML model created by Rational Software Architect
Edit and configure the transformation parameters
After importing the UML model to WebSphere Developer for System z, you must configure the transformations using the wizards. In this example, the UML model does not possess all the necessary implementation characteristics. For example, when configuring the customer number (CUST_NO) transformation, I defined this attribute as Integer (Figure 3).
Figure 3. Using the Transformation Parameters Editor
You must also configure other details for the transformation, such as CICS, MVS, and USS.
Basically, "MVS" and "USS" are the z/OS dataset names that will be used in the JCL generated code, and USS is used by CICS Services, such as for the location where the WSBIND code will be stored in the z/OS. Figure 4 shows the configuration specified for the CICS resources that will be generated by the transformation.
Figure 4. Configuring the CICS resources
Running the transformation
In this example, the transformation generated all the assets showed in Figure 5. Note that during the transformation, if Automatic Remote Deployment is selected, and you are connected to the z/OS system, the following actions are performed:
- All .cbl files are moved to the specified target COBOL data set on the MVS system.
- All .jcl files are moved to the specified target JCL data set on the MVS system.
- The JCL is submitted to the host.
- All .wsbind files are moved to the specified WSBIND directory on the USS system
- All .wsdl files are moved to the specified WSDL directory on the USS system.
Figure 5. Assets generated by the transformation
Description of the generated assets
The transformation will generate COBOL assets (with type cbl), the WSBIND files necessary to deploy CICS Services (with type wsbind), the WSDL files (with type wsdl), the JCL (with type JCL), and log files (with type log). Here are brief descriptions of the generated assets:
- @USTCRUD.cbl: Many COBOL programs responsible for performing the Web Services Converter Driver of the CRUD COBOL application.
- @USTLIST.cbl: Many COBOL programs responsible for the Web Services Converter Driver to be used by the LIST COBOL application.
- CUSTCRUD.cbl: COBOL program that performs the CRUD operations against the z/OS DB2 table.
- CUSTCRUD.log: Log file for the CRUD application. It logs the date, the version of WebSphere Integrator for System z used, parameters used for the transformation, and so on. This file must be provided to IBM if support is needed. This file also has the hexadecimal content of the WSBIND file generated.
- CUSTCRUD.wsbind: The WSBIND file required by CICS to create the Web service for the CRUD application. This file will need to be installed in the z/OS system in the CICS Web service pickup directory.
- CUSTCRUD.wsdl: This is the Web Service Definition Language (WSDL) file that is needed later for invoking the CRUD Web service that was created. This file does not need to be moved to the z/OS system, since the XML parsing is done by the COBOL driver generated and not by CICS.
- CUSTLIST.cbl: COBOL program that performs a read on multiple rows from the table.
- CUSTLIST.log: Log file for the LIST application, similar to the content as described above for the CRUD application.
- CUSTLIST.wsbind: The WSBIND file required by CICS to create the Web service for the LIST application.
- CUSTLIST.wsdl: The WSDL that defines the LIST Web service application. It will be used later for invoking the LIST application via CICS services.
Here are brief descriptions of the generated JCL:
- ITSOBD.JCL: JCL to build the generated CRUD and LIST COBOL application programs and bind the DB2 plans and packages. This JCL will invoke the proc ITSOCB, which is also generated.
- ITSOBDDR.JCL: JCL to build the CRUD and LIST COBOL generated driver programs. This JCL will invoke the proc ITSOCBDR, which is also generated.
- ITSOCB.JCL: Procedure used by ITSOBD.JCL to:
- DB2 pre-compile or pre-process of COBOL programs with EXEC SQL statements.
- CICS pre-compile of COBOL programs with CICS statements.
- COBOL compile.
- Linkedit compiled programs.
- ITSOCBDR.JCL: Procedure used by ITSOBDDR.JCL to perform the COBOL/CICS operations to the generated driver program.
- ITSORDO.JCL: JCL to define CICS resources via Resource Definition Option (RDO).
Using the Web Services Test Explorer to invoke the LIST application
After the generated code is deployed, I used the Web Services Test Explorer component of WebSphere Developer for System z to test Web services to get instant feedback. In my example, I want to list 8 rows (Figure 6).
Figure 6. Testing the CICS Web service deployed
As you can seen, this UML to COBOL transformation does not provide all the necessary code generation from UML as you might ideally need, but it is certainly a good start, and you might save some time by generating the code that you can.
Also, notice that the wizard generates 100% COBOL without any proprietary code, subroutines, or any other framework. Even if you are not interested in deploying CICS Web services, you still can take advantage of having COBOL code that uses a DB2 table that was mapped from the UML class.
Future versions of this feature will be improved, possibly to enable you to create your own templates. IBM is always eager for feedback, so let us know your ideas or suggestions on the current implementation.
- Transform UML to COBOL with WebSphere Developer for System z, Part 1: Create COBOL programs and Web services without writing code includes a complete tutorial of this example
- An introduction to Model Driven Architecture
- Model Driven Development: Are MDD models assets or liabilities?
- Getting Started with UML
- Using model-driven development (MDD) in a mainframe environment
- WebSphere Developer for System z Version 7.0
- IBM WebSphere Application Transformation demos
Dig deeper into WebSphere on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.