Introduction

CA Gen enables application development on Windows workstations and supports application deployment to integrate multiple platforms on z/OS (CICS and IMS), UNIX, Linux, Windows, .NET and J2EE.

CA is Computer Associates. And CA Gen is one of their product.

38) Explain GEN Subtype entity ? How it works?


38) Explain GEN Subtype entity ? How it works?

· When a parent entity type which includes subtypes is transformed, the parent entity type with its subtypes becomes one physical table.  All attributes defined within each subtype become optional columns on the table.   

· A subtype is sometimes promoted to an entity type in the Data Model for performance considerations.  An analysis of the impact of the subtype versus separate entity type should be done early in Analysis to avoid rework in action diagramming, database implementation, and data mapping from other systems.

· A promoted entity has a one-to-one relationship with the original entity with the following characteristics:

-The relationship is optional on the side of the original entity.

-The relationship is mandatory on the side of the promoted entity.

-The relationship is the identifier for the promoted entity.

-The relationship is mutually exclusive with any other relationships from the main (original) entity to other promoted subtypes from the same partitioning


Promoting Subtypes

· Involve your Database Administrator (DBA) in your discussions about whether to promote subtypes.  Your DBA should understand many of the factors to be considered in such a decision, which include such things as saving storage space, expending more processing time, impact on existing work, and the complexity of the proposed implementation.Use of subtypes can increase disk storage space with a consequent effect on I/O.  This is particularly true if the subtype represents a small portion of the occurrences of the parent entity type, as there will be wasted DASD for the empty columns.  The columns will contain either blanks or spaces.  This results in fewer occurrences of a single parent entity type on a data page, which increases I/O because more pages have to be READ to retrieve the data.  This effect may be minimized by the use of compression routines.

· You can use a third party vendor's compression routine (EDITPROC) to reduce the amount of disk space used.  There is some processing overhead associated with this.

· Promote subtypes to high-level entity types when faced with DBMS columns-per-table limitations, or concurrency or storage problems.

· Deciding to implement entity subtypes depends on how sensitive the installation is to wasted disk space versus increased I/O, additional INSERTs and DELETEs to create both parent and subtype rows in one table, and the access patterns for use of subtype predicates with or without parent predicates.  (Access patterns here means the answers to questions of access volume, required response times, and so forth.)Use of a subtype adds rows to a record.  This causes additional INSERTS and DELETEs in the database.  It also means additional INSERT and DELETE statements must be added to the action diagram.

· Not all subtype constraints are enforced by the code generator.  Relationships defined at the subtype level are always optional at the parent entity type level, and are only mandatory if they are against an occurrence of the subtype's type.

· Consider the effects of concurrency and reorganization and recovery administrative tasks when deciding to promote subtypes.



Subtype Views

· Attributes in the subtype can be referenced in views of the entity type or view of the subtype.  If you do not reference subtype attributes, you do not need a subtype view or the classifier.  If you do reference subtype attributes, you should reference the classifier.

· Subtype identifiers are defined to distinguish occurrences of the subtype from one another.  The indexes built for them in the Data Store List are defined as non-unique since the index will be on a table supporting all occurrences of the supertype (parent entity type).  Since identifying predicates must be static and classifying attributes do not have to be, using the classifier to make the subtype identifier unique is usually a poor choice.Put one identifier on the high level entity type (parent entity type).  Add indexes in the Data Store List as needed to enforce uniqueness constraints deemed important enough to warrant the additional index.

· An entity view cannot be matched to an entity subtype view.  View matching, and reuse of process and common action blocks, is more difficult if the same data is sometimes in an entity view and some times in an entity subtype.

· You should not have views of subtype attributes unless you also have views of the classifying value.  Test the classifier to see that the subtype attributes are valid.


· If you build a view of a subtype, the generated SQL SELECT for READs of that view automatically gets the classifying value added to the WHERE clause.

32) Gen Data Model Notation vs. UML Type Model notation



32)

What is the difference between Gen Data Model Notation vs. UML Type Model notation.

See pictures. First one is GEN model notation. Second is UML model notation.



