Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
PLAN B - Write a ReCover SPLF Command
has no ratings.
Published: 17 Oct 2012
Revised: 23 Jan 2013 - 1728 days ago
Last viewed on: 16 Oct 2017 (3311 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

PLAN B - Write a ReCover SPLF Command Published by: Bob Cozzi on 17 Oct 2012 view comments(5)

A user deleted an entire OUTQ's SPOOL files because they "couldn't find their Report".

Now the VP is pissed. Since they (as I suggested in another post) do not backup their SPLFDATA(*ALL) each evening, they are screwed!

So my plan B is to regress to circa 1984 where I would sit up late at night and read the IBM CPF "internals" manuals and try to decompose the SPOOL Database File Structure in QSPL.

Once accomplished, I'll scan the members in QSPL and for each occurrence of the Report identification, I will run my RECOVER SPOOL FILE command. And of course it will only work for SCS reports but that's all I have to worry about, today (I mean tonight). Yell

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: PLAN B - Write a ReCover SPLF Command
Posted: 4 years 11 months 29 days 15 hours 32 minutes ago
Edited: Thu, 18 Oct, 2012 at 09:38:37 (1825 days ago)

Update1: Got it to function at 80% for SCS SPOOL Files. I was able to reprint about a dozen previously deleted SPOOL files exactly as they were original printed.

According to the IBM SPOOL File manual, QSPL database members are cleared after a SPOOL File is printed (and not saved) or it is deleted. Although I do not see that actually occurring--rather it tends to mark the SPOOL members a unused or 'cleared' and does not actually perform a CLRPFM on the member. Therefore I was able to recover over 23 SPOOL files deleted from a user's OUTQ.

There is an issue with "end of SPOOL file" however. Sometimes its fine other times it seems to have remnants from other SPOOL files or other parts of "this" SPOOL file.

My thinking on this one is that they reuse the SPOOL file members (that's a fact, not a guess) and may avoid deleting the existing records in the SPOOL database file for performance reasons. Therefore their must be a code or SPOOL file ID embedded in the record check-digits or perhaps another EOF code. Still hunting.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: PLAN B - Write a ReCover SPLF Command
Posted: 4 years 11 months 29 days 10 hours 52 minutes ago

I would guess that RCLSPLSTG is the SPOOL equivalent of CLRPFM. It's been a while since I read up on spooled files, but they use storage progressively, when a spool file is deleted, that storage is then available for newly created spool files (before new storage is reserved). Performing a RCLSPLSTG frees up storage reserved for spool files.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: PLAN B - Write a ReCover SPLF Command
Posted: 4 years 11 months 29 days 9 hours 57 minutes ago

Neil, right but the docs also say that the members in QSPL are cleared. The word "clear" could be a contextual misunderstanding on my part, I read it as CLEAR (as in CLRPFM) whereas they may simply set the header to X'00' or something like that. Still researching, but so far I am able to reproduce deleted SPOOL files however, some have extra content at the end--beyond the original SPOOL file.

My guess is that they do NOT actually do a CLRPFM but rather set it to X'00' in the first 16 or so bytes of the member. Then leave the records in the file. So if the new SPOOL file using "this" member is shorter than the previous SPOOL file, the extra stuff may still be in the file, but the new file knows where it ends, so its no big deal.

I just have to discover what those readers are--it was pretty easy to learn (teach myself) the SCS data stream in an hour, but the headers on each record in the QSPL members is not intuitive. Not that it needs to be.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: PLAN B - Write a ReCover SPLF Command
Posted: 4 years 11 months 28 days 17 hours 29 minutes ago

They probably do something like set the spool length to zero. Of course you don't know what the correct length should be off the bat, but should you guess right you would not get the extra (former spooled output) stuff at the bottom. At least that's my guess.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: PLAN B - Write a ReCover SPLF Command
Posted: 4 years 11 months 28 days 16 hours 44 minutes ago

Right... looks like that ending record contains the last parts of the SPOOL file and when it ends, the prior record's data is replicated verbatim. Its almost as if they build a space with the SPOOL data, write the new stuff to it, then save it to the database, but don't first clear the space before continuing. So, yes, I believe the first 16 bytes or so of the SPOOL file contained the spool data space length.

The cool thing is, it really does print just fine until you get whatever is in that last record to show up. Since the records are either 512 (v7r1 and later) or 4079 (pre-v7r1) you can end up with a lot of trailing crap on the report... but hey, this is an UNDELETE SPOOL FILE command nothing more, so perhaps that's good enough.