If you are doing a read/write to a PS, you can simply use a diposition of MOD and do normal R/W using the EXECIO command
Reading from PS
"ALLOC DA('A.B.C') FI(DD1) MOD"
"EXECIO * DISKR DD1 (STEM NUM. FINIS)"
here the stem variable NUM gets populated where NUM.0 contains the total number of records fetched. NUM.1 , NUM.2 , ...so on contains the actual records
Writing to PS
"ALLOC DA('A.B.C') FI(DD2) MOD"
NUM.1 = "THIS IS FIRST LINE"
NUM.2 = "THIS IS SECOND LINE"
"EXECIO * DISKW DD2 (STEM NUM. FINIS)"
Because you have used dispostion of MOD, the existing records won't be overwritten but the new ones get appended to old ones
In case of PDS members, you can't use the dispotion of MOD as it gives back some ERROR. So you have to read the whole file into a stem variable(or stack)and write back the stem to the member. Now any consecutive write will start appending the records instead of overwriting the old ones...
Here, i have a code for doing that
ADDRESS TSO
"FREE DDN(INDD)"
"ALLOC DA('A.B.C(ABC)') FI(INOUT)"
"EXECIO * DISKR INOUT (STEM DUMMY. FINIS)"
"EXECIO * DISKW INOUT (STEM DUMMY.)"
TEXT.1 = "I AM FEELING GREAT NOW"
"EXECIO * DISKW INOUT (STEM TEXT. FINIS)"
This might probably help you
good luck and have fun!
Ashish