31) Explaining Action Block in CA GEN , coolgen



What is an action diagram?
The Action Diagram tool lets you build the process action diagram, procedure action diagram, and the associated action blocks.
These specify the detailed logic of elementary processes, procedure steps, business algorithms, and derivation algorithms.
Parts of action diagram
The first part of an action diagram details the views that the process imports and exports. For more information on views,
The remaining pseudocode consists of action statements such as CREATE, READ, UPDATE, DELETE, and so forth, with levels of nesting enclosed in brackets.

Types of Action Blocks (AB)
Common Action Block
Foreign Action Block
External Action Block
Procedure Step Action Block
Building the Action Diagram

Building an action diagram requires three main activities:
Creating views
Defining logic for elementary processes and procedures
Defining action blocks

Creating Views
A view is a collection of associated attributes input to or output from a business activity

Types of views
Import views show information about an entity that a process receives (or imports)
Export views show information about the entity that a process produces (or exports)
Entity action views show stored information about an entity that a process manipulates during execution Local views are used for local operations

Assigning View Characteristics
Depending on the view you create, the following characteristics can be assigned: Supports entity actions
Lock required on entry
Used as both input and output
Supports Entity Actions
When an entity view is defined in the Import or Export view subset, the Supports Entity Action option specifies whether the view is transient or persistent.

Transient and Persistent
A transient entity view does not support the entity actions CREATE, READ, DELETE, or UPDATE. Transient views can be modified by MOVE and SET actions. Transient is the default for entity views in the import, export, or local view subset. A persistent entity view allows entity actions to be performed on the designated view.. Persistent views can be thought of as database buffers.

Lock Required on Entry
This Lock Required on Entry option allows locking of an occurrence in an import view at entry to the action block. Locking an occurrence prevents other transactions from changing the view

Used as Both Input and Output
The Used as Both Input and Output option allows import entity views to be exported and export entity views to be imported

Maximum Size of Views
The following restrictions apply to the maximum size of views:
For terminal-based applications, 32K for import and 32K for export.
For a single server load module, 32K for export.
For GUI applications developed under Windows NT, Win32, or UNIX, unlimited for import and export.

Group views
A group view is a collection of one or more associated entity views. Group views have cardinality, that is, each of their component views may occur more than once.

Detail Import Group Views
Detailing group views consists of the following activities: Describe group views
Specify cardinality
Specify optionality
Specify Import Group View Cardinality
Expected numbers of occurrences for the group view. You set the group view’s minimum cardinality by the value you enter for at least. You set the group view’s maximum cardinality by the value you enter for at most. Finally, you set the group view’s average cardinality by the value you enter for on average
Explicitly or implicitly indexed
Explicitly indexed repeating group views have user-accessible indexes to refer to specific entries in the repeating group
Implicitly indexed repeating group views cause the software to go to the next occurrence in a repeating group view
Specify Import Group View Optionality The optionality of an import group view refers to whether the view is mandatory (always used as input) or optional (sometimes used as input).


Building an action diagram
Add entity actions
Add relationship actions
Add assignment actions
Add conditional actions
Add repeating actions
Add control actions
Add miscellaneous actions
Conditional statements

An IF action statement for a simple condition: IF condition 1 action_statement_list_1
CASE
CASE OF (expression)
CASE value
CASE value
OTHERWISE

Loops
The FOR EACH condition is used to iterate through implicitly indexed repeating group views. Since the view is implicitly indexed, there is no need to specify subscript controls. This will automatically be generated by COOL:Gen software.

For Each
The TARGETING clause allows you to identify the repeating export or local group view to be populated. The following example shows usage of the TARGETING clause: FOR EACH product details TARGETING group export FROM THE BEGINNING UNTIL FULL ASSOCIATE processing warehouse WITH received product WHICH is_held_in IT
WHILE Condition
The WHILE repeat condition repeats the action group as long as a condition is true. When you add the WHILE condition, set up the condition and then state the action(s) to be taken. The test for the condition takes place first. If the condition is not met, there are no iterations.
REPEAT UNTIL Condition
The combination of the REPEAT and UNTIL statements repeats an action or group of actions until a specific condition is satisfied. The test for the condition takes place after the iteration. Therefore, REPEAT–UNTIL always has at least one iteration.
FOR Condition
The FOR condition is used to control iterating through an explicitly indexed repeating group view. The syntax allows you to pick a subscript or other numeric attribute, a starting index, an ending index, and increment value for each iteration.

