000100 *==================================================================== 000000 000200 * RPG ILE XLSCGI/SAMPLECGI2 000000 000300 * Outputs an HTML table or a Spreadsheet 000000 000400 * 000000 000500 * CRTBNDRPG PGM(XLSCGI/SAMPLECGI2) DFTACTGRP(*NO) ACTGRP(SAMPLECGI2) DBGVIEW(*LIST) 000000 000600 * 000000 000700 *==================================================================== 000000 000800 /copy xlscgi/qrpglesrc,hspecs 000000 000900 /copy xlscgi/qrpglesrc,hspecsbnd 000000 001000 FSAMPLEFILEif e k disk usropn 000000 001100 F extfile('XLSCGI/SAMPLEFILE') 000000 001200 /copy XLSCGI/qrpglesrc,prototypeb 000000 001300 /copy XLSCGI/qrpglesrc,usec 000000 001400 /copy XLSCGI/qrpglesrc,variables3 000000 001500 /copy XLSCGI/qrpglesrc,xlscgiprot //*** CGI2 000000 001600 * Input variables 000000 001700 D xrequest s 10 000000 001800 * Other variables 000000 001900 D totXLSrows s 10i 0 000000 002000 D extHtml s 2000 varying 000000 002100 * Indicators for GetHtmlIfsMult subprocedure 000000 002200 D IfsMultIndicators... 000000 002300 d ds 000000 002400 D NoErrors n 000000 002500 D NameTooLong n 000000 002600 D NotAccessible n 000000 002700 D NoFilesUsable n 000000 002800 D DupSections n 000000 002900 D FileIsEmpty n 000000 003000 * 000000 003100 D inpNumber s 30p 9 //*** CGI2 000000 003200 *======================================================================== 000000 003300 * Main line 000000 003400 *======================================================================== 000000 003500 /free 000000 003600 160512 003700 fixJobCCSID(); //change job CCSID if 65535 160512 003800 SetNoDebug(*on); //do not write records to file CGIDEBUG 160512 003900 160512 004000 //Get input 000000 004100 nbrVars = zhbgetinput(savedquerystring:qusec); 000000 004200 //Get input variables: 000000 004300 // if xrequest='XLS', the output must be the spreadsheet 000000 004400 // if xrequest=' ', the output must be the HTML page 000000 004500 xrequest = zhbgetvarupper('xrequest'); //*** CGI2 000000 004600 000000 004700 //Load the external HTML 000000 004800 exthtml ='/xlscgi/html/samplecgi2.htm ' + //HTML sections //*** CGI2 000000 004900 '/xlscgi/html/samplecgi2.xml ' + //XML sections for Spreadsheet //*** CGI2 000000 005000 '/xlscgi/html/goxls.htm'; //bootstrap HTML for Spreadsheet stmf//*** CGI2 000000 005100 IfsMultIndicators = getHtmlIfsMult(exthtml:'<as400>'); 000000 005200 000000 005300 //Open file 000000 005400 if not %open(samplefile); 000000 005500 open samplefile; 000000 005600 endif; 000000 005700 000000 005800 //Start output table 000000 005900 if xrequest<>'XLS'; //*** CGI2 000000 006000 wrtsection('top'); 000000 006100 else; //*** CGI2 000000 006200 wrtsection('XMLtop'); //*** CGI2 000000 006300 endif; //*** CGI2 000000 006400 000000 006500 //Write table rows 000000 006600 samppartno=*loval; 000000 006700 setll samppartno samprcd; 000000 006800 read samprcd; 000000 006900 dow not %eof; 000000 007000 if xrequest='XLS'; //*** CGI2 000000 007100 //remove unsupported characters from character fields //*** CGI2 000000 007200 samppartno=fixString(samppartno); //*** CGI2 000000 007300 sampdescrn=fixString(sampdescrn); //*** CGI2 000000 007400 endif; //*** CGI2 000000 007500 updhtmlvar('samppartno':samppartno); 000000 007600 updhtmlvar('sampdescrn':sampdescrn); 000000 007700 if xrequest<>'XLS'; //*** CGI2 000000 007800 updhtmlvar('sampsales1':%editc(sampsales1:'P')); 000000 007900 updhtmlvar('sampsales2':%editc(sampsales2:'P')); 000000 008000 updhtmlvar('sampsales3':%editc(sampsales3:'P')); 000000 008100 updhtmlvar('sampsales4':%editc(sampsales4:'P')); 000000 008200 wrtsection('row'); 000000 008300 else; //*** CGI2 000000 008400 inpNumber=sampsales1; //*** CGI2 000000 008500 updhtmlvar('sampsales1':edtNumber(inpNumber)); //*** CGI2 000000 008600 inpNumber=sampsales2; //*** CGI2 000000 008700 updhtmlvar('sampsales2':edtNumber(inpNumber)); //*** CGI2 000000 008800 inpNumber=sampsales3; //*** CGI2 000000 008900 updhtmlvar('sampsales3':edtNumber(inpNumber)); //*** CGI2 000000 009000 inpNumber=sampsales4; //*** CGI2 000000 009100 updhtmlvar('sampsales4':edtNumber(inpNumber)); //*** CGI2 000000 009200 wrtsection('XMLrow'); //*** CGI2 000000 009300 endif; //*** CGI2 000000 009400 read samprcd; 000000 009500 enddo; 000000 009600 000000 009700 //End table 000000 009800 if xrequest<>'XLS'; //*** CGI2 000000 009900 wrtsection('tableend'); 000000 010000 else; //*** CGI2 000000 010100 wrtsection('XMLbot'); //*** CGI2 000000 010200 endif; //*** CGI2 000000 010300 000000 010400 //Send the output to the browser 000000 010500 if xrequest<>'XLS'; //*** CGI2 000000 010600 wrtsection('*fini'); //send the HTML output buffer to the browser 000000 010700 else; //*** CGI2 000000 010800 sndToExcel(); //*** CGI2 000000 010900 endif; //*** CGI2 000000 011000 000000 011100 //Back to the caller 000000 011200 return; 000000 011300 000000 011400 /end-free 000000 011500 /copy XLSCGI/qrpglesrc,sndtoexcel //*** CGI2 000000