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


Please Help Members By Posting Answers For Below Questions

How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?

893


How to know whether the module is dynamical or statistical?

858


Our issue is there seems to be a disconnect, or no link, between our SELECT statement and our SD. We had SELECT SORT-FILE and SELECT SORT-FILE ASSIGN TO SORTWRK. ASSIGN TO SORTWRK1 SORTWRK2 SORTWRK3 SORTWRK4. with SD SORT_FILE RECORD CONTAINS 7833 CHARACTERS. In either case, at run time, the system ignored our SORTWRK# DD statements and allocated 16 sort works with the SORTWK## naming convention. Any ideas why the system does not recognize the connection? We do not even need the SORTWRK DD statements. Thanks

2584


)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?

1728


What is the usage of comp fields in cobol?

859






How can we find that module can be called – whether DYNAMICALLY or STATICALLY?

955


What is Pic 9v99 Indicates in COBOL?

921


What are INPUT PROCEDURE and OUTPUT PROCEDURE?

910


I have program P1 which calls file F1 which has 100 records and following structure 001 .................. 002 .................. 003 .................. 098 .................... 099 ................... 100 .................... Now I want to read these files and write these records in file F2 in following manner. 001 ...... 051 ..... 002 ...... 052 ..... 003 ...... 053 ..... .......... ....... .......... ....... .......... ....... 048 ........ 098 ...... 049 .......... 099 ....... 050 .... 100 ......

11488


What is the difference between binary search and sequential search?

841


What is the use of intialize verb?

956


Write a program to enter and display the names of students in a class using the occurs clause.

906


) How do u handle errors in BMS macro

1690


What are the rules of the move verb?

929


State the various causes of s0c1, s0c5 and s0c7.

836