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
Name the sections present in data division.
What are the cobol coding sheets?
Which division and paragraphs are mandatory for a COBOL program?
how to convert the recors form vsam file to db2 table tru file aid
How to know whether the module is dynamical or statistical?
What is the difference between structured cobol programming and object alternativelyiented cobol programming?
Which is not true about evaluate statement
Difference between array and sub-script ?
What are literals?
How do you reference the fixed block file formats from cobol programs
Explain about different table spaces.
Explain sorting techniques in cobol program? Provide the sort file definition, the sort statement, its syntax and meaning
How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.
What is rmode(24)
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there