Scenario-1 (RAHUL) : Section1
Scenario-1 (RAHUL) : Section1
Scenario-1 (RAHUL) : Section1
Rahul is working as a mainframe developer in ABC banking project. He received a new requirement
from client for which he must write a COBOL program to validate the input file.
Section1:
The program should read the input file and perform data validation based as per client
requirements.
The record layout of TRANS-FILE ( IDC006.EMP.DETAILS) is:
The input record needs to be validated based on above rule and the records which pass the above
criteria are copied to another PS file ( IDC1600.EMP.FINAL) and processed further.
Record layout of IDC1600.EMP.DETAILS:
FD ETRANS.
01 TRANS-REC.
05 EMP-ID PIC 9(9)
05 EMP-NAME PIC X(22)
05 EMP-CODE PIC 9(1)
05 EMP-MARTIAL-STATUS PIC X(1)
05 EMP-SALARY PIC 9(5)
05 EMP-DEPT PIC 9(2)
CHOOSE
Question #1
Below are the two statement related to VSAM access mode:
1. To add records to VASAM file which is opened in output mode, use ACCESS mode as
Sequential along with the write statement to add records sequentially at the end of file.
2. To add record to VASAM file which is opened in output mode, use ACCESS mode as
Random or Dynamic along with the write statement. Here the records can be written in any
order.
ANS: 2 is Correct
Question #2
Which of the following is the correct Snippet code to validate EMP-ID field?
Question #3
Select the most appropriate Field Control statement for VASAM KSDS file
ANS: FILE-CONTROL
SELECT EMPKSDS ASSIGN TO DD1
ORGANISATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS EMP-ID-IN
FILE STSTUS IS WS-FS1
Question #4
Which of the following is the correct Snippet code to validate EMP-NAME field?
Question #5
Which of the following is the correct Snippet code to validate DEPT Field?(Choose 2 correct snippet)
Question #6
Select the correct option to define VSAM KSDS cluster. Choose the Correct 2 options
ANS: //SYSIN DD *
DEFINE CLUSTER (NAME(IDC006.EMINFO.FILE) –
TRACKS(5 5) -
VOLUMES(USER01) -
CONTROLINTERVALSIZE(512) -
KEYS(9 0) -
RECORDSIZE(40 40) -
INDEXED) -
DATA (NAME(IDC006.EMPINFO.FILE.DATA))-
INDEX (NAME(IDC006.EMPINFO.FILE.INDEX))
/*
&
ANS: //SYSIN DD *
CREATE CLUSTER (NAME(IDC006.EMPINFO.FILE) -
TRACKS(5 5) -
VOLUMES(USER01) -
CONTROLINTERVALSIZE(512) -
KEYS(9 0) -
INDEXED -
RECORDSIZE(40 40)) -
DATA (NAME(IDC006.EMPINFO.FILE.DATA))-
INDEX (NAME(IDC006.EMPINFO.FILE.INDEX))
/*
Question #7
Rahul has decided to copy record from PS to VSAM KSDS File using IDCAMS utility. Select the most
appropriate option.
Question #8
Assume EMPKSDS VSAM file has 100 records.
Select the correct code to read last 50 records from the EMPKSDS VSAM file in dynamic mode
By accepting the key. Choose the most appropriate option.
ANS: C000-PROCESS-PARA.
ACCEPT EMP-ID-IN.
START EMPKSDS KEY IS EQUAL TO EMP-ID-IN.
IF WS-FS1 = 00 THEN
PERFORM E000-READ-FILE UNTIL WS EDF= ‘Y’
ELSE
DISPLAY ‘THE STATUS OF FILE IS’ WS-FS1
END-IF
E000-READ-FILE
READ EMPKSDS NEXT RECORD
AT END
MOVE ‘Y’ TO WS-EOF
NOT AT END
PERFORM F000-PROCESS-PARA
END-READ
Question #9
Select the correct snippet to delete record from EMPKSDS VSAM file.
ANS: DELETE-PARA.
MOVE 990009900 TO EMP-ID-IN
READ EMPKSDS
INVALID KEY
PERFORM ERROR-ROUTINE
NOT INVALID KEY
DELETE EMP-KSDS-REC
END-READ.
Question #10
Which of the following is the correct Snippet code to validate SALARY field?
Select two correct options.
&
*************************COMPLETED***********************************
Scenario-2 (DAVID)
Section 1
Question # 1
David is working on Mainframe migration project and below are the requirement details.
File details:
File structure:
Requirements:
Table needs to be created as per the file structure and data types
Table name: TBCUST
· Check CNO, CNAME, CBAL fields are blank or not if any field in blank, then don't insert the record
into table
· If CADD field is blank, then insert NULL value into corresponding column
CHOOSE
Question #1
DCLGEN copybook is part of ________ SECTION? Choose the best option
ANS: WORKING-STORAGE
Question #2
What in the record length David have to mention during MFID CUSTOMER DATA file creation?
Choose the best option
ANS: 58
Question # 3
What is valid programming logic to process at the records from sequential file as per the
requirement
ANS: Write a loop to read all the record until file status is equal to 10
Question #4
Assume that the client asked David to create a table with Primary key(TCNO). In this scenario, how
to create unique index after creating table with Primary key?
ANS: CREATE UNIQUE INDEX IX_TECUST ON TBCUST(TCNO);
Question #5
How do you declare record structure in DATA DIVISION as per the requirement if you are the
developer?
ANS: DATA DIVISION.
FILE SECTION
FD CUSTFILE.
01 FS-CUSTREC.
05 FS-CNO PIC X(5).
05 FS-CNAME PIC A(20).
05 FS-CADD PIC X(20).
05 FS-CBAL PIC 9(8) COMP-3.
05 FS-CDOB PIC X(8).
Question #6
What is valid table structure as per the requirement?
ANS: CREATE TABLE TBCUST(
TCNO CHAR(5),
TCNAME CHAR(20),
TCADD CHAR(20),
TCBAL DECIMAL(8),
TCDOB DATE ) IN DATABASENAME TABLESPACENAME;
Question # 7
Choose appropriate COBOL logic to check FS-CNO, FS-CNAME fie fields are blanks or not?
ANS: IF FS-CNO =’ ‘
IF FS-CNAME =’ ‘
DISPLAY ‘CUSTOMER NUMBER & NAME FIELDS ARE BLANK’
ELSE
DISPLAY ‘CUSTOMER NAME IS NOT BLANK’
END-IF
ELSE
DISPLAY ‘CUSTOMER NUMBER IS NOT BLANK.
END-IF.
Question #8
How do you handle Nut indicator in COBOL program when you are moving sequential Ble to 082
table if CADD feld is blank in sequential file?
ANS: Declare WS-ADD-NULL variable in working storage section with S9(4)
Type
Move-1 to WS-ADO-NULLI CADD is blank
Move 0 to WS-ADD-NULL if CADD is not blank
Mention WS-ADD-NULL field in insert command
Question #9
What is the vald SQL command to insert the data into TOCUST table?
Assume following details:
Column names: TCNO,TCNAME,TCADO TCBAL,TCDOB
Host variables for the mentioned columns HV-TCNO, HV-TCNAME,HV-TCADD,HV-
TCBAL,HV-TCDOB
Indicator Variable for the column TCADD is IV-TCADO
Insert NULL value for the column TCADD.
ANS: EXEC SOL
INSERT INTO TBCUST
VALUE(:HV-TCNAME,:HV-TCADD:IV-TCADD,:HV-TCBAL
END-EXEC
Question #10
How do you define the file in environment division as per the given business requirement?
ANS: ENVIRONMENT DIVISION
INPUT-OUTPUT SECTION
FILE-CONTROL
SELECT CUSTFILE ASSIGN TO DD1
ORGAN7IZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS STATUS-VARIABLE
*************************COMPLETED***********************************
Scenario-3 (BILLING)
Section 1
Question # 1
Display the BILL in the following format along with the details of usage as follows:
*********************************************************************
ABC BROADBAND SERVICES CUSTOMER DETAILS:
*********************************************************************
CUSTOMER DETAILS:
Validation:
2. The CUSTOMERID must be existing in VSAM file. Else display an error message "CUSTOMER DOES
NOT EXISTS" 3. If the total usage is zero display "CUSTOMER CANNOT BE BILLED FOR THE GIVEN
DURATION" and end the program.
Joe is developing a batch program which will perform the following business logic:
1.Accept the CUSTOMER ID, FROM-DATE and TO-DATE of bill generation from the user
2. Fetch the details of the Customer from the VSAM file, corresponding to the accepted
CUSTOMERID
3. Compute the TOTALUSAGE in GB for the accepted CUSTOMERID within the duration of FROM-
DATE and TO-DATE (inclusive of both dates)
4. If the total usage is not zero, calculate the total BILLAMOUNT payable using the following
specification.
(1 GB = 1024 MB)
CHOOSE
Question #1
Choose the right host variable for the column USAGEINGB?
ANS: S9(02)V9(03) COMP-3
Question #2
How Joe will implement the second validation written in the scenario in his program? Choose the
best right approach
ANS: He reads all the records from VSAM ksds file sequentially and compare the data from the file
with accepted customer id
Question # 3
Joe is going to create VSAM KSDS file using ISPF 3.2 option to store customer details. Can you
suggest appropriate file attributes for creating VSAM KSDS file?
ANS: Record Size Average :56
Record Size Maximum : 56
Key Length: :6
Offset :0
Question # 4
How Joe will implement the validation-1(CUSTOMER ID MUST BE NUMERIC) in the Cobol code?
ANS: Using Class condition
Question # 5
Choose the right statements written in file control para of cobol program for the VSAM KSDS file
ANS: SELECT CUST ASSIGN TO DD1
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS FS-CUST-ID
FILE STATUS IS WS-FS1.
Question # 6
Choose the 2 right approach for calculating total bill amount as per the plan from the total usage
Name of the plan is stored in a data name WS-PNAME
Total bill amount will be stored in a data name WS-COST
Question # 7
Joe would like to add below sample data in USAGE table using SPUFI USAGEID: 12000 CUSTID:
112233 USAGEDATE: 12th May 2020 USAGEINGB: 12.123
Question # 8
Joe created table USAGE successfully. But he could not insert data into the table. His insert scripts
are failed with -540 sqlcode.
How to resolve above issue?
ANS: By creating a unique index using below query CREATE UNIQUE INDEX IDIDX ON
USAGE(USAGEID)
Question # 9
How Joe will calculate the TOTALUSAGE as per the business logic given in the scenario? Choose 2
right approach.
EXEC SQL
SELECT SUM(USAGEINGB) FROM USAGE
WHERE CUSTID=HV-CUSTID AND USAGEDATE BETWEEN
:WS-FROM-DATE AND :WS-TO-DATE
END-EXEC.
&
ANS: By declaring the following cursor
EXEC SQL
DECLARE CURSOR C1 WITH HOLD FOR
SELECT USAGEINGB FROM
USAGE WHERE CUSTID=:HV-CUSTID
AND USAGEDATE BETWEEN :WS-FROM-DATE AND :WS-TO-DATE
END-EXEC.
Question # 10
Choose the right table script for the table mentioned in the scenario to store usage details of
customer. Choose 2 right choice
*************************COMPLETED***********************************
Scenario-4 (JOHN)
John is a mainframe developer who is coding a batch program for the below requirements to
fetch the details of books sold in normal price at xyz pvt ltd.
N- NORMAL PRICE R-
REDUCED PRICE
F- Free
Below records are added to the BOOK_SALES table
S 1001 10002 4 N
S 1002 10001 2 N
S 1003 10002 2 N
S 1004 10005 4 R
S 1005 10005 2 R
S 1006 10002 2 N
S 1007 10003 1 F
S 1008 10004 1 R
2. Check whether the accepted book number is present in the BOOK MASTER table. If not
display "BOOK details not present in the records".
3. Find the total number of copies of the same book sold in 'normal' price, display "THIS
BOOK HAS NOT BEEN SOLD ON NORMAL PRICE"
5. If accepted book number is blank(spaces), display the details of all the books sold in
normal price.
Report Format:
**********************************************************************
BOOK SALE REPORT
**********************************************************************
BOOK NUMBER : <book number>
**********************************************************************
NO OF COPIES SOLD IN NORMAL PRICE : <no of copies>
*********************************************************************
Question # 1
Choose the right host variable for the column BOOK_NAME. If the host variable prefix is BK
Choose the most appropriate option
Ans :
01 BK-BOOK-NAME
49 BK-BOOK-NAME-LEN PIC 59(4) COMP
49 BK-BOOK-NAME-TEXT PIC X(50)
Question # 2
What is the output generated for input Book number 10005 as per given table data in scenario?
Ans : The message "THIS BOOK HAS NOT BEEN SOLD ON NORMAL PRICE" will be displayed in
SPOOL
Question # 3
What is the most variable PICTURE clause of the table column BOOK_NO?
Ans :
* Cursor must be declared in working storage section or procedure division as first step
* One FETCH statement is enough to display all the book details
Question # 6
Display the number of copies sold without leading zeroes. What is the best approach? Provided,
SL-NO-OF-COPIES is the host variable used for the table column NO_OF_COPIES.
Ans :
Declare below dataname in the Working Storage Section,
01 COPIES-ED PIC Z(2)9(7),
Before displaying, do the below move,
MOVE SL-NO-OF-COPIES TO COPIES-ED
DISPLAY COPIES-ED.
Question # 7
Choose the right statements that identify SALE_ID as primary key and BOOK_ID as foreign key
in the BOOK_SALES table, such that subsequent inserts in the table will be successful.
Ans :
CREATE TABLE BOOK_SALES (
SALE_ID CHAR(5) NOT NULL PRIMARY KEY,
BOOK_NO INTEGER NOT NULL REFERENCES BOOK_MASTER(BOOK_NO),
NO_OF_COPIES INTEGER NOT NULL
SALE_STATUS CHAR(1) NOT NULL) IN DBNAME,TSNAME.
Question # 9
Check whether the accepted Book Number is present in the BOOK_MASTER table. If not, display
'BOOK DETAILS NOT PRESENT IN THE RECORDS'
&
EXEC-SQL
SELECT COUNT(BOOK_NO)
INTO WS-COUNT
FROM BOOK_MASTER
WHERE BOOK_NO = BK-BOOK-END-EXEC.
EVALUATE SQLCODE
WHEN 0
PERFORM PROCESS-PARA!
WHEN +100
DISPLAY 'BOOK DETAILS NOT PRESENT IN THE RECORDS'
WHEN OTHER
PERFORM ERROR-PARA
END-EVALUATE.
Question # 10
What is the correct cursor declaration to fetch the details of books sold in normal price, if the
input Book number is blank/spaces?
Ans :
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT BOOK_NO,BOOK_NAME,AUTHOR,SUM(NO_OF_COPIES)
FROM BOOK_MASTER
GROUP BY BOOK_NO,BOOK_NAME,AUTHOR
HAVING SALE_STATUS ='N'
END-EXEC.
*******************************COMPLETED*************************************