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
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 |
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 |
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 |
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 |
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 |
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 |
if you give cylinder(1,1)how many cylinders it will be allocate?
How to remove the spaces at end of each record in the output file Via COBOL program? note: The file has a VB length
What is the significance of 'above the line' and 'below the line'?
hi. This is Ram.i have one doubt.why can't we display comp-3 variables directly? let me answer quickly plez........
The maximum number of dimensions that an array can have in COBOL-85 is ?
what is the minimum number of lines a Cobol program should have to successfully compile and run
how to check whether the open command of a sequential file is successful? or not?
What is the difference between copy and include in cobol?
which one is the best of com and com-3.using of real time ?
i want to learn mainframe..any websites and material to learn from basic..? my mail id : rajeswaribe2010@gmail.com
What is SQL Code -904 and -903 in DB2 And how to handle it?
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there