CapGemini Mainframe Interview Questions
Below are the few Tricky ones faced at CapGemini.
1. I have 1000 steps in a cataloged procedure. I want to run only a few steps (say from 8th step to 16th Step). How this can be achieved?
2. A cobol db2 program takes a flat file as input and updates a DB2 table and creates an output file. It has around 1 million rows that are to be processed.
If it failed after processing 10,000 records. How to restart it? Commit frequency is 500
If it fails after processing 9999 records, how to proceed with the restart?
What happens to the Output file records after the abend and how to handle the restart with respective to Output file?
3. Explain the Page up & Page down logic.
4. How to read a VSAM file in backwards order?
5. What is commarea and how this is useful?
6. What is the Maximum Size of the data that can be passed thru Commarea?
7. If more data is required to be passed from one program to another, what are all the possible ways in increasing size order.
8. What is an Alternative Index? In which datasets it is possible to have an Alternative Index?
9. I have two files with some data and I want to combine that data and create a new file. How this can be achieved in JCL?
10. I have a file with some data and I want to split it into multiple output files based on some condition. How to achieve this in JCL?
11. I want to create 3 Output files from an input file using JCL. First file should be with records that are having ‘005’ in the first 3 characters and second file should have records that are having ‘010’ in the first 3 places. And all the remaining records needs to be placed in the 3rd file. How to achieve this
12. DO we have CANCEL command in COBOL. If Yes, Where we use it?
13. How a PLAN be created in COBOL-DB2 program?
14. What is -305 SQL code?
Answers:
1. Using IEBEDIT utility required steps can be run. It has options to Include the steps and also Exclude the steps. If the number of steps in the PROC are less, then this can be achieved by using the proper COND Parameters.
2.
3. Scrolling logic explaied very well at CICS Page Up/Down Logic
In above link, COMMAREA has been used to pass store & pass the data between PF7/PF8 But instead of using COMMAREA, TSQs can also be used.
4. If we have any particular Key from where the backwards needs to be started then
move that key in to the RIDFLD field
Issue a Start Browse Command
Issue a READNEXT COMMAND WHICH Actually starts the reading from the given Key.
Now Issue a READPREV command and put this read previous in a loop until the required condition is met.
If the file needs to be read from the last records onwards in reverse Order, then Move LOW-VALUES in to Key field and do the same process mentioned above.
5 & 6. COMMAREA is one of the important features that CICS provides which is used to pass data between two programs under a transaction or to pass data between two transactions under same terminal. It is a special form of User storage that has a maximum of 32k as limit. But the recommended data that can be passed is 24k.
7. COMMAREA is limited to 32K, if more data needs to be passed then
– TSQs can be used to store the data that is more than 32K
– Acquire storage using GETMAIN command and pass the address of that data in COMMAREA.
– Using Channels and Containers which is a new approach introduced in CICS transaction Server version 3.1. This is more flexible way of passing larger amounts of data.
8. Alternative INdex is used to access the data using alternative Keys. For example in an employee file, EMPID is the primary key on which Primary INDEX is created and there is a need to access the data using Employee Name, So on Employee name Alternative Index can be created. Alternative INdex is a Key Sequenced data set that contains the Key entries of Alternative keys which points to the Base records.
9 . It can be done using JOINKEYS of JCL SORT.
10. Using OUTFIL option.
13. Null value error. If null indicator is not specified and data has a null value then this SQL code would be returned
Common SQL codes are listed here –> SQL Codes that we get Frequently
Yes, COBOL has a `CANCEL` command. The `CANCEL` statement is used in COBOL to terminate a dynamically called program and release any resources associated with it. Here’s a brief overview of where and how it is used:
### Purpose:
The `CANCEL` statement is used to:
1. Unload a dynamically called subprogram from memory.
2. Ensure that the next time the subprogram is called, it starts fresh, as if it were being called for the first time.
### Syntax:
“`cobol
CANCEL program-name.
“`
### Usage Context:
– **Dynamically Called Programs**: The `CANCEL` statement is applicable only to programs that are called dynamically using the `CALL` statement with a program name specified in quotation marks or using a variable (e.g., `CALL ‘program-name’` or `CALL variable`).
– **Resource Management**: Use the `CANCEL` statement when you need to release resources or ensure that the called program is reinitialized before its next invocation.
### Example:
Here’s an example of using the `CANCEL` statement in a COBOL program:
“`cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. MainProgram.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-PROGRAM-NAME PIC X(8) VALUE ‘SubProg’.
PROCEDURE DIVISION.
CALL WS-PROGRAM-NAME.
* Perform operations with the subprogram
CANCEL WS-PROGRAM-NAME.
* The subprogram is now unloaded and its resources are released
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. SubProg.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-MESSAGE PIC X(20) VALUE ‘Hello from SubProg’.
PROCEDURE DIVISION.
DISPLAY WS-MESSAGE.
EXIT PROGRAM.
“`
### Key Points:
– **Dynamic Call**: `CANCEL` only affects programs that are called dynamically. For statically linked subprograms, `CANCEL` has no effect.
– **Resource Release**: Using `CANCEL` can help manage memory and resources, especially in long-running applications where many different subprograms might be called dynamically.
– **Reinitialization**: After a `CANCEL` statement, the next `CALL` to the same subprogram will result in the subprogram being loaded and initialized again.
In summary, the `CANCEL` statement is an important tool in COBOL for managing dynamically called subprograms, ensuring efficient use of resources, and controlling the lifecycle of called programs.