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

Scan a file for a string & update a counter on finding.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ruchi Mittal

New User


Joined: 15 Oct 2007
Posts: 1
Location: Bangalore

PostPosted: Tue Oct 16, 2007 7:51 pm
Reply with quote

I've a file where I need to scan an area (from col x to col y, which is the entire record) looking for "M=?" for each record and then perform certain para based on ? value.

eg.

Code:
----|----|----|----|----|----|----|----|----|----|
RECORD1AAAAAAAAAAAAAAAAAAAM=PAAAAAAAAA
RECORD2BBBBBBBBBBBBBBBBBBBM=RBBBBBBBBB
RECORD3CCCCCCCCCCCCCCCCCM=PCCCCCCCCCCC
RECORD4DDDDDDDDDDDDDDDDDM=GDDDDDDDDDDD
RECORD5DDDDDDDDDDDDDDDDDM=GDDDDDDDDDDD
----|----|----|----|----|----|----|----|----|----|



The literal being searched (M=?) may occur at any position in the entire record.


Thanks all..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 16, 2007 11:30 pm
Reply with quote

Hello,

You can do what you want using reference modification.

Define a variable that will be the displacement into the data area (i.e. 77 DSPL PIC 999 COMP-3 VALUE ZEROS.).

Set up a loop that moves the starting position (x) to dspl,
compares the current position to 'M=" (i.e. IF DATAAREA(DSPL:2) = 'M='),
and increments DSPL until end-of-data is reached (y - 2) or 'M=' is found.

If 'M=' is found, use the byte after the "=". If 'M=' is not found, do whatever is appropriate.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding and researching jobs All Other Mainframe Topics 0
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
Search our Forums:

Back to Top