Page 1 of 1

File Operation thru ISPF Services

PostPosted: Fri Aug 21, 2009 3:33 pm
by eprasad629
Hi,

I'm currently working over a REXX module which makes use of ISPF services to delete/add line in a sequential file.

I'm able to add a new line at the end of the file by using ISPF service command. I don't know how to delete a line (which could be at start/middle/last) from a file.

Currently I'm processing the file by

1. Reading the file contents by LMGET and storing it to a stem variable.
2. Erase the file completely
3. Re-Create the file with the same name
4. Searching the line to be deleted in the stem variable which was created earlier
5. If the search string matches with the stem variable, NOP, else LMPUT to write the content back to new file.

I think the code which I have written is so vague which I want to get rid off.

Could you please advise how this could be simplified further?

Please let me know if the information is not clear.

Many thanks in advance.

Re: File Operation thru ISPF Services

PostPosted: Fri Aug 21, 2009 4:57 pm
by expat
You have a dataset, and you wish to edit / delete a line or lines.

What would I do ............. use an ISPF edit macro to process the dataset.
"ISPEXEC EDIT DATASET('dataset name') MACRO(macroname)"
- - The macro will need to be in a dataset allocated to either SYSEXEC or SYSPROC unless you use the ALTLIB statement to allocate your own PDS as part of the concatenation.

Inside the edit macro
1) Find the line that needs to be deleted, "ISREDIT F 'string' FIRST"
2) Get the line where the string was found, "ISREDIT (CRSLINE) = CURSOR"
3) Delete the line where the cursor is, "ISREDIT DELETE "CRSLINE
4) Save the changes on exit from the macro, "ISREDIT END"

Take the time to read the ISPF edit macro manual - it is full of great examples and is easy to follow.