View previous topic :: View next topic
|
Author |
Message |
josepnass
New User
Joined: 31 Dec 2003 Posts: 16 Location: dc
|
|
|
|
Hi All,
I want to bypass certain records in COBOL I.e. reading a rile if cases equal 223 bypass if not process
Thanks ALl |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Is it a fyi or you want to know how the logic of reading the file till end and for each record check the specific field which = 223 and if you find so then skip and read next record? |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
I don't know about Cobol, but writing code to skip unwanted input is trivial in essentially all programming languages I've ever used. Here is an Assembler example analyzing SMF data.
Code: |
....
READ GET SMF Read an SMF record
LR 3,1 Copy the record address to reg 3
USING SMFREC,3 Establish SMF record addressability
CLI TIVRCDTY,1 Test if dump header
BE READ Ignore it if so
CLI TIVRCDTY,2 Test if dump trailer
BE READ Ignore it if so
TP TIVRCDTE Verify record date is packed decimal
BNZ READ Ignore record if not
ICM 0,B'1111',TIVRCDTS Load record time of day
BM READ Ignore record if time of day is bad
C 0,=A(100*24*60*60) Test time of day
BNL READ Ignore record if time of day is bad
CLI TIVRCDTY,34 Test if TSO end of session
BNE READ Br if not
TP TIVONDTE Verify LOGON date is packed decimal
BNZ READ Br if not
.... |
As you can see data is ignored for a multitude of reasons.- Record types 1 or 2.
- Record date is not packed decimal
- Record time of day doesn't make sense.
- Record is not type 34
- TIVONDTE field in a type 34 record is not packed decimal
For those of you who are not up date in Assembler, the TP instruction tests a field to see if it contains valid packed decimal data. |
|
Back to top |
|
|
josepnass
New User
Joined: 31 Dec 2003 Posts: 16 Location: dc
|
|
|
|
reading the file and not in assembler but Cobol is record type is 123 for example then bypass that record and move on ..
Rohit Umarjikar wrote: |
Is it a fyi or you want to know how the logic of reading the file till end and for each record check the specific field which = 223 and if you find so then skip and read next record? |
|
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Mainframe Skills: cobol adabas natural JCL
As far as i see it, you know already, but you want to test if we know. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Note: This is only for example and change the file layout as per your requirements.
Code: |
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT file-in ASSIGN TO Input.
DATA DIVISION.
FILE SECTION.
FD file-in
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD.
01 ws-rec.
05 ws-check-code PIC x(3).
05 Ws-other PIC x(7).
WORKING STORAGE SECTION.
05 WS-EOF PIC x(1) VALUE 'N'.
88 eof VALUE 'Y'.
PROCEDURE DIVISION.
OPEN INPUT file-in
perform 100-read-infile thru 100-exit until eof
100-read-infile.
initialize ws-rec
read file-in
AT END
SET eof TO TRUE
NOT AT END
if ws-check-code = '123' or '223'
continue( do nothing/skip)
else
process
end-if
end-read
.
.
.
Close file-in
goback. |
|
|
Back to top |
|
|
|