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



I have the file which is having the extension no as records. sample file will look like below. 2..

Answer / santy

You can solve this problem using the Referencial Intigrity.

Let consider these extension no. in WS section.
01 WS-EXTN PIC X(4).

IF WS-EXTN(1,1)='3'
ISPECT WS-EXTN replacng first '3' by '5'
END-IF.

read the next record.

Is This Answer Correct ?    5 Yes 0 No

I have the file which is having the extension no as records. sample file will look like below. 2..

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

I have the file which is having the extension no as records. sample file will look like below. 2..

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

I have the file which is having the extension no as records. sample file will look like below. 2..

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

I have the file which is having the extension no as records. sample file will look like below. 2..

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

Post New Answer

More COBOL Interview Questions

How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?

0 Answers  


wht is the use of evalute verb ? how do u declare recfm in cobol and jcl ?

2 Answers   EDS,


hi dudes.....can any one help me..... what is SET TO TRUE all about,anyway?

1 Answers  


Can we use goto statement in inline_perform ?

5 Answers   IBM,


INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?

0 Answers  






how can u redefine picx(10) with pic 9(6).

3 Answers   TCS,


I am sending values a and b with pic x(10) and pic x(10) by using call statement. In linkage section, I am receiving values with pic x(10) and pic x(11). Will my program fail? will it be compile error or run time abend?

3 Answers  


can any one give good example for cond 88 level number and for renames pls urgent dudes ?

3 Answers   DELL,


wht happens if we dnt give scope terminator ?

4 Answers   TCS,


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

0 Answers  


What is ASKTIME, SUSPEND

1 Answers   IBM,


how we sort two input files based on a common column and giving one o/p file please send me the coding logic?

0 Answers   Valtech,


Categories