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

What is the difference between comp and comp-3 usage?

0 Answers  


period is missing in the cobol program which error we getting

5 Answers   TCS, Tesco,


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

1 Answers  


What is the Purpose of Pointer in the string?

0 Answers  


here is my compile and link edit steps in a jcl //COMPILE1 JOB (3CUS,S),'CCDM TEST' //STEPNAME EXEC PGM=IGYCRCTL,PARM='DYNAM,RENT,LIB,OBJECT, // OFFSET,APOST,OPTIMIZE',REGION=4096K //STEPLIB DD DSNAME=PM7351.TEST2.COB,DISP=SHR //SYSIN DD DSNAME=PM7351.TEST2.COB(PGM1),DISP=SHR //SYSUT1 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT2 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT3 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT4 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT5 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT6 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSUT7 DD UNIT=SYSDA,SPACE=(10,(10,10)) //SYSPRINT DD SYSOUT=* //SYSLIN DD DSNAME=&&LOAD,DISP=(MOD,PASS),UNIT=SYSDA, // SPACE=(10,(10,10)),DCB=BLKSIZE=400 //LKED EXEC PGM=IEWL,REGION=1024K //SYSPRINT DD SYSOUT=A //SYSLIB DD DSN=PM7351.TEST2.LOADLIB,DISP=SHR // DD DSN=PM7351.TEST2.COB(PGM1),DISP=SHR //SYSLMOD DD DSN=PM7351.TEST2.LOADLIB, // DISP=SHR //SYSUT1 DD UNIT=SYSDA,DCB=BLKSIZE=1024,SPACE=(CYL,(1,1)) //SYSTERM DD SYSOUT=* //SYSLIN DD DSN=&&LOAD,DISP=(OLD,DELETE) //SYSIN DD DUMMY i am getting IEW2013I 0F08 NO MEMBER NAME WAS SPECIFIED. MODULE WAS SAVED USING TEMPNAM1. could any one tell me the resolution for this..?

1 Answers  






What are differences between Static Call and Dynamic Call?

10 Answers   IBM, KBC, Keane India Ltd, Verizon,


I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?

3 Answers   IBM,


Differentiate COBOL and COBOL-II?

0 Answers  


How do you fetch current date in normal cobol pgm and in cobol-db2 pgm?

3 Answers   Cap Gemini, CTS,


What is the difference between index and subscript?

5 Answers   Visa,


What is the Linkage section? What is the Use and Why the parm length use alway "PARM-LENGTH PIC S9(4) or PIC S9 (4) COMP." any reason?.Please let me know any one... Cheers,Prasad

8 Answers   Syntel,


What is Control Break processing ?

1 Answers   iGate,


Categories