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 do u handle errors in BMS macro
how do you define single dimensional array and multidimensional array in your cobol?
What are INPUT PROCEDURE and OUTPUT PROCEDURE?
Write a program to explain size error.
A table has two indexes defined. Which one will be used by the SEARCH?
i was faced one question- i have value -00001234.56 Suppress the zeroes and the output should be -1234.56 But Not - 1234.56 spaces should not be available after suppressing the zeroes. logic in jcl and cobol?
What is report-item in COBOL?
What rules are followed by the search verb.
What is the Purpose of Pointer in the string?
Have you used comp and comp-3 in your project? And how?
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
What is redefines clause in COBOL?
what happens if parmparameter passes zero bytes to the program
How to know whether the module is dynamical or statistical?