OK. Now, I won't have the opportunity to test for a couple of days, so I won't guarantee that it's error-free; to the left, debugging is one of the joys of the software developer's life.
Your exec will look about like this;
/* Rexx */
lastkey = ''
dsn = ''
drop record.
"EXECIO 1 DISKR TULIN"
do while (rc=0)
pull record.1
thiskey = substr(record.1,1,4)
if (thiskey¬lastkey) then do
if (lastkey¬='') then do
"EXECIO 0 DISKW TULOUT (FINIS"
"FREE FI(TULOUT)"
address ispexec "FTOPEN TEMP"
address ispexec "FTINCL FOO"
address ispexec "FTCLOSE"
address ispexec "VGET ZTEMPF"
"SUBMIT '"ztempf"'"
dsn = "BARIN.#"thiskey
"ALLOC FI(TULOUT) DA("dsn") NEW SPACE(1,1) TRACKS LRECL(80)",
"RECFM(F B)"
end
lastkey = thiskey
end
"EXECIO 1 DISKW TULOUT (STEM RECORD.)"
"EXECIO 1 DISKR TULIN"
end
I assume that you're running this in background ISPF, and that TULIN is allocated in the JCL. It appears that the key is the first four characters of the record; if not, adjust the parameters of the
substr function accordingly.
The skeleton FOO will be:
//&SYSUID.BAR JOB other parameters
//*
//STEP0001 EXEC PGM=BAR
//BARIN DD DSN=&DSN,DISP=SHR
//BAROUT DD DSN=&SYSUID..BAROUT.#&LASTKEY,other parameters
other DD statements as needed
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day