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 |
How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?
How can you add a particular field in copybook?
How is sign stored in Packed Decimal fields and Zoned Decimal fields?
how would find total records in files using seqientional
In COBOL programming, what is PERFORM? What is VARYING?
Consider the following code: 77 A PIC 99V99 VALUE 55.35 77 B PIC 99V999 VALUE 32.754 ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!" What will be the result ? (a) A=88.10, B=32.754 (b) A=87.00 B=32.754 (c) A=87.10 B=32.754 (d) ERROR!!! will be DISPLAYed on the screen.
01 var1 pic s9(9)v99. 01 var2 pic x(30). procedure division. move 12345.99 to var1. move12345.99 to var2. display var1. display var2. what is the output?
How can I find the maximum value of a field in a file while reading the file dynamically? without using sort function. Suppose i have a file with fields Timestamp, description, teamname, teamnumber.. i have read the file till end and find the maximun value of timestamp which is not in sorted order.. can we use function max(timestamp)?
Write a program to concert an Indexed file into Sequential file?
Syntax for JCLLIB & JOBLIB???
if a>b continue display x. dispaly y. end-if display 1 display 2. display 3. what should be my output ?
Is it possible to mutliply a comp variable with an comp-3 variable. Will there be any error if i do it?