/* ************************************************************/         
/*  This program converts spool-files to .HTML files          */         
/**************************************************************/         
       	     PGM
 
/*  Working Variable Declaratives                             */         
             DCL        VAR(&DATA) TYPE(*CHAR) LEN(200)                         
             DCL        VAR(&JOB) TYPE(*CHAR) LEN(10)                           
             DCL        VAR(&USER) TYPE(*CHAR) LEN(10)                          
             DCL        VAR(&NUM) TYPE(*CHAR) LEN(6)                            
             DCL        VAR(&SPLFILE) TYPE(*CHAR) LEN(10)                       
             DCL        VAR(&SPLFNBR) TYPE(*DEC) LEN(4)                         
             DCL        VAR(&SPLFNBRC) TYPE(*CHAR) LEN(4)                       
             DCL        VAR(&WAIT) TYPE(*DEC) LEN(5 0) VALUE(-1)                
             DCL        VAR(&RPT) TYPE(*CHAR) LEN(200)                          
                                                                                                                                                                                                                                         
/* Get Data Queue Entry                                           */                                                                                                                                   
 RCVDTAQ:    CALL       PGM(QRCVDTAQ) PARM(  'MYOUTQ'   'MYLIB' +             
                          200 &DATA &WAIT)                                                                                                                     
/* Calc Spoolfile info from Data Queue Entry */                                 
             CHGVAR     VAR(&JOB) VALUE(%SST(&DATA 13 10))                      
             CHGVAR     VAR(&USER) VALUE(%SST(&DATA 23 10))                     
             CHGVAR     VAR(&NUM) VALUE(%SST(&DATA 33 6))                       
             CHGVAR     VAR(&SPLFILE) VALUE(%SST(&DATA 39 10))                  
             CHGVAR     VAR(&SPLFNBR) VALUE(%BIN(&DATA 49 4))                   
             CHGVAR     VAR(&SPLFNBRC) VALUE(&SPLFNBR) 
           
/*  Copy HEADER source                                            */         
/*  QGPL/HTML created using CRTPF FILE(QGPL/HTML) RCDLEN(200)     */         
             CPYF       FROMFILE(QGPL/QHTMLSRC) TOFILE(QGPL/HTML) +             
                          FROMMBR(HEADER)  MBROPT(*REPLACE)  +
			  FMTOPT(*CVTSRC)                    
                            
/*  Copy Spool file records                                       */                                                
             CPYSPLF    FILE(&SPLFILE) TOFILE(QGPL/HTML) +                 
                          JOB(&NUM/&USER/&JOB) SPLNBR(&SPLFNBRC) +              
                          MBROPT(*ADD)                          
/*  Copy FOOTER source                                            */         
             CPYF       FROMFILE(QGPL/QHTMLSRC) TOFILE(QGPL/HTML) +             
                          FROMMBR(HEADER) MBROPT(*ADD) FMTOPT(*CVTSRC) 
         
/*  Copy HTML to IFS                                              */
             CHGVAR     VAR(&RPT) VALUE('/www/apachedft/htdocs/' || + 
                          &SPLFILE *TCAT '.html')                     
             CPYTOIMPF  FROMFILE(QGPL/HTML) TOSTMF(&RPT) +                     
                          MBROPT(*REPLACE) RCDDLM(*CRLF) DTAFMT(*FIXED)         
/*  Apply Authority                                               */         
             CHGAUT     OBJ(&RPT) USER(*PUBLIC) DTAAUT(*RWX) +                 
                          OBJAUT(*ALL)                                          
             GOTO       CMDLBL(RCVDTAQ)                                                              
             ENDPGM