Copy spool file partially

20 pts.
Tags:
AS/400
CPYSPLF
Spool files
Hi,

I want to copy only the last 10 lines of a spool file. Can Anyone tell me how I can do it?

 



Software/Hardware used:
As/400 , CL

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here’s a start on one way of doing it:<pre>
DLTF FILE(QTEMP/SPOOLFILE)
MONMSG CPF0000
DLTF FILE(QTEMP/LAST10RCD)
MONMSG CPF0000

CRTPF FILE(QTEMP/SPOOLFILE) RCDLEN(132)

CPYSPLF FILE(&FILE) TOFILE(QTEMP/SPOOLFILE) +
JOB(&NBR/&USR/&JOB) SPLNBR(&NUM) MBROPT(*ADD)

RTVMBRD FILE(QTEMP/SPOOLFILE) NBRCURRCD(&NbrRecords)

CHGVAR &StartRRN ( &NbrRecords – 9 )

CPYF FROMFILE(QTEMP/SPOOLFILE) +
TOFILE(QTEMP/LAST10RCD) FROMMBR(*FIRST) +
TOMBR(*FROMMBR) MBROPT(*REPLACE) +
CRTFILE(*YES) FROMRCD( &StartRRN )</pre>

I wouldn’t do it that way, but I suspect that it’s pretty close to the best way for you. The QTEMP/LAST10RCD file will have the last 10 spooled records.

If the spooled file is not compatible with CPYSPLF, you’ll have to do it the ‘right’ way. Much more complex, but much more flexible.

Tom

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TomLiotta
    "Copy" to where? Tom
    125,585 pointsBadges:
    report
  • MathewGeorge
    Thanks for the solution. I am writing to flat PF.
    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: