# COBOL Interview Questions

Showing Questions 1 - 20 of 239 Questions
First | Prev | Next | Last Page
Sort by:
|
•

#### How many bytes occupied following comp example?

Dear Friends,

This is regarding COBOL comp.

PIC X(3) occupy the 3 bytes... but PIC 9(3)V9(7) COMP occupied how much bytes?

I said in interview that 10/2 = 5 bytes. V is specified for decimal point.

Is that correct? But interviewer looked at me differently when I said this answer?

#### Jyoti Kalagi

• Feb 15th, 2023

We can store only 9 and S not V in comp ,if we want to store decimal use comp-3 not comp

#### rathna

• Aug 17th, 2022

N/2 for even number and than +1. (n+1/2) for odd number.
3+7=10
10/5= 5
5+1=6

•

#### In the example below

05 WS-VAR1 PIC X(5),05 WS-VAR2 REDEFINES WA-VAR1 PIC 9(5),PROCEDURE DIVISION MOVE 'ABCDE' TO WS-VAR1.Now what is the value of WS-VAR1 and WS-VAR2 ?

#### Jeevan Poojar

• Apr 25th, 2021

WS_VAR1 - ABCDE
WS-VAR2 - A CDE

#### supriya

• Sep 5th, 2017

Here given 05 WS-VAR2 redefines WA-VAR1 pic 9(5). means WA-VAR1 should be defined in working storage so while compiling it will throw the error. but excluding this next statement in procedure division is move abcde to ws-var1. means value of ws-var1 is =abcde

•

#### Jo Ann

• Aug 4th, 2020

there is much difference between Linkage and working-storage on how you define variables. linkage section has 01 level only. Linkage is to take in data from other programs or stored procedures. Wor...

#### ramesh4greek

• Jun 11th, 2010

There is no difference between Working and Linkage both are in Data Division.Working-Storage for declaring the variables in main program.Linkage section is used for declaring the variables for Sub program. Parm parameters also can be declared in Linkage section only.

•

#### Redefine

What is redefine in COBOL?

#### Dhans

• Sep 2nd, 2019

The REDEFINES clause is used to store more than one data items in the same storage area. Syntax: level-number Data-name1 REDEFINES Data-name-2 data-name-1 is the redefining item or the REDEFINES su...

#### gauravaram

• Dec 6th, 2018

redefines class is something you can use the existing memory location for your new variable using the redefines caluse 01 emp-data pic x(100) 05 emp-name pic x (40) 05 emp-no pic x(20) 05 fi...

•

#### nids

• Jan 17th, 2019

Perform varying sub from 4 by 1 until sub is greater than the occurs area. Move spaces or zeros to the fields in the occurs.

#### Guest

• Apr 3rd, 2018

Hi,
I have query regarding the initialization of occur clause.

01 WS-TABLE.
02 WS-DETAIL OCCURS 20 TIMES.
COPY DDS-ALL-FORMAT OF TESTPF.

Query - How can I initialize WS-DETAIL for particular index 5 where up to index 4 having data in WS-DETAIL?

•

#### Concatinating two rec by using COBOL & JCL

I need to concatenate records by using cobol and jcl (both) as follows.

Input File:

AAAAA
BBBBB
CCCCC
DDDDD
11111
22222
33333
44444

Split the file into two halves and
1st rec of first half and 2nd rec of second half records are concatinated and
2nd rec of first half and 2nd rec of second half records are...

#### GAURAVARAM

• Dec 6th, 2018

Please post your requirement clearly .. If you have to concatenate the records from two different files you can use IEBGENER

`Code `

#### Kalyan

• Mar 20th, 2018

Outrec overlay=(5:13,3,9:5,3,13:17,3,17:9,3)

•

#### How to separate to multi-field?

For example:
01 something PIC X(06).
01 one PIC 9(02).
01 two PIC 9(02).
01 three PIC X(02).
SELECT socket(:number)
INTO :something
FROM DUAL
result:
something = 1234ww
one = 12
two = 34
three = ww

#### gauravaram

• Dec 6th, 2018

We can declare something as a group variable
01 something pic x(06)
05 one pic 9(2)
05 two pic 9(2)
05three pic x(2)

#### Indu

• Nov 2nd, 2018

Redefines can be used

•

#### What is the difference between NEXT SENTENCE and CONTINUE?

NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.

• Jul 20th, 2006

the following code explains u clearly

If A>B

next sentence

end-if

display 1

display 2.

display 3.

it will display only 3. if a>b

if a>b

continue

end-if

display 1

display 2.

display 3.

it will display 1 2 3. if a>b. let me know if it is not correct.

#### Prasanth Karthikeyan

• Sep 14th, 2018

Continue pushes the control to Add +1 to Input-count. Say if Input-count was 0 then the value will be iterated to 1

Next sentence will never add +1 to Input-count it will bypass the command. Say if Input-count was 0 then the value will remain same.

#### Amit

• Jan 17th, 2017

When NEXT SENTENCE is coded, Program will not add +1 to INPUT-COUNT.
When CONTINUE is coded, +1 will be added to INPUT-COUNT.

