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.

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

14) CA GEN, CoolGEN and testing best practice

CA GEN, COOLGEN and testing best practice During testing normally there is a need to run monthly jobs, yearly jobs and jobs tied to some specific dates. This kind of testing is called date simulation. Best Practice: The date simulation can be brought about in two different ways: 1. For the client the system date can be set to the required date in the individual clients 2. For the server, the date exit routine TIRDATC/TIRDATX can be written in assembly to accept the date from a file. The input file can be updated to the required date before executing the job.

13) Gen, CA-GEN, COOLGEN and DB2 related issues

GEN and DB2 Related issues The SQL generated by CA GEN, COOL:Gen is not always the best and in most cases there is an need for the following: • Creation of new index • Rewrite the READ action block to access existing indexes • Change table/index parameters • Need for partitioned tables Best Practice: Once the servers are ready for execution, the bind for the plans are done with EXPLAIN option. Each and every SQL is scanned for the following: • Does it result in a join, if so can it be avoided • Does it use an existing index, if not how to influence the SQL to make use of it • Would creation of an index improve the performance • Change of parameters (for eg: for batch jobs executing without any overlap, the lock can be escalated to table level and combined with appropriate acquire and release parameters in the bind step the performance can be improved).

12) What are the different CA Gen, aka COOLGEN services when in component based environment ?



Below is just an example. Your client side may have different architecture. Using these component services a transaction is built. And the whole development code is isolated from each other and have a specific purpose. Example - D service will have all the reads, create, update, delete statements on entities. So during maintenance it needs to be touched only if affected database is changed.

Types -

H Service  - Test Harness. To test the transaction

I Service - Interface. It is a Public Operation – the interface to the service

M Service - Private Operation Manager – the director or traffic cop

C Service - Contains isolated logic. e.g. editing of  imports or doing calculations, client side

T Service - Translator: Transient view to Persistent view

D Service - Data Access – goes against the database

P Service - Translator: Persistent view to Transient view

X Service - External Wrapper – an EAB that interfaces with an existing program

S Service - Error Processor – translates Exit States to Return Codes