Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Bypass certain records in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: Bypass certain records in COBOL
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Aug 08, 2014 9:49 am    Post subject:
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 User


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

PostPosted: Fri Aug 08, 2014 10:19 am    Post subject:
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    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Aug 08, 2014 4:57 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Aug 08, 2014 7:29 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us