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 |
The following entries appear in the WORKING-STORAGE SECTION: 01 DATE-TODAY. 05 YY PIC XX VALUE "90". 05 MM PIC XX VALUE "12". 05 DD PIC XX VALUE :31". 01 DATE-EDIT PIC XX/XX/XX. MOVE DATE-TODAY TO DATE-EDIT. (a) 901231 (b) 90/12/31 (c) 31/12/90 (d) 311290
is it possible to pass an SQL query inside a jcl which is inside a cobol program?
What is R-mode and A-mode?
If a file has 1000 records.. if i have to replace the first and last characters of the file with another character. how it can be done....
can i give 9(10) in comp 3 instead of s9(10) ? if i can give wht would be ths ans
What is the size of s9(19)comp3? explain
I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?
How to print 10 to 1 if the input have only 10 digit number?
Give some advantages of REDEFINES clause?
how many bytes does a s9(12)COMP-4 field occupy?? a.2 b.4 c.8 d.1 ans with reason please
what is linkcard in cobol?
What care has to be taken to force program to execute above 16 Meg line?