I have the file which is having the extension no as records.
sample file will look like below.
2310
3410
3256
4350
3781
5408
I need to replace the record which is starting with 3 to 5
(i.e) 3410 to 5410. How can we do it through cobol
and cobol-db2 program? I need the possible logic?
Answers were Sorted based on User's Feedback
Answer / jagan
Thavasi ,
In your case , check the record number 1 and 4 which has 3
in the second position of it . As your have given LEADING .
As it encounters the first '3' in any of the position in
the record , it will change it to '5' .
Please correct me if i am wrong...
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / pa
read the record to the WS varible defined below
01 ws-var1.
05 ws-var2 pic x(1).
05 ws-var3 pic x(2).
if ws-var2 = '3'
inspect ws-var replacing first '3' by '5'
end -if
read the next record.
Hope it works
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / reena
Define the working storage variable in the following way:
01 ws-var1.
05 ws-var2 pic x(1).
05 ws-var3 pic x(3).
Read the database file.
Move the database field value to the working storage
variable (i.e. ws-var1)
Then preform the following
if ws-var2 = '3'
move '5' to ws-var2
move ws-var1 to the database field
rewrite database record
end -if
read the next record.
Preform the above routine till eof..
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / thavasi
The answer is:
move each record to WS-REC PIC X(04).
then write the below statment to be executed for each rec.
INSPECT WS-REC REPLACING LEADING '3' by '5'.
why am i using LEADING instead of FIRST is that the
requirement says that 'STARTING with 3 by 5'
Is This Answer Correct ? | 1 Yes | 4 No |
What is Pic 9v99 Indicates in COBOL?
0 Answers SwanSoft Technologies,
I have a occurs for 100 times but it has executed 101 time what could be the reason?
What is the size of s9(19)comp3? explain
what r the types of perform statement
what is the use of outrecord?
In an array processing what is the thing that can be done by using subscripts but not by using index
how to refer the data field?
I have to write to a outfile where the number of records in that file should be the header of that file using IMS.. can anyone help me in this issue
Difference between ps, esds
How can you add a particular field/coloumn in copybook?
which is faster either static call or dynamic call ? and specify the reasons for it ? reply fast
what is the maximum error code in mainframe