How to define variable 9(20) in COBOL, because compiler
does not allow us to declare variables with Pic 9(18). Can
anyone please let me know the answer... I know one answer
to this question which is to use Compiler option Arith
(Extend) during Compilation. It extends the maximum limit
to 9(32)..Just wanted to know if there is any other way to
extend this?

Answers were Sorted based on User's Feedback



How to define variable 9(20) in COBOL, because compiler does not allow us to declare variables wit..

Answer / abc

try with this:

01 VARIABLE-ABC.
03 VAR-1 PIC 9(18).
03 VAR-2 PIC 9(2).

This may work, please try and see.

Is This Answer Correct ?    10 Yes 1 No

How to define variable 9(20) in COBOL, because compiler does not allow us to declare variables wit..

Answer / vikram

01 VAR-1 PIC 9(18).
change the datatype then it's possible

01 VAR-1 PIC x(20).

Is This Answer Correct ?    1 Yes 0 No

How to define variable 9(20) in COBOL, because compiler does not allow us to declare variables wit..

Answer / dimpy19

try with this:

01 VARIABLE-ABC.
03 VAR-1 PIC 9(18).
03 VAR-2 PIC 9(2).




or
use PROCESS ARITH(EXTEND) before IDENTIFICATION DIVISION

ARITH option syntax

.-COMPAT-.
>>-ARITH(-+-EXTEND-+-)-----------------------------------------><


When you specify ARITH(EXTEND):
The maximum number of digit positions that you can specify in the PICTURE clause for packed-decimal, external-decimal, and numeric-edited data items is raised from 18 to 31.

Is This Answer Correct ?    0 Yes 0 No

How to define variable 9(20) in COBOL, because compiler does not allow us to declare variables wit..

Answer / sachin borase

Use the varchar.

01 var-char-variable.

49 ws-letch s9(4) comp.
49 ws-text 9(20).

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More COBOL Interview Questions

wht r the advantages of 77 level number ?

8 Answers   TCS,


What is COMP SYNC?

3 Answers  


Hi Guys, I have faced one interview question if I have requirement to add 5 new columns to existing table what are prerequisite do i need to take.

1 Answers  


i want to use only first 100 records from a file.plz tell me how to write JCL for this(for read,copy,write operations).plz give me details of all posible JCL utilities?

7 Answers   CTS,


I have File 1 occurs 5 times with Employee-ID,Employee-Name,Employee-Dept (EEE and MECH). I have File 2 occurs 10 times with Employee-ID,Employee-Name,Employee-Dept (EEE,CIVIL,CHEMICAL and MECH). In FIle 1 and FIle 2 , for matching Employee-DEPT (Only MECH) , we need to move entire records from file1 to file 2. We should not use 2D array. Your help is needed here.

0 Answers   Steria,






What does EXIT do ?

3 Answers   Deloitte,


How to define a array dynamically.....

5 Answers   Fidelity,


If you are current on the owner of a set, what is the difference between obtain next and obtain first?

0 Answers  


should I use Go back in the main program ? Yes we can use Go back in main program as well.

2 Answers   Xansa,


what is the advantage of using redefines instead of delaring the variables ?

5 Answers   HCL,


01 a pic 9(3) value is 123 01 b pic 9(6) move a to b wht will be the value ? and 01 a pic x(6) value is abc 01 b pic x(3) move a to b wht will be the value ?

7 Answers   Patni,


What does the INITIALIZE verb do?

1 Answers  


Categories