Extract only those records from a PS file which are having word 'TEXT' in the records using COBOL? The word TEXT is not present in a particular position in all the records.
Answer Posted / chatgpt
IDENTIFICATION DIVISION.
PROGRAM-ID. EXTRACT-TEXT-RECORDS.
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE.
01 INPUT-RECORD PIC X(100).
FD OUTPUT-FILE.
01 OUTPUT-RECORD PIC X(100).
WORKING-STORAGE SECTION.
01 SEARCH-TEXT PIC X(4) VALUE 'TEXT'.
PROCEDURE DIVISION.
OPEN INPUT INPUT-FILE
OUTPUT OUTPUT-FILE.
READ INPUT-FILE
AT END DISPLAY "No records found."
NOT AT END PERFORM PROCESS-RECORDS.
CLOSE INPUT-FILE
OUTPUT-FILE.
STOP RUN.
PROCESS-RECORDS.
PERFORM UNTIL END-OF-FILE
IF INPUT-RECORD CONTAINS SEARCH-TEXT
WRITE OUTPUT-RECORD
END-IF
READ INPUT-FILE
AT END MOVE 'Y' TO END-OF-FILE
END-PERFORM.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?
Give some examples of command terminators?
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?
Explain about different table spaces.
What is the default value(s) for an initialize and what keyword allows for an override of the default?
how do you reference the variable block file formats from cobol programs
What is the difference between perform … with test after and perform … with test before?
What is the difference between Call and a Link?
How can we find that module can be called – whether DYNAMICALLY or STATICALLY?
What is the difference between binary search and sequential search?
What is the difference between a binary search and a sequential search what are the pertinent cobol?
What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?
How you can characterize tables in cobol?
Explain what you understand by passing by value.
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..