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

Name some of the examples of COBOl 11?

2688


What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?

680


i made it to stage 3 of an interview process wednessday they will quiz my knowledge again face to face for an analyst role recruiter said it will be based on Business requirements system is cobol and good ideas what they might ask etc

2109


what is amode(24), amode(31), rmode(24) and rmode(any)?

705


What is a report item?

742






Is it possible that the redefines clause has different picture clauses compared to the one it redefined?

678


i need a small 3d program using inline and outline.

1642


how do you reference the ksds vsam file formats from cobol programs

669


What the difference is between continue and next sentence?

665


Define cobol?

866


For rewrite, why is it mandatory that file needs to be opened?

623


What is the difference between Global and External Variables?

666


What is the default value(s) for an initialize and what keyword allows for an override of the default?

698


What is the difference between Call and a Link?

702


Explain about different table spaces.

652