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
Answer Posted / 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 |
Post New Answer View All Answers
how to move the records from file to array table. give with code example
I have a File that has duplicate records. I need only those records that occur more than thrice.?
i need a small 3d program using inline and outline.
What are the access modes of START statement?
How can you get the ksds file records into your cobol program?
Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.
What is the difference between next sentence and continue in cobol programing language?
What is the problem of ordered sequential files access?
how can we apply for HSBC exam(Mainframe) in India??? i went to their site and was told to submit my CV ,. etc..( totally confusing...)
how to convert the recors form vsam file to db2 table tru file aid
i want a program using by if, evaluate , string, unstring, perform, occurs?
What is the difference between perform … with test after and perform … with test before?
) how do u code after getting data?
HOw can I get the negative sign while deduct high value from low value
Describe the cobol database components?