Convert spool file to physical file in AS/400

25 pts.
Tags:
AS/400 Spooled Files
Physical Files
Spooled File to Physical File Conversion
How to convert result file to physical file?

Software/Hardware used:
As400

Answer Wiki

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

Using CPYSPLF will copy is printed report to a PF

Another method to use is to creat a PF with a length of 133 rather than 132. This allows the first character to be used as a control character so that you can convert the contents of the physical file back to a spool file and maintain proper page breaks and so forth.

When you copy the spooi file to the physical, do this (assuming QSYSPRT is the printer file name):

CPYSPLF FILE(QSYSPRT) TOFILE(SPOOLPF) CTLCHAR(*FCFC)

To take the contents from the PF back to a spool file do this:

CPYF FROMFILE(SPOOLPF) TOFILE(QSYSPRT) MBROPT(*ADD)

Discuss This Question: 9  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • 65GTO
    You will need to create a Flat File ( PF with no DDS and a record length of 132). Use the CPYSPLF command to copy the spool file into this PF.
    335 pointsBadges:
    report
  • Subhro
    I need to get the start and end time along with the tape number used for daily back on regular basis...using script..may be CL program...Can any one help me out with the code ?
    50 pointsBadges:
    report
  • TomLiotta
    Can any one help me out with the code ? Probably. Post a question and let's find out. (Make it a new question with its own topic.) Include as much of the requirements as are needed. List any constraints that should be heeded. Tom
    125,585 pointsBadges:
    report
  • Rayj1031
    I have a command and program called CVTPRTPF. The command lets you create a spooled file and immediately copy it to a physical file. I use this command extensively to perform functions like you describe. There are any number of ways to collect the start and stop time of a job from the history log, or the job log. the program:
    /******************************************************************************/
    /* PROGRAM NAME . . . . . . . . . . . . . . :   cvtprtpf                      */
    /* AUTHOR . . . . . . . . . . . . . . . . . :   RAYMOND G. JOHNSON            */
    /* DATE CREATED . . . . . . . . . . . . . . :   02/16/2007                    */
    /*                                                                            */
    /* PROGRAM INFORMATION:  Convert print to physical file.                      */
    /*                                                                            */
    /*                                                                            */
    /******************************************************************************/
    /* CHANGE LOG:                                                                */
    /******************************************************************************/
    /* DATE         INITIALS   CHANGE DESCRIPTION                                 */
    /******************************************************************************/
    /* XX/XX/200X   XXX                                                           */
    /*                                                                            */
    /*                                                                            */
    /******************************************************************************/
    
    PGM          PARM(&CMD &PRTF &QF &MEMBER)
    
                 DCL        VAR(&MSGDTA)  TYPE(*CHAR) LEN(80)
                 DCL        VAR(&MSGID)   TYPE(*CHAR) LEN(7)
                 DCL        VAR(&CPYR)    TYPE(*CHAR) LEN(30) +
                              VALUE('ISOLUTIONS CONSULTING, INC.')
    
                 DCL        VAR(&XXXXXXX) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&YYYYYYY) TYPE(*CHAR) LEN(20)
    
                 DCL        VAR(&CMD)     TYPE(*CHAR) LEN(3000)
                 DCL        VAR(&FILE)    TYPE(*CHAR) LEN(10)
                 DCL        VAR(&LIB)     TYPE(*CHAR) LEN(10)
                 DCL        VAR(&MBR)     TYPE(*CHAR) LEN(10)
                 DCL        VAR(&MBROPT)  TYPE(*CHAR) LEN(8)
                 DCL        VAR(&MEMBER)  TYPE(*CHAR) LEN(20)
                 DCL        VAR(&PRTF)    TYPE(*CHAR) LEN(10)
                 DCL        VAR(&QF)      TYPE(*CHAR) LEN(20)
    
    /******************************************************************************/
    /*           GLOBAL MONITOR MESSAGE - STANDARD ERROR EXIT                     */
    /******************************************************************************/
    
                 MONMSG     MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(ERROR))
    
    /******************************************************************************/
    /*           START OF PROGRAM.                                                */
    /******************************************************************************/
    
                CHGVAR     VAR(&FILE)     VALUE(%SST(&QF 1 10))
                CHGVAR     VAR(&LIB)      VALUE(%SST(&QF 11 10))
                CHGVAR     VAR(&MBR)      VALUE(%SST(&MEMBER 3 10))
                CHGVAR     VAR(&MBROPT)   VALUE(%SST(&MEMBER 13 8))
    
                CHKOBJ     OBJ(&LIB/&FILE) OBJTYPE(*FILE)
    
                MONMSG     MSGID(CPF9898) EXEC(DO)
                   SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +
                             MSGDTA('LIBRARY' *BCAT 'not found') +
                             MSGTYPE(*ESCAPE)
                   RETURN
                ENDDO
    
                MONMSG     MSGID(CPF9801) EXEC(DO)
                  CRTPF      FILE(&LIB/&FILE) RCDLEN(512)
                ENDDO
    
                CHKOBJ     OBJ(&LIB/&FILE) OBJTYPE(*FILE) MBR(&MBR)
                MONMSG     MSGID(CPF9815) EXEC(DO)
                  ADDPFM     FILE(&LIB/&FILE) MBR(&MBR)
                ENDDO
    
                OVRPRTF    FILE(&PRTF) HOLD(*YES)
    
                CALL       PGM(QCMDEXC) PARM(&CMD 3000)
    
                MONMSG     MSGID(CPF0000) EXEC(DO)
                  SNDPGMMSG  MSG(&CMD *BCAT 'failed')
                  RETURN
                ENDDO
    
                CPYSPLF    FILE(&PRTF) TOFILE(&LIB/&FILE) JOB(*) +
                             SPLNBR(*LAST)
    
                DLTSPLF    FILE(&PRTF) JOB(*) SPLNBR(*LAST) +
                             SELECT(*CURRENT)
    
                DLTOVR     FILE(&PRTF)
    
    
    
    
    
    
    
    
     RETURN:     RETURN
    /******************************************************************************/
    /*           END OF PROGRAM / ERROR EXIT                                      */
    /******************************************************************************/
    
     ERROR:      RCVMSG     MSGTYPE(*EXCP)  MSGDTA(&MSGDTA) +
                              MSGID(&MSGID)
                 MONMSG     MSGID(CPF0000)
                 SNDPGMMSG  MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +
                              MSGTYPE(*ESCAPE)
                 MONMSG     MSGID(CPF0000)
     END:        ENDPGM 
    
    
    the command
    
    CVTPRTPF:   CMD        PROMPT('CONVERT PRINT TO PHYSICAL FILE') +
    
                PARM       KWD(CMD) TYPE(*CMDSTR) LEN(3000) MIN(1) +
                             PROMPT('COMMAND TO PRODUCE OUTPUT')
                PARM       KWD(PRTF) TYPE(*NAME) LEN(10) MIN(1) +
                             PROMPT('PRINTER FILE NAME')
                PARM       KWD(TOFILE) TYPE(Q1) MIN(1) PROMPT('TO +
                             PHYSICAL FILE')
                PARM       KWD(MBROPT) TYPE(E1) PROMPT('MEMBER OPTIONS')
    
    Q1:         QUAL       TYPE(*NAME) LEN(10) MIN(1)
    
                QUAL       TYPE(*NAME) LEN(10) DFT(*CURLIB) +
                             SPCVAL((*CURLIB)) PROMPT('LIBRARY')
    
    E1:         ELEM       TYPE(*NAME) LEN(10) DFT(*FIRST) +
                             SPCVAL((*FIRST)) PROMPT('MEMBER TO +
                             RECEIVE OUTPUT')
    
                ELEM       TYPE(*CHAR) LEN(8) RSTD(*YES) DFT(*REPLACE) +
                             VALUES(*REPLACE *ADD) PROMPT('REPLACE OR +
                             ADD RECORDS') 
    
    
    Once you have the JOB log or History Log information in a file you can read the file and parse out any information you want. I then use the %SST command to parse out the information you want into variables and now you can do anything you want with the data. Query/400 also enables you to parse out those details from a job log or history log. If you wrote the backup program you can insert a program message with test like '>>>>@ next line starts the backup job.' Then you can use the >>>>@ as a marker in the file to easily find the information you are looking for.
    335 pointsBadges:
    report
  • MDratwa
    In front of the "CPYF FROMFILE(SPOOLPF) TOFILE(QSYSPRT) MBROPT(*ADD) ", you will need to do an override for QSYSPRT. It will look something like "OVRPRTF FILE(QSYSPRT) CTLCHAR(*FCFC) ".
    785 pointsBadges:
    report
  • Ckishorekumarr
    [...] Convert spool file to physical file in AS/400 [...]
    0 pointsBadges:
    report
  • 9783444184
    hi Rayj1031, what is the value of &cmd in your program or what i enter in to them..
    1,355 pointsBadges:
    report
  • 9783444184
    thanks i got it
    1,355 pointsBadges:
    report
  • dinuas400
    Use the CPYSPLF command to convert the spool file to physical file... But that file will be a single field file... You need to parse that acordingly..
    510 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following