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
i have 10 names in an array and my name is one of them also array is not in sorted order i need to display my name using index how will i do this
What is the difference between comp and comp-3?
i made it to stage 3 of an interview process wednessday they will quiz my knowledge again face to face for an analyst role recruiter said it will be based on Business requirements system is cobol and good ideas what they might ask etc
What are the different data types in cobol?
How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?
What are various search techniques in cobol? Explain.
A table has two indexes defined. Which one will be used by the SEARCH?
What rules are to be followed while using the corresponding options?
Whats the difference between search & search ALL?
In COBOL programming, what is PERFORM? What is VARYING?
How to print 10 to 1 if the input have only 10 digit number?
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?
What are the different rules for performing sort operation?
how to convert the recors form vsam file to db2 table tru file aid
Write down the divisions of cobol program?