REXX to insert/delete lines in a sequential file.

Ask/Clarify the questions on TSO, CLIST & REXX

Moderators: Veera, Moderator Group

Post Reply
Mr.Protagonist
Member
Posts: 1
Joined: Tue Apr 16, 2013 4:14 pm

REXX to insert/delete lines in a sequential file.

Post by Mr.Protagonist » Tue Apr 16, 2013 4:31 pm

Hi All,

I need to write a Rexx script which inserts/deletes lines in a particular way.

The sequential file would already have some text data in it.

My requirment is like this.

1) I need to insert lines just before a string (lets say 'Thanks')
ex:-
HI,
THE FOLLOWING ERRORS ARE FOUND.

THANKS,
MR.PROTAGONIST


So the new lines should be inserted between the strings 'THE FOLLOWING ERRORS ARE FOUND' and 'THANKS,'
2) When I submit my rexx script for the 2nd time, first these newly inserted lines sholud be deleted and then new set of lines should be inserted.


Note:
These new set of lines which are inserted/deleted are not constant in number. They can be 2,4,8 or any other number. The only thing that's constant is, these lines are always inserted before a particular string(here 'THANKS,')


Thanks in advance
Thanks,
Mr.Protagonist

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Tue Apr 16, 2013 6:06 pm

I think the first pass sounds relatively straight-forward. Read one record at a time. If the record does not contain the value of "THANKS," then write it out again. If it does, write out the data to be inserted, then continue on like before.

For the second pass, I'm not sure. Can you somehow mark the records that have been inserted on the first pass so you can identify them here?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Apr 16, 2013 7:21 pm

Read your original input the second time, and just add the new lines, to a 2nd output.

You'll end up with:

Original input file (I hope you didn't really want to do it "in place")
First Output File (with first message before "THANKS")
Second Output File (with second message before "THANKS")

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Wed Apr 17, 2013 12:46 pm

Or you could have separate files for each part and just concatenate them together.
Regards
Nic

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others