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.
Answers were Sorted based on User's Feedback
Answer / divyakiruthiga
Step 1: Read the first record from the PS file into a ws-variable WK-ROW.
Step 2 :INSPECT WK-ROW TALLYING WK-TXT-COUNT FOR ALL 'TEXT'.
Step 3: If the WK-TXT-COUNT is greater than 0, then write the record to the output file.
Step 4: Initialize the WK-TXT-COUNT
Step 5: Continue the above process till end of file.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
What are 77 levels used for?
What are the cobol coding sheets?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?
How can you submit a job from COBOL programs?
What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?
How to retrive the 9th records out of ten records using the cobol program ?
input:-AABBCCDDEFGHIIJ output:- ABCDEFGHIJ Here in input we hav the duplicate characters i.e repeating characters.SO we should eliminate the duplicate characters and should display the output in ascending order.
.How to add one input & one Out file in existing cobol program. how approach tell me step by step.
what is dynamic array in cobol? what is the difference b/w array and table in cobol?
How do you get the data to code the BMS macro?
Suppose i have a Cobol field of 10 byte. it contains a decimal sign.How to know where is the point location?
can we use the two 01 level in file discription ?