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 SOC3?HOW IT CAN BE RESOLVED?
If a file has 1000 records.. if i have to replace the first and last characters of the file with another character. how it can be done....
i want to use only first 100 records from a file.plz tell me how to write JCL for this(for read,copy,write operations).plz give me details of all posible JCL utilities?
What R 2 of the common forms of the EVALUATE STATEMENT ?
Consider the following COBOL entries 05 X PIC 99 VALUE 10. ADD 40 X TO X. COMPUTE X = 3 * X - 40. The result in X is
what is label record is standard or omitted in file description of data division?
I try to use some column names in my cobol progorm but these column not in db2 table ..when do i get error ..while bind time or runtime?
what is the minimum number of lines a Cobol program should have to successfully compile and run
11 Answers ABC, Societe Generale,
Can a REDEFINES clause be used along with an OCCURS clause? if yes, 01 WS-TABLE. 03 WS-TABLE-EL OCCURS 5 TIMES PIC X(1) VALUE 'A'. 03 WS-EX REDEFINES WS-TABLE-EL PIC X(5). What can you expect? if no,why?
what is srange and nosrange pls reply to ths question ?
HOW TO MOVE REDEFINES CLAUSE FROM INPUT TO OUTPUT ?
how to know that the file has 300 records how to acess it?