Can we move SPACES to numeric field and ZEROES to
alphabetic field? If yes what are the way doing this?
Answers were Sorted based on User's Feedback
Answer / siva
yes, we can move accordingly thru REDEFINES clause.
Example :
01 WS-A PIC 9(5).
01 WS-AR REDEFINES WS-A PIC X(5).
01 WS-B PIC A(5).
01 WS-BR REDEFINES WS-B PIC X(5).
MOVE 12345 TO WS-A.
MOVE SPACES TO WS-AR.
MOVE 'ABCDE' TO WS-B.
MOVE ZEROES TO WS-BR.
WS-A, WS-AR contains spaces and WS-B, WS-BR contains
zeroes.
Is This Answer Correct ? | 19 Yes | 1 No |
Answer / chakri
Sriram we can move numeric data items to alphanumeric data
items and vice versa. But when we do arithmetic operations
then only it will throw error if we move alphanumeric data
items to numeric items.
Is This Answer Correct ? | 9 Yes | 5 No |
Answer / maneendra
Hi all,
I am adding one more point to all.
we can move spaces to numeric field without using redefines
also. it can be possible by Reference modification(The
compiler will then treat your WS-NUM field as alphanumeric.
The field length is not necessary).
sample prog and results are:
IDENTIFICATION DIVISION.
PROGRAM-ID. SPATONUM.
AUTHOR. MANEENDRA.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM PIC 99.
01 WS-STR REDEFINES WS-NUM PIC XX.
PROCEDURE DIVISION.
MOVE ZEROS TO WS-NUM.
DISPLAY 'BEFORE:', WS-NUM.
MOVE SPACES TO WS-NUM(1:).
DISPLAY 'AFTER:', WS-NUM.
STOP RUN.
OUTPUT:
BEFORE:00
AFTER:
For moving numeric field to Alphanumeric field, we can pass
it directly.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / guest
Chakri, you are wrong. Only Numeric data can be moved to
alphanumeric variable. The reverse is not possible.
One way of doing it is using Redefines clause.
Is This Answer Correct ? | 6 Yes | 5 No |
we can move the numeric to alphanumeric or alphabetic and
vive versa only using the redefines.
this concept is useful when you want to have only one copy
book field need to change to num/aplha for particular
program.
Is This Answer Correct ? | 1 Yes | 0 No |
Consider the following: 77 W-NUM PIC 9 VALUE 0 ------ MOVE 1 TO W-NUM PERFORM PARA-X UNTIL W-NUM > 9. ------ PARA-X ADD 1 TO W-NUM How many times PARA-X is executed ?
a pic s9(4) comp b pic s9(4) comp-3 c ???????????????? d ???????????????? move a to c add a+B giving d. what is ur declaration for c,d?
In COBOL programming, what is PERFORM? What is VARYING?
What is difference between comp & comp-4?
77 I pic 99 value 5 Perorm para-A I times. Para -A. move 10 to I. How many times the para-A will be executed.?
study the following 01 A PIC 99V0 VALUE 5 01 B PIC 9V9 VALUE 6 01 C PIC 99V9 VALUE 2.5 01 D PIC 99 VALUE 3 COMPUTE A ROUNDED B C = A+B*C/D ON SIZE ERROR PERFORM PRINT-ERROR the comments of A.B.C after execution of the above statement are a.A=10 B=0 C=10 b.A=10 B=9.9 C=9.9 c.A=10 B=0 C=9.9 d.A=10 B=6 C=10
Can the OCCURS clause be at the 01 level?
WT R TECHNICAL MAINFRAME QUESTION ASKED IIN ANJANASOFTEARE??
why mainframe we use not like java as frontend oracle as backend. or not word excel.In there also huge ammount data stored.
if a pic 9(3) value 354,b pic x(2) value '46' then a)a>b 2)a<b 3)error
If by mistake we MOVE a working storage variable into LINKAGE area. What will happen??
Consider the following code: 77 A PIC 99V99 VALUE 55.35 77 B PIC 99V999 VALUE 32.754 ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!" What will be the result ? (a) A=88.10, B=32.754 (b) A=87.00 B=32.754 (c) A=87.10 B=32.754 (d) ERROR!!! will be DISPLAYed on the screen.