30) Types of Action Blocks (AB) in coolgen, CA GEN

Common Action Block

Foreign Action Block

External Action Block

Procedure Step Action Block

29) Parts of action diagram in coolgen, ca gen



The first part of an action diagram details the views that the process imports and exports. For more information on views,

The remaining pseudocode consists of action statements such as CREATE, READ, UPDATE, DELETE, and so forth, with levels of nesting enclosed in brackets.

28) What is an action diagram?

28) What is an action diagram?


The Action Diagram tool lets you build the process action diagram, procedure action diagram, and the associated action blocks.
 
These specify the detailed logic of elementary processes, procedure steps, business algorithms, and derivation algorithms.

27) Coolgen Interview Questions - Set 07



How to Generate Host Code using the Installation Tool

The expected output of performing this procedure is a set of load modules and DB2 DBRM modules.  
In order to accomplish this, you must:
·         Generate the trigger and load modules from the implementation model
·         Generate the load modules from the model
·         Ship .rmt files from step 1 and 2 to PID

·         Compile, link , and bind programs  

26) Coolgen Interview Questions - Set 06



How to handle error in the GEN coding : 

1. naming the action diagrams in a  application and
2. using exit states to support error handling

When an error occurs the user and the developer should know

1. what service or action block failed
2. what attribute had a problem

3. the problem it had

25) Coolgen Interview Questions - Set 05


Talk about the Batch model and packaging etc in COOLGEN, CA-GEN

·         Choose model and appropriate batch business system (E.G. modelname).
·         Add Procedure/Procedure step and create as a type = BATCH
·         Packaging as Batch, give the job name
·         Use host encyclopedia load module packaging. Give Load module name as a program that is used in a  batch JCL
·         Build the JCL and make sure you have allocated TIRIOVF dataset.
·         Decide Check pointing logic if required
·         Check pointing logic is required if the job has to be made as restart-able without any manual intervention.
·         Time based check pointing or record based check pointing
·         Time base check pointing means take a commit point ofter predefined interval and save the key of the record processed.

·         Record based check pointing means take a commit point after certain number of records and save the key of the record processed.

24) GEN, CA GEN, CoolGen client procedure related best practice





The control to the client procedure comes from the following ways:
1.   From previous client
2.   From the server
3.   From the same client (for displaying an error)
4.   From the next client (on success or failure)
To know where the control comes is quite tricky.

Best Practice:
The usual way of communicating from client to client OR client to server is through the IEF variable command. But as explained above this alone is not sufficient to signify where the control comes from. Hence the following convention is followed:
·       Two variables curr_command and prev_command are maintained. curr_command is assigned to prev_command, command is assigned to curr_command in the beginning of the client procedure.
·       Command is set to "return" whenever the control transfers from the server
·       The convention is as follows:
Client procedure:
...
...
/* Execute client validations here */
CASE of Command
CASE…
CASE…
Otherwise…
End CASE

/* Execute client code after window has been displayed */
CASE of curr_command
CASE…
CASE…
Otherwise…
End CASE

/* Execute client code after return from server */
CASE of prev_command
CASE return
            /* Code to be added return from server */
            …
CASE…
Otherwise…
End CASE


Note: Client validations can also be executed as events.

23) GEN, CA GEN, CoolGen client procedure related best practice





Exit states cannot be set across server procedures. This becomes a major impediment in the following cases:
·       Server wants to return an error message to client by means of an exit state
Note: COOL:Gen allows exit states to be passed across procedures. But this practice is not valid for earlier versions

Best Practice:
Every client and server procedure does the following:
·       In the beginning USE an init action block
·       Just before exit USE an exit action block

The client procedure looks like:
Import Views:
Export Views:
Local Views:

