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

01 WS-VARX PIC X(10) VALUE 'ABCDEFGHIJ'.
01 WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345'.

What will happen I am going to Display the WS-VARX and WS-
VARN?

Answers were Sorted based on User's Feedback



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

Answer / mallikarjun

WE CANNOT GIVE VALUE CLAUSE IN THE SECOND STATEMENT I.E.
WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345' . IF YOU
SPECIFY VALUE CLAUSE SYSTEM WILL SHOW AN ERROR, IF YOU
SPECIFY WITH OUT VALUE CLAUSE I.E.
WS-VARN REDEFINES WS-VARX PIC 9(5).
THEN IF YOU GIVE DISPLAY STATEMENT THEN ABCDEFGHIJ AND
ABCDE WILL BE DISPLAYED

Is This Answer Correct ?    26 Yes 3 No

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

Answer / mallikarjun

if you use redefines in your statement the numeric
declaration will be over rided and stored as charechter, i
have testing this practically

Is This Answer Correct ?    6 Yes 0 No

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

Answer / sandy

Mallikarjun is 100% correct

Is This Answer Correct ?    5 Yes 2 No

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

Answer / neela

Hi KHB Naidhu,
pic x means it should be alphanumeric
pic 9 means it should be Numeric

so we have to move numeric values also to the pic x

for this qtion is correct what was explained my
mallikarjuna.

regards
Neela

Is This Answer Correct ?    2 Yes 1 No

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

Answer / khbnaidu

Mallikarjun Ur answer is wrong because of WS-VARN is Numric
field & how will display the ABCDE result?

Is This Answer Correct ?    2 Yes 13 No

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

Answer / siva

WS-VARX = 12345FGHIJ
WS-VARN = 12345

Is This Answer Correct ?    1 Yes 14 No

Post New Answer

More COBOL Interview Questions

what is Pic 9v99 Indicates?

2 Answers  


can internal sort be applied to sort ksds files?

1 Answers  


level number 77 is used to define a)group data b)elementary data c)redefine d)none

8 Answers   TCS,


What are the different rules of SORT operation?

0 Answers  


What are the cobol coding sheets?

0 Answers  






can we use the two 01 level in file discription ?

6 Answers  


TO abend the data sholud open in which mode? 1.new 2.old 3.mod 4.shr

1 Answers   MNC,


What are the situations u have used in ur project for Subcript and Index ? 1.if u use Subscript why not Index,why u choose Subscript only? 2.if u use Index why not Subscript,what abt Displacement?

2 Answers   Cap Gemini,


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?

4 Answers   CSC, TCS,


In COBOL "BEFORE" advancing is there or not ?

3 Answers  


i Want All cobol ERROR codes?

4 Answers   HCL, IBM,


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,


Categories