Use any editor to enter the RPGLE source code for the member GETCUS of QRPGLESRC in CGIDEV2. The code for GETCUS is shown in Figure 31.24. It includes a number of copy statements that pull in necessary code. These will be included in all CGI programs.
Figure 31.24: Here's the RPGLE code for CGIDEV2/QRPGLESRC MBR(GETCUS).
The program uses a series of subprocedures to build the next page to display for the user. The call to gethtml reads all the HTML needed to build the second Web page. This code is stored in member GETCUS2 of DEMOHTML in CGIDEV2 and is shown in Figure 31.25. The call to wrtsection(‘top’) writes the HTML code for the top of the page into a buffer waiting to transmit to the remote user. As each record is read in the DOU loop, the program calls updhtmlvar to load the data in CName into the variable cname on the Web page. Then, the call to wrtsection(‘tabrow’) writes the data for that customer into the buffer. After all records have been processed, the call to wrtsection(‘bottom’) loads the HTML code for the bottom of the page into the buffer, and the call to wrtsection(‘*fini’) transmits the buffer to the remote user.
Figure 31.25: Here's the HTML code for CGIDEV2/DEMOHTML MBR(GETCUS2).
The markers /$top, /$tabrow, and /$bottom are not HTML tags, but markers for the CGIDEV2 tool to use to identify sections of the HTML code. The variable /%cname%/ is also not HTML; it's only a marker that the CGI program replaces with real data. The CGI program mixes the HTML code and the live data from the database into a text string in a buffer that is then sent to the remote user. In this case, it builds the Web page displayed in Figure 31.26.
Figure 31.26: Here's your second Web page.
This is just the simplest of examples, showing you how to code your own CGI programs using RPGLE and CGIDEV2. IBM provides plenty of examples to help you expand into increasingly sophisticated Web pages.