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 is the meaning of 'TALLING' verb in cobol?
is it mandatory to give data division before procedure division ? wht happens if i give procedure division first thn data division ? reply soon
I got user abend U4038 while compiling my runjcl.. can anyone help me?
What is the difference between SEARCH and SEARCH ALL? What is more efficient?
When the working storage variables get allocated? a.At Compile time b.At starting of the run time c.At end of the run time. d.None of these
what is jcl approach for programming?
01 ws-p pic 9(2). 01 ws-q pic 9(2) value 01. 01 ws-r pic 9(2) value 99. p.d. compute p = q + r what will be result of p ans(00) but my question is that how i got 10 on the place of 00. (truncation will ocuure on right side not left). please tell me ?
How to Write the RESTART Logic Using COBOL?
4 Answers GalaxE, L&T, Syntel, TCS,
Difference between next and continue clause
How to display string in the reverse order using occurs clause?
i have mainprogram and subgram...if i compile mainprogram without stop run..what will u get in compilation time?
If I want to increase the Limit in GDG. What should I do?