Note: This technical blog is more intended for IMS and Mainframe Developers only, since most of the terms and terminologies are in relation to IMS and Mainframe technologies.
As we all know that IMS stands for Information Management System and it came into existence around 1966. Till today, it is retaining its supremacy and that is only because of its well-organized hierarchical structure, non-existence of redundant data, enhanced data security at the segment level, auto-logging facility and the most important one for today’s market is, its ability to interact with open source technologies like JAVA, .Net and few others. So, when we have a powerful Mainframe database of that sort, it’s our responsibility to know the Do’s and Dont’s in it. Hence, for the benefit of the IMS developer, I have listed down few of the main Do’s and Dont’s in IMS DB Applications.
From DBD (Database Descriptor) perspective:
- Critical and very important data should always be at the top and the less important one, at the bottom.
- Data Grouping has to be done in such a way that data storage occupies less space, faster data access, efficient retrieval mechanism and enforces the security measures at the database/segment level.
- Efficient usage of Indexed Database, thereby reducing I/O calls.
- Segment occurrence can be limited by using FREQ parameter in DBD.
- Advisable to have an OVFLW (overflow) dataset in the DBD in order to handle the storage exception of the primary dataset.
- In case of Secondary Index, ensure LCHLD (Logical Child) is being defined in the Parent DBD for the respective segment of the Secondary Index DBD, with PTR (Pointer) parameter as INDX (Index). For Secondary Index DBD, access mode should always be INDEX and its LCHILD should refer to the Parent DBD segment for which secondary index is being set.
- For a DBD, one can create a maximum of 255 LCHILD, 32 XDFLD (Index Field) and total number of DBD fields (inclusive of XDFLD) should not exceed 255.
- For the best availability and huge data handling, HALDB (High Availability Large Databases) setup is a good option.
- For better transaction rates and high speed processing, DEDB (Data Entry Database) is always preferred.
- Upon successful DBD creation, DBDGEN has to be performed immediately.
From PSB (Program Specification Block) perspective:
- PSB name, Transaction name and the Program name has to be always the same.
- In case of BMP & MPP programs, the program name, PSB and the transactions have to be registered in respective IMS Control regions.
- Check whether PSB, Program and Transaction are in start mode before it is being executed.
- For Batch processing, the type parameter of first PCB should be ‘DB’ (Database) and in case of Online it should be ‘TP’ (Terminal/Transaction Processing)
- In case of multiple positioning on the same database, it is good to have two PCB’s (Program Control Block) for the same database with appropriate PROCOPT (Processing Options) options.
- Based on the IMS calls, appropriate PROCOPT option has to be selected for the respective PCB’s.
- Based on the Transaction criticality and availability, appropriate PLC (Processing Limit Count), Priority and Class have to be set for the MPP transactions.
- In case of BMP Checkpoint and Restart programs, ensure there is a PCB entry with GSAM (General Sequential Access Method) file type for the Checkpoint and the PSBGEN statement should contain the CMPAT parameter as YES.
- In case of MPP, especially for transaction switch programs, ALT-PCB should be the first entry within PSB followed by IO-PCB.
- Upon successful PSB creation, PSBGEN has to be performed immediately.
From Program perspective
In IDENTIFICATION DIVISION
- Any additional compiler option for a specific program has to be mentioned as comments and that too below in the Identification Division.
- Below the compiler option description, it is compulsory to have a short description about the Program function.
- In case of any changes to the program functionality, please append the comments as mentioned below but do ensure that they are commented.
In ENVIRONMENT DIVISION
- Adhere to the Project recommended configuration section.
- For Input/Output Section, especially for the File-Control statement,
- Check whether DDNAMES of the input & output logical file names that are defined in the program are same as in the PSB.
- Should not define the checkpoint file (GSAM) in the SELECT clause inspite of its definition in the PSB.
In DATA DIVISION
- Check if the sequence in which FD entries appear should coincide with the sequence of the SELECT statements in the File Section.
- Maximum length of the Report file should always be 133 bytes
In WORKING-STORAGE Section
- Check if all the variables used in arithmetic calculations are defined in packed format (Binary or Packed decimal) and signed wherever applicable.
- Check if the error messages are set up as data items or in a file, but not hard-coded as literals in the procedure division.
- Check if IMS abend routine copybooks are included.
- All the IMS segment copybooks and its associated SSA copybooks have to be included.
- In case of MPP programs, copybooks of DIF (Device Input Field), DOF (Device Output Field), MID (Message Input Descriptor) and MOD (Message Output Descriptor) have to be included.
- In case of Checkpoint programs, checkpoint associated parameters, such as Checkpoint-Id, Save areas and other parameters have to be clearly defined in the working storage section.
In LINKAGE Section, it is always a good practice to start as below,
- Check whether all the required PCB’s are being added in the linkage section.
- If the program is a subroutine, all its associated parameters needs to be declared in the linkage section.
In PROCEDURE DIVISION,
- PCB entries in the procedure division/Entry statement must coincide with the PSB definitions.
- In case of ENTRY statement, it should always be accompanied with ‘DLITCBL’, along with the PCB entries.
- If the program is a subroutine, check if the PCBs and other parameters are in the same order as in the called program.
- Check if there is a description box before each PARA, describing its function.
- It is good to have a separate PARA for the Initialization (include variable initialization, Open files, date calculation etc.) and terminate action (Close files, write trailer record etc.)
- Set the switches/flags initialization in the INIT-PARA
- In case the program needs the current system date for it process, try to get the system date in the INIT-PARA itself.
- If a PARA is going to do the Perform loop based on a flag or a field value, validate whether that particular field has been initialized before the paragraph is being executed.
- If there are any switches/flags used inside a PARA, ensure that they are initialized before that PARA is being executed.
- Check whether the last line of each PARA ends with a period “.” separately.
- For every IF, EVALUATE, CALL and PERFORM, there must be a corresponding END-IF, END-EVALUATE, END-CALL and END-PERFORM.
- There should not be more than 3 nested IF’s and to avoid that breakdown, the IF’s based on the flags should be set in the previous IF.
- GOTO statements must be avoided.
- Check if the date calculations/verifications are used only through the standard Date routine as per project standards.
- Ensure the period “.” is being used at the end of the last parameter of the IMS call.
- Almost all the error and abend scenarios have to be handled in the program itself, thereby ensuring very little chances of abnormal termination.
- Before any Delete/Replace call, GHU call has to be issued.
- The Key of the IO-Area should not be altered between the GHU call and DLET/REPL calls.
- In case of IMS program that uses GSAM files, the OPEN, READ, WRITE and CLOSE statements must be issued through ‘CBLTDLI’ calls.
- To override the IMS default path, it is better to go for appropriate Command codes based on the DB operations.
- Too many secondary index database calls will slow down the application and system performance.
- Avoid using STOP-RUN or EXIT for the IMS program termination, instead, go for the GO-BACK statement for the proper IMS region shutdown.
- After the compilation of the IMS programs, ACBGEN must be done but ensure its DBDGEN and PSBGEN are already completed.
WRT BMP Programs (Batch Message Processing)
- In case of Checkpoint-Restart programs, XRST call should always be the first IMS call, with its respective parameters.
- Evaluation should be done on its DLI-STATUS code and the CHKP-ID should verify whether it’s a normal start or a restart.
- For every checkpoint, the key values can be stored in the respective checkpoint save areas, so that it will facilitate the DB reposition in case restart process.
- Maximum of seven checkpoint save areas can be used.
- Decide on which particular DB operation, the checkpoint counter has to be incremented.
- The length of checkpoint parameters and save-area parameters should always be calculated prior to CHKP call.
For MFS (Message Formatting Services):
- The TYPE parameter of DIV statement should have the below,
- IN (Screen to receive inputs only)
- OUT (Display Screen)
- INOUT (Receive the inputs, process it and display the output)
2. For any display fields, DFLD (Device Field) should be associated with literals and position but not the label name.
3. For Response/Conversation transaction type, NEXT parameter has to be always filled in with respective transaction-id name.
4. In case of MFS editable fields, DFLD length should always be plus two from its original length, to accommodate the attribute function.
5. In case of any changes in the existing screens/fields, keep a close look on the field position and the length such that it should not affect the existing MFS setup.
6. It is always good to have the hidden space in the MFS, for the future expansion and screen navigation.
7. GU call should always be the first IMS call for the MPP Programs, followed by the respective IMS calls.
8. Verify whether the output message length has been calculated and passed, before the ISRT call is issued.
9. In case of transaction or destination switch, IMS call sequence should be ISRT, CHNG and PURG IMS calls.
10. For any transaction and destination switch, it is mandatory to use ALT-PCB along with other IMS call parameters.
WRT JCL & PROC
- Always the EXEC step must have the PGM = DFSRRC00 followed by its PARM. This may vary in some of the projects.
- PARM should follow the below sequence,
3. Make sure the system Id, Application group name and DB2 system parameters are pointing to the correct regions.
4. DBDLIB, RESLIB, PSBLIB and ACBLIB must exist in JCL.
5. IMSLOGR file must for BMP Checkpoint-Restart programs.
6. In case of restart, key in the corresponding checkpoint-Id against the Checkpoint parameter provided in the above JCL PARM.
7. Validate whether the PSB and Program are in START mode before Restart is being done.
8. In case of DLI mode, please don’t hold the respective DBD and PSB otherwise it will end in contention issue.
I assume that by going through the above artifacts, any IMS developer, regardless of his/her experience level, will be equipped in handling IMS DB and DC applications, with a very minimal assistance. Moreover, this will enforce the developer to set the standards in their IMS coding, thereby resulting in high-quality deliverables for the end-clients.