What will happen if a variable is declared as below..
Explain with an example?

Working storage section:-
01 WS-VARX PIC X(9) VALUE SPACES.
01 WS-VARN REDEFINES WS-VARX PIC 9(9).

Answers were Sorted based on User's Feedback



What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / lalith

Working storage section:-
01 WS-VARX PIC X(9) VALUE SPACES.
01 WS-VARN REDEFINES WS-VARX PIC 9(9).

REDEFINES: It is used to save the memory space....

ur declearing like that ws-varn will take the same memory
of ws-varx...

when u used display statement
DISPLAY WS-VARN
it shows the spaces... WS-VARN will take same memory of WS-
VARX irrespective of data type....

Is This Answer Correct ?    6 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / rookie

if you perform any arithmetic operation than comes the
question of any abend

Is This Answer Correct ?    4 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / ezhilenthi

It wont show any Abend, the main purpose of REDEFINES
clause is to use the same storage area with one or more
data item with different sizes and PIC 's. We will face
Abend if we try to MOVE WS-VARN TO WS-VAR.

Is This Answer Correct ?    4 Yes 1 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / neelam saini

WORKING-STORAGE SECTION.
01 WS-VARX PIC X(9) VALUE SPACE.
01 WS-VARN REDEFINES WS-VARX PIC 9(9).
01 I PIC 9(2).
01 J PIC 9(2).
PROCEDURE DIVISION.
MAIN-SECTION.
MAIN-PARA.
MOVE 123456789 TO WS-VARN.
DISPLAY WS-VARN.
STOP RUN.

ON RUN TIME. 123456789
O/P : 123456789

Is This Answer Correct ?    2 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / lalit

I am agreed with Rookie. It will abend if any mathematical
operation like add, subtract will be performed with
variable WS-VARX, but if any mathematical operation is
performed using WS-VARN then it will not abend because it
is numeric in nature.

Is This Answer Correct ?    1 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / ankur

after redefining we can also move alphabetic to numeric or
numeric to alphabetic field . mathematical operation is
different . if we go for that it will give s0c7.

Is This Answer Correct ?    1 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / anna

WORKING-STORAGE SECTION.
01 WS-VARX PIC X(9) VALUE SPACE.
01 WS-VARN REDEFINES WS-VARX PIC 9(9) value zeros.
in this case you can used any data, by using right
field for numeric data ws-varN, for alphabetic /alphanumeric
ws--varX.

Is This Answer Correct ?    0 Yes 2 No

What will happen if a variable is declared as below.. Explain with an example? Working storage ..

Answer / prasanna

Wont it show SOC or ASRA because of the data exception...
(non numeric in a numeric field) ??

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More COBOL Interview Questions

Can we dynamically increase the size of occurs clause? i.e In case I an not sure of the size of array and want to increase the size at run time.If yes , how?

1 Answers  


wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them to be send to outputfile in reverse order. PLZ HELP ME OUT .........THIS IS A RECENT QUESTION IN IGATE..

5 Answers   iGate,


How you can characterize tables in cobol?

0 Answers  


How do define Dymanic array in cobol how do u define single demensional arry and multidymensional arry in ur cobol.

4 Answers   Cap Gemini,


What is ASKTIME, SUSPEND

1 Answers   IBM,






there is a file whose ORGANISATION is INDEXED.you want to read the records from the file in RANDOM fashion as well as sequentially.then which of the access mode would you specify? a.SEQUENTIAL b.RANDOM c.DYNAMIC D.ACCESS MODE has nothing to do with it

3 Answers   TCS,


I have a File that has duplicate records. I need only those records that occur more than thrice.?

3 Answers   IBM, Wipro,


comp-3 field occupy?

5 Answers  


how to display date in reverse order if the pic clause of the is numeric suppose date is 09032010 ==> need to print in 20100309 (pic clause is numeric)

6 Answers  


What is the difference between a binary search and a sequential search what are the pertinent cobol?

0 Answers  


I want ALL ERROR codes in VSAM

3 Answers   American Express, TCS,


how you will define variables length in cobol.

3 Answers   Temenos,


Categories