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
Answer Posted / 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 |
Post New Answer View All Answers
1.Is it possible to move the data from 99.99 to 99v99? 2.What is the CICS-vsam Compilation process? 3.In My GDG 5 generation will be there GDG3 got an abend what will happen? 4.In my GDG first generation is +1 And I want to add the new generation what will happen previous generation? 5.How can you give the PIC clause below conditions A). s9 (reddy), B). s9 (5) occurs 5 times? 6.How override the proc from a particular step? and what is symbolic and override Procs?
what is search and searchall?what is the diffrence between them?give an best example?
Name some of the examples of COBOl 11?
What are the access modes of START statement?
Write a program to explain size error.
What are the different rules to perform a Search?
What is the default value(s) for an initialize and what keyword allows for an override of the default?
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..
What is the compute verb? How is it used?
How to read the 2nd last record of a VSAM file? (The file size is huge and we don't know the key)
How do you define a variable of comp-1 and comp-2?
how do you reference the variable block file formats from cobol programs
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
What happens when we move a comp-3 field to an edited (say z (9). Zz-)?
what is the difference between COBOL2 AND COBOL390?