IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Bypass certain records in COBOL


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
josepnass

New User


Joined: 31 Dec 2003
Posts: 16
Location: dc

PostPosted: Fri Aug 08, 2014 6:58 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Aug 08, 2014 9:49 am
Reply with quote

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
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Fri Aug 08, 2014 10:19 am
Reply with quote

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.
  1. Record types 1 or 2.
  2. Record date is not packed decimal
  3. Record time of day doesn't make sense.
  4. Record is not type 34
  5. 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
View user's profile Send private message
josepnass

New User


Joined: 31 Dec 2003
Posts: 16
Location: dc

PostPosted: Fri Aug 08, 2014 4:53 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Aug 08, 2014 4:57 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Aug 08, 2014 7:29 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top