USE client_init_action_block ...
...
...
USE client_exit_action_block...

The server procedure looks like:
Import Views:
Export Views:
Local Views:

USE server_init_action_block ...
...
...
USE server_exit_action_block...

The client_init_action_block contains code as follows:
CASE of  exit_state_code
CASE 0
            Set exit_state as exit_state_a
CASE 1
            Set exit_state as exit_state_b
...
END CASE

The client_exit_action_block contains code as follows:
Move all import views to export views

The server_init_action_block contains code as follows:
Move all import views to export views

The server_exit_action_block contains code as follows:
CASE of exit_state
CASE exit_state_a
            Set exit_state_code to 0
CASE exit_state_b
            Set exit_state_code to 1
...
END CASE
Exit state is return_to_client

Note: return_to_client is the exit state to transfer control to the client from the server. If a rollback is to be done, then exit state is set to return_to_client_rb which has the rollback attached to it.

22) GEN, CA GEN, CoolGen server procedure related best practice




The Read action block fails to use the index even though the predicates in normal COBOL programs would have made use of the index.

Best Practice:
In spite of having separate Read action blocks for each read, the entity views in the RAB should contain the required attributes. If attributes other than those in index are to be accessed then, it is better to have separate entity views.
For eg: Assume table T1 has index I1, I2, I3 respectively and the attributes in I1, I2 and I3 are A1, A2 and A3 respectively. Then a Read  of the following type will be an Index read instead of an Index Only Read.:

Entity View: Entity T1 A1,
                                 A2,
                                A3
...
...
Read T1 where A1 = local view lcl_a1_value

The better way of coding this:

Entity View: Entity ent1_T1 A1,
                  Entity ent2_T1 A2,
                 Entity ent3_T1 A3.
...
...

Read ent_T1 where A1 = local view lcl_a1_value

21) GEN, CA GEN, CoolGen server procedure related best practice



In the server procedure sometimes the Read generates an extra predicate (which has not been coded as part of the read statement). Hence the index is not used even if one exists.

Best Practice:

Each Read is coded in open action block each. They are often called the Read Action Blocks (RAB). COOL:Gen generates the extra predicate whenever it is not sure whether the read is for an update or just a read only.

20) GEN, CA GEN, CoolGen server procedure related best practice



Use of Read Each for a batch program with restart logic, opens and closes the cursor repeatedly causing performance degradation

Best Practice:
Instead of invoking the program repeatedly, it is replaced by the following logic:
...
Set commit_count to 0
Set commit_freq to 10000
Read Each table (with cursor hold)
...
commit_count = commit_count + 1
If commit_count = commit_freq Then
            USE ext_commit_action_block
...
End Read Each
...

Note: ext_commit_action_block is an external action block, which contains only SQL statement: COMMIT.

19) GEN, CA GEN, CoolGen testing related best practice




During stress testing, very active tables and its associated children undergo deadlocks and timeouts. (Note: dsg_sequence_no is the primary index which has running sequence numbers as its value. The primary index was on the descending sequence to avoid a sort when getting the maximum dsg_sequence_no)

Best Practice:  

The following three design changes to the application:
1.     Create a primary index with dsg_sequence_no in ascending sequence
2.     Define the subpage parameter as 1 rather than 16
3.     Introduce a dummy column at the end of the table as X(250). Drop the primary index and recreate it with dsg_sequence_no and the dummy column.

The advantage of these suggestions are:
1.     Ascending sequence will avoid unnecessary reordering of the index whenever new records are created.
2.     Redefinition of Subpage to 1 will avoid subpage splitting altogether during creation
3.     Making the key size to be approximately 250 bytes ensures only less number of entries are available in each page. This will lessen the number of deadlocks/timeouts. Further all the 3 changes require no change to the application



18) GEN, CA GEN, Coolgen and design best practice




Use of a running sequence number as the primary key instead of a logical key gives rise to the following issues:
·       For new creations the access is always towards the end of the table
·       Contention in an multi-user environment for accessing the last sequence number

