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



Extract only those records from a PS file which are having word 'TEXT' in the records usin..

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

Extract only those records from a PS file which are having word 'TEXT' in the records usin..

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

Post New Answer

More COBOL Interview Questions

2)Where the Plan is located in CICS-DB2?

1 Answers   IBM,


if you code move high-values to variable,can you move it into numeric variable or alphanumeric variable?

1 Answers   Patni,


How can you submit a job from COBOL programs?

2 Answers   ITC Infotech,


How to solve SOC7. I have the cobol coded as below 01 A PIC 9(4). 01 AIN REDEFINES A. 05 AIN1 PIC S9(4) 01 B PIC 9(4)V99. 01 BIN REDEFINES B. 05 BIN1 PIC S9(4)V99. PROCEDURE DIVISION. START-PARA. INITIALIZE A AIN B BIN. ACCEPT A B. DISPLAY 'VALUE OF A=' A. DISPLAY 'VALUE OF B=' B. DISPLAY 'VALUE OF BIN1=' BIN1. DISPLAY 'VALUE OF AIN1=' AIN1. COMPUTE AIN1 = BIN1 - AIN1. DISPLAY 'VALUE OF AIN1=' AIN1. When i'm executing this code i'm getting SOC7 for A = 12 & B=34. Can someone explain SDSF OUTPUT DISPLAY TCOM058R JOB05458 DSID 102 LINE 0 COLUMNS 02- 81 COMMAND INPUT ===> SCROLL ===> CSR ********************************* TOP OF DATA ********************************** VALUE OF A=12 VALUE OF B=34 VALUE OF BIN1=34 VALUE OF AIN1=12 CEE3207S The system detected a data exception (System Completion Code=0C7). From compile unit PROG1 at entry point PROG1 at statement 29 at compile +000004CE at address 00007ECE. Please address how to solve this issue Thanks in advance.

1 Answers  


At the minimum, which division of COBOL is enough to be coded?

3 Answers   CTS,






The maximum number of dimensions that an array can have in COBOL-85 is ?

11 Answers  


How to retain the Duplicates in the one records?

3 Answers   CS,


how to move the records from file to array table. give with code example

0 Answers   ADP, Syntel,


) how do u code after getting data?

0 Answers   IBM,


i have a requrement in A as viswa!@#$%&^**reddy i need to move viswareddy in B without junk values pls say how to do ths reply fast

4 Answers   L&T,


If I want to increase the Limit in GDG. What should I do?

1 Answers   IBM,


hi dudes.....can any one help me..... what is SET TO TRUE all about,anyway?

1 Answers  


Categories