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

read then Write from a perticular keyword to end of a file


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

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Tue Apr 07, 2009 11:59 am
Reply with quote

There are few records in a file, i want to read when i found the keyword COMPLETE in that file. So i want to read the file from that line COMPLETE to the end and write also.

exp: file is like that
xxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyy
gggggggggggggg
he jajajja COMPLETE nnnn
aaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbb
...
So i want to write the records from aaaa.... that is from 5th line.. as i got the keyword COMPLETE in the previous record, so i want to write records from the next record to the last..
i.e..
aaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbb
...

How to put the read logic in cobol and write logic..
Thanks
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue Apr 07, 2009 1:05 pm
Reply with quote

Maxsubrat, you will have to read every record in FILE 1 in order to search for the variable "COMPLETE ". Once it is found ,you can write in the FILE 2 from the remaining records of FILE 1.

WTF
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 4:11 pm
Reply with quote

does the COMPLETE keyword start at one particular position ?
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 Apr 07, 2009 8:37 pm
Reply with quote

Hello,

It should not matter at which position COMPLETE begins. . .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Apr 07, 2009 8:43 pm
Reply with quote

Leo might have been thinking in terms of the fact that searching for "COMPLETE" would be faster if it started at a known location rather than having to use INSPECT.
Back to top
View user's profile Send private message
maxsubrat

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Tue Apr 07, 2009 9:11 pm
Reply with quote

dick scherrer wrote:
Hello,

It should not matter at which position COMPLETE begins. . .



do u know the solution..?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 9:35 pm
Reply with quote

maxsubrat wrote:
dick scherrer wrote:
Hello,

It should not matter at which position COMPLETE begins. . .



do u know the solution..?


more than likely, Mr. Scherrer knows the answer. considering all the posts in this thread, what about the answer do you not understand, Maxsubrat?
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 9:36 pm
Reply with quote

dick scherrer wrote:
Hello,

It should not matter at which position COMPLETE begins. . .


hello Dick scherrer, As Terry said it would definitely help if COMPLETE begins is at a fixed position.

maxsubrat,

you didnt answer whether complete begins at a particular position.

If it does not, read file sequentially,

move the record into working storage and do a INSPECT clause on it looking for COMPLETE, at the same time keep incrementing a counter for number of records read.
If NOT found, keep reading next records until EOF reached.
If found, read next record and write into o/p file. Set some flag for COMPLETE found.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Apr 07, 2009 10:41 pm
Reply with quote

dbzTHEdinosauer wrote:
maxsubrat wrote:
dick scherrer wrote:
Hello,

It should not matter at which position COMPLETE begins. . .



do u know the solution..?


more than likely, Mr. Scherrer knows the answer. considering all the posts in this thread, what about the answer do you not understand, Maxsubrat?

Mr Scherrer might be holding out for that big pay raise before he answers the question. icon_lol.gif
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 Apr 07, 2009 11:38 pm
Reply with quote

Quote:
do u know the solution..?
Unless i completely misunderstand the requirement, yes. . .

Actually the post following my last reply is one way. . .

Another is to code a loop and use reference modification to determine if a record contains COMPLETE.

Quote:
Mr Scherrer might be holding out for that big pay raise before he answers the question.
Sure, instead of $ - a title icon_wink.gif

d
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 07, 2009 11:41 pm
Reply with quote

Quote:
Sure, instead of $ - a title
Be careful what you ask for, Dick -- somebody might bestow something like "Maintainer of the Porcelain Throne" upon you! icon_confused.gif
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 Apr 07, 2009 11:54 pm
Reply with quote

Was thinking that with the "Mr", i'd already been bestowed. . . icon_rolleyes.gif

Quote:
"Maintainer of the Porcelain Throne"
More like "Driver of the Porcelain Bus" icon_wink.gif
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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 Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top