15 pts.
 Copy Spooled File to a Source Physical File Member
How do I copy a spooled file listing into a member of a source physical file?

I accidentally deleted the source member, but have a spooled copy taken via option 6.  I would like to convert the spooled file back into the deleted member.



Software/Hardware used:
ASKED: December 7, 2010  4:13 PM
UPDATED: December 9, 2010  9:51 PM

Answer Wiki:
Step 1 - CRTPF QTEMP/WFILE RCDLEN(133) Step 2 - CPYSPLF QPSUPRTF QTEMP/WFILE (your job name/number) Step 3 - Use WRYQRY to create a new PF. Define result fields to parse the input reecord into the 3 fields needed for a source PF. Also use Select to omit the records from page heading. Step 4 - Use CPYF to copy this new file into your source file member. Use FMTOPT(*CVTSRC)
Last Wiki Answer Submitted:  December 7, 2010  4:41 pm  by  CharlieBrowne   32,785 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,785 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

CRTPF QTEMP/WFILE RCDLEN(133)

Although a length of 133 is reasonable, it implies two likely assumptions. First, it implies that the spooled file record length is 132. Second, it implies that the CPYSPLF command will specify the CTLCHAR(*FCFC) option.

If either of those assumptions isn’t true, then RCDLEN() might need to be a different value.

Tom

 107,735 pts.

 

After some thought, you consider this:

  • Create a SQL table, not in QTEMP:
    CREATE TABLE mylib.SRCSPLF ( 
    	SRCDATA CHAR(132) CCSID 37 NOT NULL )
  • Create a VIEW over the table:
    CREATE VIEW mylib.SRCSPLFV ( 
    	SRCDATA ) 
    	AS 
    	SELECT SUBSTR(SRCDATA, 9, 80) AS SRCDTA FROM mylib.SRCSPLF

The table will be the target for CPYSPLF. Then the view is the source for CPYF. By sizing the SRCDATA column and the SUBSTR() appropriately, you get just the columns of the spooled file that have the source data.

You might even have a WHERE clause on the view that drops the page headings from the source listing. The source member will need some editing to remove lines such as page headings.

Tom

 107,735 pts.

 

Open a new member in your source file using SEU; F15=Browse/Copy options; Select 2=Spool file, and under the Browse/copy spool file section enter the spool file name, job, user, job number, and spool number; copy the spool file into the member and make any necessary adjustments to the alignment (LT and RT are your friends).

 5,670 pts.

 

Addendum: you will need to strip out the page headings, &c., but unless you’re dealing with hundreds of pages it shouldn’t be particularly onerous.

 5,670 pts.

 

…using SEU; F15=Browse/Copy options; Select 2=Spool file, and under the Browse/copy spool file section…

This is probably the best choice for a one-time or infrequent recovery option. Good call.

Tom

 107,735 pts.