25 pts.
 Convert spool file to physical file in AS/400
How to convert result file to physical file?

Software/Hardware used:
As400
ASKED: September 10, 2009  8:21 AM
UPDATED: April 23, 2012  7:00 AM

Answer Wiki:
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)
Last Wiki Answer Submitted:  September 11, 2009  2:56 pm  by  CharlieBrowne   32,805 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,805 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

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.

 315 pts.

 

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 pts.

 

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

 107,845 pts.

 

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.

 325 pts.

 

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) “.

 645 pts.

 

hi Rayj1031,
what is the value of &cmd in your program or what i enter in to them..

 1,240 pts.

 

thanks i got it

 1,240 pts.