Best Practice:
1.   One solution is to a common table, which contains only two attributes: table name and last sequence number. Being a small table, this should resolve the contention problem to a great extent.
2.   Instead of creating the primary key ASIS, the key is inverted and created. This will resolve the creation of new records towards the end of the table.
For eg:
If the primary key is a 6-digit number, the new records are created as follows:
·       100000
·       200000
·       ...
·       900000
·       010000
·       110000
·       210000
·       ...

Note: One could also use a random number generator to create unique primary key. See a post to create a random number using program..

17) GEN, CA GEN data modelling best practice



Denormalization of tables whenever the access equals or exceeds three levels but can be avoided by having additional attributes.

Eg: To get attrib1 table T1 and attrib3 from table T3 the normal sequence would be:

Read T1 Where A1 = local view lcl_a1
When Successful
            Read T2 Where current view and
                        A2 = local view lcl_a2
            When Successful
                        Read T3 Where current view and
                                    A3 = local view lcl_a3
                        When Successful
                        ...
End Read

Instead by storing the extra attrib1 attribute in Table T3, these three reads can be avoided.


Note: There is of course the need to update this field as when the field is updated in table T1.

16) GEN, CA GEN, CoolGEN batch job related another best practice



The batch jobs of COOL:Gen even though they execute successfully, they return with a return code of 100. For unsuccessful executions, it displays the return code as given by the TP monitor.

Best Practice:
Instead of invoking the batch program as given below:
...
//SYSTSIN        DD       *
            DSN SYSTEM(DB2T)
            RUN PROGRAM(PROGA) PLAN(PROGA)
            END
/*

Execute it as follows:
..
//SYSPROC      DD       DSN=SYS2.COOLGEN.CLIST,DISP=SHR

...
//SYSTSIN        DD       *
            EXECDSN PROGA DB2T
/*

The contents of EXECDSN will look like:
/* Rexx */
Parse Upper Arg programname db2system .
"NEWSTACK"
Queue "RUN PROGRAM("programname") PLAN("programname")"
Queue "END"
"DSN SYSTEM("db2system")"
Coolgenrc = Rc
"DELSTACK"
If Coolgenrc = 100 Then
            Exit 0

Exit Coolgenrc

15) GEN, CA GEN, CoolGEN batch job related best practice


GEN, CA GEN, CoolGEN batch job related best practice

If a batch step due to its logic doesn’t write even a single record to the output file created in the same step, and a subsequent step has a read from this file. The read fails with an abend.

Best Practice:
The abend occurs because the EOF marker is not set if the file is not opened and closed for output. A dummy step is introduced in between these 2 steps, which will write the EOF marker if the file is empty. This is achieved as follows:
//STEP01          PGM=IKJEFT01
//FILE01            DD        DSN=SBBT02.NEW.FILE,DISP=(,CATLG),…
//SYSTSIN        DD        *
            EXECDSN progname db2system
/*
//STEP03          PGM=IKJEFT01
//FILE01            DD        DSN=SBBT02.NEW.FILE,DISP=SHR
//SYSTSIN        DD        *
            EXECDSN progname db2system
/*

Instead add the following step in between the two steps:
//STEP01          PGM=IKJEFT01
//FILE01            DD        DSN=SBBT02.NEW.FILE,DISP=(,CATLG),…
//SYSTSIN        DD        *
            EXECDSN progname db2system
/*
//STEP02          PGM=IKJEFT01
//SYSPROC      DD        DSN=SYS2.COOLGEN.CLIST,DISP=SHR
//FILE01           DD        DSN=SBBT02.NEW.FILE,DISP=SHR
//SYSTSIN        DD        *
            EMPTYFLE
/*
//STEP03          PGM=IKJEFT01
//FILE01            DD        DSN=SBBT02.NEW.FILE,DISP=SHR
//SYSTSIN        DD        *
            EXECDSN progname db2system
/*

The logic in the REXX program would contain logic like this:

/* Rexx */
“NEWSTACK”
“EXECIO * DISKR FILE01 (FINIS”
Queue “”
“EXECIO * DISKW FILE01 (FINIS”
“DELSTACK”

Exit