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 the difference b/w level no.01 & level no.77?

3 Answers   HCL,


how many bytes does s9(7)COMP-3 field occupies?

6 Answers   ADP,


I want ALL ERROR codes in VSAM

3 Answers   American Express, TCS,


explain sorting techniques in cobol program?

0 Answers  


what will be the output when a)pic 9(6)value 000178 is moved to pic ***,***. b)pic 9(5) value 57397 is moved to pic $$,$$9.

5 Answers  






I have two questions here. 1. How to read a flat file in reverse order? 2. How to read a VSAM KSDS file in reverse order? In both the cases we donot know the total number of records.

2 Answers   L&T,


What is Comm?

2 Answers   IBM, Kemper Corporation,


Define static linking and dynamic linking.

0 Answers  


Can we move X(9) to 9(9). If yes what are the ways for doing this?

3 Answers  


wht is the diff b/w if and evaluate stmts ?

2 Answers   DELL,


How many variables can be declared in w-s section.?

2 Answers  


how will u find out 3rd week's 2nd day using occurs ?

3 Answers   L&T,


Categories