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

How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that

0 Answers  


Whats the difference between search & search ALL?

3 Answers   IBM,


What is rmode(any) ?

0 Answers  


WE HAVE 5 DIFFERENT RECORDING MODE IN COBOL.FIXED, FIXEDBLOCK, VARIABLE, VARIABLEBLOCK AND UNDEFINED. WHAT IS THE DIFFERENCE AMONG ALL AND WHICH TYPE OF FORMAT SHOULD BE USED WHEN

3 Answers   Infosys,


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

0 Answers  


What is the difference between PIC 9.99 and PIC9v99?

0 Answers  


what is filler and what is use of filler

3 Answers   Syntel,


What is the difference between next sentence and continue in cobol programing language?

0 Answers  


What do you feel makes a good program?

2 Answers  


what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?

4 Answers   IBM,


I HAVE FOLLOWING DECLARATION. 02. A PIC X(10) VALUE 'XXXXXXXXXX'. 02. B REDEFINES A. 05. C PIC X(3). 05. D PIC X(3). 05. E PIC 9(3). IN MY PROG, I HAVE MOVE 1 TO E. DISPLAY A. WHAT WILL BE DISPLAYED AS A RESULT OF THIS? PLEASE EXPLAIN THE ANSWER. THANKS.

7 Answers   Amdocs,


What is the difference between Global and External Variables?

0 Answers  


Categories