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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

1908


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

1944


Difference between array and sub-script ?

1169


What is the difference between structured cobol programming and object alternativelyiented cobol?

755


Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?

720






What rules are to be followed while using the corresponding options?

641


What are 77 levels used for?

659


Discuss about changing dataset name in proc.

763


What is report-item in COBOL?

711


What is the use of intialize verb?

750


how do you reference the printer file formats from cobol programs

665


what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.

8167


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

661


if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

5695


State the various causes of s0c1, s0c5 and s0c7.

665