Without using move verb how to move one variable to another.
Answers were Sorted based on User's Feedback
Answer / bala
We can do this in multiple ways.
1) Using UNSTRING
2) COMPUTE
3) Also, REFERENCE MODIFICATION i.e, if XYZ is a variable with value 'all interview' then
A = XYZ(1:3) moves the first 3 characters of XYZ variable to A.
i.e, A value will be 'all'
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / manikandesvaran
1)Using REDEFINES you can acheive this.
For ex.
10 WS-OLD-START-DATE PIC 9(8).
10 WS-NEW-START-DATE REDEFINES WS-OLD-START-DATE.
15 WS-START-YEAR PIC 9(4).
15 WS-START-MONTH PIC 9(2).
15 WS-START-DAY PIC 9(2).
Now WS-NEW-START-DATE will hold the value of WS-OLD-START-
DATE.
2)Using UNSTRING operator.
UNSTRING WS-NEW INTO WS-OLD
3)Using COMPUTE verb.
COMPUTE WS-NEW = WS-OLD.
4)Using SET statement.
SET OLD to NEW.
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / raju
Let the variables and their values be A = 20 and B = 30
and we need to swap them as A = 30 and B = 20 without MOVE statement
BEFORE AFTER
A B A B
Way 1: COMPUTE A = A+B 20 30 50 30
COMPUTE B = A-B 50 30 50 20
COMPUTE A = A-B 50 20 30 20
Way 2: COMPUTE A = A*B 20 30 600 30
COMPUTE B = A/B 600 30 600 20
COMPUTE A = A/B 600 20 30 20
Is This Answer Correct ? | 1 Yes | 0 No |
What is mean by maxcc
What is the difference between performing a SECTION and a PARAGRAPH?
What is the LINKAGE SECTION used in COBOL?
What are the steps you go through while creating a COBOL program executable?
I hav vari declaration like..... 77 a pic s9(9).99. 77 b pic s9(9).99 comp. 77 c pic s9(9).99 comp-3. if i use MOVE 123456789.99 to a,b,c what happen every one working fine ?
Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
What is SQL Code -904 and -903 in DB2 And how to handle it?
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
if you give cylinder(1,1)how many cylinders it will be allocate?
1.What is the limit of linkage section?
Can the OCCURS clause be at the 01 level?
how can we get current dat and time thru cobol pgm