I have a seq file with different fields one field is address
with pic x(50) as input in a cobol program. In address there is
'PUNE' at any different positions in the address field ( form 1
t0 50) . My requirement is select the fields with address 'PUNE'
by using cobol. Please suggest

Answers were Sorted based on User's Feedback



I have a seq file with different fields one field is address with pic x(50) as input in a cobol p..

Answer / jagan

IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-3270.
OBJECT-COMPUTER. IBM-3270.

INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO INFILE

SELECT OUT-FILE ASSIGN TO OUTFILE

DATA DIVISION.

FILE SECTION.
FD IN-FILE.
01 INPUT-REC.
05 IN-NAME PIC X(20).
05 IN-ADDRESS PIC X(50).

FD OUT-FILE.
01 OUT-REC.
05 OUT-NAME PIC X(20).
05 OUT-ADDRESS PIC X(50).

WORKING-STORAGE SECTION.

01 NO-MORE-RECORDS PIC X(1).
88 END-OF-FILE VALUE 'Y'.
88 NOT-END-OF-FILE VALUE 'N'.

01 COUNT PIC 9(1).

PROCEDURE DIVISION.
MAIN-PARA.
PERFORM READ-FILE UNTIL END-OF-FILE.
STOP RUN.

READ-FILE.
MOVE 0 TO COUNT.
READ IN-FILE AT END SET END-OF-FILE TO TRUE
NOT AT END
IF IN-ADDRESS NOT EQUAL TO SPACES OR LOW-VALUES
INSPECT IN-ADDRESS TALLYING COUNT FOR ALL
'PUNE'.
IF COUNT > 0
WRITE OUT-REC FROM INPUT-REC
END-IF
END-IF
END-READ.
END-READ-FILE.

The above piece of code should do what you have asked .
Correct me incase there are any errors.

Is This Answer Correct ?    23 Yes 2 No

I have a seq file with different fields one field is address with pic x(50) as input in a cobol p..

Answer / garry

@Jagan.

Good Reply.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More COBOL Interview Questions

Explain what you understand by passing by value.

0 Answers  


I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?

3 Answers   IBM,


What is comp-1 and comp-2?

0 Answers  


what is the basic concept of mainframe? what knowledge is needed for learn this mainframe?

4 Answers   CSE, TCS, Wipro,


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

0 Answers  






What is the maximum size of a 01 level item in COBOL I? in COBOL II?

2 Answers   IBM, RBS,


I am getting S00F abend when i try to compare two variable of different pic class,one variable is of 9(09) and another is S9(09) comp-3. First i moved the data from S9(09) comp-3 to 9(09), but no luck. So i tried to move the data from S9(09) comp-3 to X (09) and move to 9(09). I am getting same error message, Please help me to find solution for this ptoblem. ERROR MESSAGE - "The system or user abend S00F R=NULL was issued."

1 Answers  


I have 100 records in a file.. i want to sort the records from 5 to 5o... give the syntax...

2 Answers   CTS, DSRC,


is it possible to declare index in cobol program? if it is not why its tell me pls

3 Answers  


which one is better among static call and dynamic call?

3 Answers  


Can we change the password using ALTER? anyone tried and changed?

0 Answers   IBM,


In an EVALUATE statement, can I give a complex condition on a when clause?

2 Answers  


Categories