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 |
Consider the following: 77 A PIC 9(10) 77 B PIC 9(10) 77 C PIC 9(19) MULTIPLY AB BY B GIVING C Which of the following is true ? (a) The execution of the above may result in size error. (b) The execution of the above will result in size error. (c) The definition of C is invalid resulting in compilation error. (d) No error will be thee and the program would proceed correctly.
How do define dynamic array in cobol.
can we use COPY statement in w-s section? how?
can you please let me know if there is any walkins for COBOL/PLI/DB2/IMS/JCL in pune other than IBM and ITC infotech
whats the disadvantage of search all over search?
how do you reference the variable unblock file formats from cobol programs
I have put two write operations in a single para for two different conditions.Will that lead to an abend or run successfully and write two records?
What are 77 levels used for?
What is difference between static and dynamic call in cobol?
How can you display the SPOOL information ?
what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.
If i initialize the 01 level variable in array, will it initialize all the array elements (occurs)?