The operation of a program contains input and output parameters
based on classes defined in the model. These parameters are appropriate
to identify the external data manipulated by the program. The COBOL
profile creates a resource stereotype to identify resources
manipulated by a program, such as a file, a message queue, or a relational
table. In order to define a resource, you need to create a dedicated
resource class that references a root Data Object to define the data
of the resource.
The relationship between the Resource class and the DataObject
class shows that the Resource class's contents is defined by the Data
Object. This relationship is captured by a Stereotype. After the Resource
class is defined and connected to the appropriate DataObject, the
input and output parameters can target this resource class instead
of the DataObject class. You can define the model to manipulate resources
through a parameter which type is a Resource stereotyped class. You
can define the model to manipulate linkage data through a parameter
which type is a DataObject stereotyped class. To set a program to
manipulate the resource, complete the following steps:
- Create a resource class that reference the DataObject that will
be manipulated by the resource.
- Reference the DataObject from the resource.
- Apply the ResourceIsStructured stereotype
to the relationship.
- Change the operation parameter so that its type targets the Resource
class and not the DataObject class. If an operation has a parameter
whose type is directly on DataObject, the generation assumes that
it is a data definition to be used in the linkage section.
In order to automate this process, a Rational® Software Architect pattern is provided
that does these steps automatically. To enhance the diagram, complete
the following steps:
- From the Workbench, click , and then select the Pattern Explorer view. The Pattern Explorer view opens.
- Select the COBOL program pattern
under UML to COBOL.
- From the Pattern Explorer view, drag the COBOL program
to the diagram.
The first parameter of the pattern is the operation that
you want to process. Drag the operation of the
COBOL_Programs class
that you want to transform into a program. The pattern now automatically
performs changes against the parameters of the operation. All its
parameters are modified and resources are created. You can then specify
which Data Object you want to use in this program as linkage section
in the second parameter. The changes are directly visible on the operation
parameters. To see the newly created Resources in your diagram, drag
the resource classes from the Project Explorer to the diagram.
Note: It is a good practice to create several diagrams that
can display subsets of your models; for example, a separate diagram
dedicated to the program, one to its resources, and one to the root
definition.
There is also a File stereotype available that
you can apply in addition to the ResourceisStructured stereotype
to further define the resource as a File. The attributes of the stereotype
can help define the type of file (VSAM Sequential, Indexed) which
further customizes the COBOL source code generated by the later transformations.