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 |
i have a variable block which is used in my cobol program as input file having records of 4080 after compilation while runing the program im getiing file attribut mismatch and it is saying tht the record length of the file is 4084 can any one knw the answer how to reslove it ?
2)Where the Plan is located in CICS-DB2?
I have a field with data type X(10). I want to perform arithmetic operation on this field? I tried doing it by moving the value into a numeric field. but it didn't work out. I am getting a S0C7 abend. Pls let me know if there is any way of getting this done?
A table has two indexes defined. Which one will be used by the SEARCH?
How do you fetch current date in normal cobol pgm and in cobol-db2 pgm?
We are using the searching a table which is indexed, once the key is found, how can we get the occurance at which the key was found.
What are the cobol coding sheets?
What is comp-1 and comp-2?
How to convert bunch of words in a line to relvant ASCII values?
What is COMP-1? COMP-2?
Under which scenario you would go for a static call as opposed to dynamic call?
How to find whether a Flat file is empty or not without Reading a file in COBOL Program. (not using JCL)