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
What are INPUT PROCEDURE and OUTPUT PROCEDURE?
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
how do you reference the variable unblock file formats from cobol programs
How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?
What is amode(31)
Can we redefine the field of x(200) to less than 200?
How to use the same COBOL program in Batch and CICS on lines? explain with an example
Write the code implementing the perform … varying.
What is the LINKAGE SECTION used in COBOL?
please..could u give an example about USAGE IS POINTER ..and explain why and when we use it ?
What are the different rules for performing sort operation?
Which mode is used to operate the sequential file?
What is difference between static and dynamic call in cobol?
What is comp-1 and comp-2?
how do you reference the rrds file formats from cobol programs