I have a seq file with different fields one field is address
with pic x(50) as input in a cobol program. In address there is
'PUNE' at any different positions in the address field ( form 1
t0 50) . My requirement is select the fields with address 'PUNE'
by using cobol. Please suggest
Answers were Sorted based on User's Feedback
Answer / jagan
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-3270.
OBJECT-COMPUTER. IBM-3270.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO INFILE
SELECT OUT-FILE ASSIGN TO OUTFILE
DATA DIVISION.
FILE SECTION.
FD IN-FILE.
01 INPUT-REC.
05 IN-NAME PIC X(20).
05 IN-ADDRESS PIC X(50).
FD OUT-FILE.
01 OUT-REC.
05 OUT-NAME PIC X(20).
05 OUT-ADDRESS PIC X(50).
WORKING-STORAGE SECTION.
01 NO-MORE-RECORDS PIC X(1).
88 END-OF-FILE VALUE 'Y'.
88 NOT-END-OF-FILE VALUE 'N'.
01 COUNT PIC 9(1).
PROCEDURE DIVISION.
MAIN-PARA.
PERFORM READ-FILE UNTIL END-OF-FILE.
STOP RUN.
READ-FILE.
MOVE 0 TO COUNT.
READ IN-FILE AT END SET END-OF-FILE TO TRUE
NOT AT END
IF IN-ADDRESS NOT EQUAL TO SPACES OR LOW-VALUES
INSPECT IN-ADDRESS TALLYING COUNT FOR ALL
'PUNE'.
IF COUNT > 0
WRITE OUT-REC FROM INPUT-REC
END-IF
END-IF
END-READ.
END-READ-FILE.
The above piece of code should do what you have asked .
Correct me incase there are any errors.
| Is This Answer Correct ? | 23 Yes | 2 No |
01rec1. 05 a pic 999v99 value 123.12 05 b pic 99v9 value 45.9 02 rec2. 05 x pic 999v99 05 y pic 99v99 05 z pic x(3) value 'abc' if rec1 is moved to rec2 then what is the value of rec2?
what is the diff b/w select stsmt and cursor ?
Write a program to enter and display the names of students in a class using the occurs clause.
How to code fscode 10 in cobol program? Where yoy code in your pgm?give ans for the question.
What was removed from COBOL in the COBOL II implementation?
I have a Main Program which is calling Sub-Program which is a DB2 pgm. What will happen if I am not closing the cursor used in the Sub-program? Please advise..
what is call by value and call by reference ?
3 Answers Infosys, ITC Indian Tobacco Company,
if you code move high-values to variable,can you move it into numeric variable or alphanumeric variable?
what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.
I try to use some column names in my cobol progorm but these column not in db2 table ..when do i get error ..while bind time or runtime?
i want to use only first 100 records from a file.plz tell me how to write JCL for this(for read,copy,write operations).plz give me details of all posible JCL utilities?
which is better either static call or dynamic call? and why?