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 get the result of your program directly on your pc?
What is the difference between Global and External Variables?
State the various causes of s0c1, s0c5 and s0c7.
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?
Write a cobol program making use of the redefine clause.
) How do u handle errors in BMS macro
Explain about different table spaces.
What is a SSRANGE and NOSSRANGE?
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
How do we get current date from system with century in COBOL?
What is report-item in COBOL?
What is the difference between Call and a Link?
What is rmode(any) ?
how do you reference the printer file formats from cobol programs