•

#### Ascending Order String Handling

Given a string for eg: MICROSOFT, How can you arrange each letter in this string in an ascending order?

#### Kalyan

• Mar 20th, 2018

In EBCDIC A- C1 , B - C2....Z- E9. Perform varying inx from 1 by 1 until ws-data >= 9 If not-first-time If ws-h < ws-data(inx:1) Move ws-h to ws-o(inx-1:1) ...

•

#### Called and calling program for cobol with cursor

I have program A which is calling B first time. B program is feaching data using cursor , but some mess happened and the control went back to pro A without closing cursor . Once again program A called program B then what will happen to cursor. will program fetch the data.

#### Kalyan

• Mar 20th, 2018

It depends on how program b is linked. Above answer is correct for statically linked. But if dynamically linked then program b will be in initial state in 2nd time and no error will come.

#### Anand Jeyapaul

• Oct 26th, 2017

How do we avoid the error code of -502? How do we close the cursor in the calling program?

•

#### EMail Validation via COBOL

I have file with customer details and I need to process only those records who is having valid email id, so how we can validated these records using COBOL?

#### neha

• Jan 29th, 2018

MOVE @ TO WS-CHAR
you can use INSPECT EMAILID TALLYING WS-COUNT-1 FOR ALL INITIAL WS-CHAR
IF WS-COUNT > 0 (means there is @)
proceed
ELSE
ERROR OUT

#### PRAVEEN SAINI

• Feb 12th, 2017

It is partially correct answer @ symbol is part of the answer we have to check (.) for valid mail id ..
Correct me if I am wrong

•

#### Lagnesh prithiviraj

• Nov 21st, 2017

Using ICETOOL, Below syntax will get just all duplicates if duplicates are decided based first eight charactes
SELECT FROM(SORTIN) TO(SORTOUT) ON(1,8,CH) ALLDUPS DISCARD(SORTXSUM)

#### raman gupta

• May 26th, 2017

//STEP010 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=TEST...

•

#### Srinivas Enumula

• Sep 8th, 2017

Copy - Expand the copybook statements during compilation time.

Include - Expand the copybook statements during pre-compilation time. Usually for DELGENS we use INCLUDE as DCLGEN statements needed during pre-compilation process.

#### surya

• Dec 31st, 2015

Copy will be used in the cobol compile process and Include will be used during the Db2 precompile process. So we include a Dclgen. We cannot copy a dclgen..If so the program will fail the compilation.We can include a copybook too.

•

#### Kathir

• Jul 1st, 2017

Static Call: Sub programs compiled version of code is embedded with main program so if compile sub program with modified changes then main program is also being compiled. Dynamic Call:Sub programs ve...

#### Maria

• Jun 16th, 2015

We can identify whether the call is static or dynamic by seeing the CALL structure. Static Call: we refer the program name in the CALL statement. e.g. CALL PGM1 Dynamic call : we use one WS variabl...

•

#### COBOL File Handling

how do you read a file in reverse order through COBOL program?

#### sunny

• Jun 28th, 2017

Add a seq number to file thru JCL (1:seqnum,3,zd) and sort the file in descending order sortfields=copy, include cond=(1,3,zd,d) after this provide the file in Cobol as input.

#### Gyanendra Singh

• Jul 7th, 2016

Can be done in VSAM : by using Low and HIGH-VALUE
If you pass HIGH-VALUE to the key field, then it will read the record from bottom

•

#### Consider the following COBOL entries 05 X PIC 99 VALUE 10. ADD 40 X TO X. COMPUTE X = 3 * X - 40. The result in X is (a) 10 (b) 40 (c) Compile or Run time error (d) none of these

• Jun 22nd, 2016

Answer is 40 - value of X is 10 -- add 40+10+10 = 60 ---> x=(3*60)-40 = 180 -- but pic declared as 99 -- right to left move so Answer is 40

#### Saranya

• May 28th, 2016

Add statement will add 40+10(value of X)+10(value of X) and the result will be stored in X as 60. Then, the compute statement multiples the value of X by 3 and subtract by 40. So, the value of X will ...

•

#### What is the difference between static & dynamic call?

In the case of static call the mainprogram and subpgms r loaded into the mainmemory initially.in the case of dynamic call only the mainpgm is loaded first and the subpgm is loaded only when a call to it is made.so the memory utilization is good in dynamic call.

• Jun 4th, 2016

Static and dynamic will be decided only on compiler if NODYNAM - it is static, if DYNUM then dynamic.

• Mar 8th, 2016

In case of Static Call, we use the call literal. For example, CALL PGM1. In case of dynamic call, we define a variable and pass the sub-program name to it before calling. Ex- 01 WS-VAR1 PIC...

•

I have two modules called 'A' and 'B'. Module 'A' opens the ORACLE database connection, and Calls 'B', which queries the database using the 'SELECT' statement.When I hard code the module name during CALL, the called module uses the database connection opened in the module 'A'. Pls refer below:CALL "B"But, when I moved the module name into a variable and try to call the module, as belowMOVE "B" TO...