Net.Data Menu
Net.Data CGI script provides a dynamic menu.
Net.Data is a server-side scripting language that provides web servers the ability to dynamically generate web pages using data from multiple data sources. The example below is code that uses the DTW_DIRECTCALL function to access an RPG program. The script incorporates multiple lanaguages. Some of the functions, such as cookies, were managed by JavaScript. Other elements made use of Java applets. INOUT sepecifies the argument list for I/O variables. The key variables are passed to the RPG program. The RPG program builds the menu table from relational database entries. The menu presented is dependent on the keys provided by the CGI script. Different web users will be presented with a custom menu that matches their profile. The menu options vary from customer to customer and even the page graphic elements may vary by profile.
Building a dynamic menu
The program example below is a Net.Data script that gnerates an HTML table using the DTW_SQL function of the script language. The table output in the SQL block will be referenced in the DTW_DIRECTCALL function (highlighted in red). The table will be used as an I/O variable in the argument used for the RPG application program.
%{ ********************** Define block ************************%} %DEFINE { page_title="Web Client Initial Menu" DTW_REMOVE_WS = "NO" DTW_PRINT_HEADER = "NO" SHOWSQL = "NO" pass_flag="OK" Usr_Prf="" Usr_Typ = "" Vnd_Nbr = "0" Syn_Nbr = "0" Prf_Typ = "" Client_Logo="" Page_Header="WEB00000.htm" Doc_List=" " Dsp_Name="" UsrNam="" MNU="INIT" DTW_HTML_TABLE = "YES" MnuTable = %TABLE GrpTable = %TABLE counter = "1" newrow = "0" tablerow = "0" DTW_SET_TOTAL_ROWS="YES" %} %{ ********************** Get Profile ************************%} %FUNCTION(DTW_SQL) GetProfile() { SELECT PSPROF,PSTYPE,PSNAME,PSLOGO,PSINCL,PSIDOC,PSSUBT, PSVEND, PSSYNC FROM WEBPRFPF WHERE PSPROF = '$(USR)' %MESSAGE { 100 : "Profile not on file" : exit %} %Report { %Row { @dtw_assign(Client_Logo, V_PSLOGO) @dtw_assign(Page_Header, V_PSINCL) @dtw_assign(Doc_List, V_PSIDOC) @dtw_assign(Usr_Typ, V_PSSUBT) @dtw_assign(Prf_Typ, V_PSTYPE) @dtw_assign(Vnd_Nbr, V_PSVEND) @dtw_assign(Syn_Nbr, V_PSSYNC) @dtw_assign(Dsp_Name, V_PSNAME) %} %} %} %FUNCTION(DTW_SQL) Show_Group(OUT t1) { SELECT WGUSR, WGSEQ, WGSYNC, WGNAME, WGGMBR FROM WEBGRPPF WHERE WGSTAT='Y' AND WGUSR = '$(USR)' ORDER BY WGSEQ %MESSAGE { 100 : "No GROUP records were found." : continue %} %REPORT { <TABLE bgcolor="#c7c7e0" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0"><hr size="5"></td> </tr> <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0">Menus</td> </tr> <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0"><hr size="5"></td> </tr> %ROW { <TR bgcolor="#C7C7E0"> <TD > <A HREF="/CGI-BIN/DB2WWW/WEB50025.NDM/INPUT?USR=$(V_WGUSR)&SEQ=$(V_WGSEQ)"> <FONT SIZE="1">$( V_WGNAME )</FONT></A> </TD> </tr> %} </TABLE> <INPUT TYPE="hidden" NAME=rowtotal VALUE="$(NUM_ROWS)"> %} %} %{******** Function Section ********* %} %FUNCTION(DTW_DIRECTCALL) Get_Menu ( IN CHAR(10) USR, CHAR(10) MNU, INOUT DTWTABLE MnuTable ) { %exec { /QSYS.LIB/CGIPX010.LIB/WEB700RP.PGM %} %Report { <table cellspacing="1" width="100%" bgcolor="#ffffff" border="0" cellpadding="2"> %Row { <tr> %if(@dtw_rstrip($(V_RECID)) == "M1") <td >$( V_MNIMG1 )</td> <td >$( V_MNITM1 )</td> %endif %if(@dtw_rstrip($(V_RECID)) == "G1") <td COLSPAN="2" align="CENTER">$( V_MNITM1 )</td> %endif %if(@dtw_rstrip($(V_RECID)) == "M2") <td >$( V_MNIMG1 )</td> <td >$( V_MNITM1 )</td> <td >$( V_MNIMG2 )</td> <td >$( V_MNITM2 )</td> %endif %if(@dtw_rstrip($(V_RECID)) == "G2") <td COLSPAN="4" align="CENTER">$( V_MNITM1 )</td> %endif </tr> %} </table> <INPUT type="hidden" NAME="Usr_Prf" value="$( USR )"> <input type="hidden" name="Mnu_Nam" value="$( MNU )"> <input type="hidden" name="rowtotal" value="$(NUM_ROWS)"> %} %} %{ ******************** HTML Block: Input *********************%} %HTML (INPUT) { Content-type: text/html Pragma: no-cache Expires: 0 Cache-control: no-cache <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head><title>Partner Support Web</title> <style > A:ACTIVE { COLOR: #FF0000; TEXT-DECORATION : NONE; FONT-FAMILY: VERDANDA,ARIAL; FONT-SIZE: 10PT; FONT-WEIGHT: 500} A:HOVER { COLOR: #191970; BACKGROUND: #E6E6FA; TEXT-DECORATION : NONE;FONT-FAMILY: VERDANA,ARIAL; FONT-SIZE: 10PT; FONT-WEIGHT: 500} A:LINK { COLOR: #0000FF; TEXT-DECORATION : NONE;FONT-FAMILY: VERDANA,ARIAL; FONT-SIZE: 10PT; FONT-WEIGHT: 500} A:VISITED { COLOR: #003366 ; TEXT-DECORATION : NONE; FONT-FAMILY: VERDANA,ARIAL; FONT-SIZE: 10PT; FONT-WEIGHT: 500} BODY { font-family: verdana,arial } BODY {color :#003366;} BODY { font-size: 10pt; } BODY {font-weight: 600;} BODY { SCROLLBAR-BASE-COLOR: #003366; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-COLOR: #A997C4; SCROLLBAR-HIGHLIGHT-COLOR: #A997C4; SCROLLBAR-SHADOW-COLOR: #4D445C; SCROLLBAR-DARKSHADOW-COLOR: #4D445C; SCROLLBAR-FACE-COLOR: #003366; SCROLLBAR-TRACK-COLOR: #ffffff; } P.DATA { font-family: verdana,arial; color: #003366; font-size: 8pt; font-weight: 500} P.COPY { font-family: verdana,arial; color: #666666; font-size: 8pt; font-weight: 500} TD.TEXT1 { font-family: verdana,arial; color: #003366; font-size: 10pt; font-weight: 700} TD.TEXT2 { font-family: verdana,arial; color: #003366; font-size: 10pt; font-weight: 500} TD.TEXT3 { font-family: verdana,arial; color: #003366; font-size: 8pt; font-weight: 500} TD.TEXT4 { font-family: verdana,arial; color: #FFFFFF; font-size: 10pt; font-weight: 700} </style> <script language="JavaScript1.2"> <!-- var exp = new Date(); var expDays = 1; // number of days the cookie should last var Msgpage = "/Pops/popUPMsg.htm"; var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes"; // Define image objects var backOff = new Image( 34, 18 ); backOff.src = "/images/btn_back_only.gif"; var backOn = new Image( 34, 18); backOn.src = "/images/btn_back_only_active.gif"; var hlpOff = new Image( 20, 20 ); hlpOff.src = "/images/hlp_btn0.gif"; var hlpOn = new Image( 20, 20); hlpOn.src = "/images/hlp_btn1.gif"; var brwWin; var brwOpen; function show_Browser() { if(brwOpen==true) { brwWin.close();} brwWin = window.open("/PartnerSupport/browser.html", "brwWin", "height=280,width=640,top=50,left=100,alwaysRaised=1,resizable=1"); setTimeout('closeWin(brwWin)', 10000); brwWin.focus(); brwOpen=true; } function closeWin(brwWin) { brwWin.close(); brwOpen=false; } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } // Delete the cookie function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } // set the expiration exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); function amt(){ var count = GetCookie('popcount') if(count == null) { SetCookie('popcount','1') return 1 } else { var newcount = parseInt(count) + 1; DeleteCookie('popcount') SetCookie('popcount',newcount,exp) return count } } // Get cookie value function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } // Check the cookie count function checkCount() { var count = GetCookie('popcount'); if (count == null) { count=1; SetCookie('popcount', count, exp); window.open(Msgpage, "", windowprops); } else { count++; SetCookie('popcount', count, exp); } } // Report card var grdWin; var grdOpen; var vnd; var constURL="/CGI-BIN/DB2WWW/VND00310.NDM/Main?VendorNo="; function show_Grades(vnd) { if(grdOpen==true) { grdWin.close();} URL = constURL + vnd; grdWin = window.open(URL, "grdWin", "height=340,width=440,top=150,left=200,alwaysRaised=1,resizable=1"); //setTimeout('closeWin(grdWin)', 10000); grdWin.focus(); grdOpen=true; } function closeWin(grdWin) { grdWin.close(); grdOpen=false; } function highlightButton(placeholder, imageObject) { document.images[placeholder].src = eval( imageObject + ".src"); } function formHandler(form) { var URL = form.docpage.options[form.docpage.selectedIndex].value; window.location.href = URL; } function Page_Help(Attr) { var PageHelp; var PHelp; var urlVar = '/HelpSupport/'; if(PHelp == true) PageHelp.close(); var RefLoc = new String(urlVar + Attr); PageHelp = window.open(RefLoc, "PageHelp", "height=320,width=480,top=50,left=100,alwaysRaised=1,scrollbars=1,resizable=1"); PageHelp.focus(); PHelp = true; } //-->The end of the section to be hidden </script> </head> <body bgcolor="#ffffff" topmargin="0" leftmargin="0"> <div align="center"> <center> <input type="hidden" name="Usr_Prf" value="$( USR )"> <input type="hidden" name="Mnu_Nam" value="$( MNU )"> @GetProfile() %if($(Page_Header) == "") %INCLUDE "WEB00000.htm" %else %INCLUDE "$(Page_Header)" %endif <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td bgcolor="#ffffff" valign="top" width="25%" align="left"> <!-- *************************** //--> <!-- left side information table //--> <!-- *************************** //--> <table width="180" border="0" cellspacing="0" cellpadding="0"> %if($(Usr_Typ) != "G") <tr> <td width="100%"> <table bgcolor="#c7c7e0" border="2" cellspacing="2" cellpadding="2" width="100%"> <tr><td bgcolor="#191970" class="TEXT4" width="100%"> <a href="JavaScript:Page_Help('WEB50005A.htm')" onMouseOver="highlightButton( 'Help', 'hlpOn' );window.status='Return to previous page';return true;" onMouseOut="highlightButton( 'Help', 'hlpOff' );window.status=' ';return true;"><img src="/images/hlp_btn0.gif" alt="Page Help" width="20" height="20" border="0" name="Help"></a> <STRONG>WEB50005</STRONG> </td></tr> </table> </td> </tr> %endif <!-- if the profile is defined as a group profile,load the group members //--> %if($(Usr_Typ) == "G") <tr> <td> <table border="0" bgcolor="#c7c7e0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td valign="top" width="15%"><img src="/images/groups1.jpg" width="30" height="100"></td> <td valign="top" width="85%" class="TEXT3">The profiles associated with <strong>$(Dsp_Name )</strong> are listed below on the group menu. To display a menu click on the profile name. </td> </tr> </table> <table width="180" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#c7c7e0"> <td width="100%">@Show_Group(GrpTable)</td> </tr> </table> </td> </tr> %endif <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0"><hr size="5"></td> </tr> <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0">Options</td> </tr> <tr> <td class="TEXT1" align="center" bgcolor="#c7c7e0"><hr size="5"></td> </tr> %if($(Usr_Typ) != "G") <tr bgcolor="#c7c7e0"> <td width="100%" class="TEXT3"><a href="/CGI-BIN/DB2WWW/WEB20005.ndm/INPUT?USR=$(USR)&MNU=$(MNU)">Change my menu</a></td> </tr> %if($(Prf_Typ) == "VND") <tr bgcolor="#c7c7e0"> <td width="100%" class="TEXT3"> <a href="JavaScript:show_Grades('$(Vnd_Nbr)');"> Report card</a></td> </tr> %endif %endif <tr bgcolor="#c7c7e0"> <td width="100%" ><a href="JavaScript:show_Browser()">What's my browser?</a></td> </tr> <tr bgcolor="#c7c7e0"> <td width="100%" ><a href="/CGI-BIN/DB2WWW/WEB20001.ndm/INPUT?PRF=$(USR)">Contact data</a></td> </tr> <tr> <td width="180" align="CENTER"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25"><img src="/images/blcc7.jpg" border="0" width="25" height="25"></td> <td bgcolor="#c7c7e0" width="130"><font color="#c7c7e0" >...</font></td> <td width="25"><img src="/images/brcc7.jpg" border="0" width="25" height="25"></td> </tr> </table> </td> </tr> </table> </td> <!-- ***************************** //--> <!-- Load the profile menu options //--> <!-- ***************************** //--> <td bgcolor="#ffffff" valign="top" align="center" width="50%"> <div align="center"> <table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" width="350"> <tr> %if($(Client_Logo) == "") <td valign="top" width="350" align="center"><font size="4" color="#003366"><b>$(Dsp_Name )</b></font></td> %else <td valign="top" width="350" align="center">$( Client_Logo )</td> %endif </tr> <tr> <td align="center" valign="top" width="350"> @Get_Menu(USR,MNU,MnuTable) </td> </tr> </table> </div> </td> <!-- ********************************** //--> <!-- Right side document pull down menu //--> <!-- ********************************** //--> <td bgcolor="#ffffff" valign="top" align="right" width="25%"> <FORM method="post" name="form1"> <table width="180" border="0" cellspacing="0" cellpadding="0"> %if(Doc_List != "*NONE") <tr> <td width="100%"> <table border="0" bgcolor="#c7c7e0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td valign="top" width="15%"><img src="/images/socside3.jpg" width="30" height="100"></td> <td valign="top" width="85%" class="TEXT3"> <p align="left">Use the pull-down menu to select a document you want to view, then <strong>Click</strong> on the <strong>Get</strong> button.</p> </td> </div> </tr> </table> </td> </tr> <tr> <td class="TEXT1" align="center" bgcolor="#e6e6fa"><hr size="5"></td> </tr> <tr> <td width="180" bgcolor="#e6e6fa" align="center"> <input type="button" name="documents" value="Get" onClick="JavaScript:formHandler(this.form);"><select name="docpage" size="1"> %INCLUDE "$(Doc_List)" </select> </td> </tr> %endif <tr> <td class="TEXT1" align="center" bgcolor="#e6e6fa"><hr size="5"></td> </tr> <tr> <td width="180" align="CENTER"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25"><img src="/images/blce6.jpg" border="0" width="25" height="25"></td> <td bgcolor="#e6e6fa" width="130"><font color="#e6e6fa">...</font></td> <td width="25"><img src="/images/brce6.jpg" border="0" width="25" height="25"></td> </tr> </table> </td> </tr> </table> </form> %if($(Prf_Typ) == "VND") <script language="JavaScript"> <!-- checkCount(); //--> </script> <TABLE BORDER="0" WIDTH="125" CELLPADDING="2" CELLSPACING="2"> %{ <tr> <td width="100%" align="right"> <APPLET CODE="rollOver.class" codebase="/applets/" WIDTH=50 HEIGHT=50> <param name=imgOff value="/images/whtnew0.jpg"> <param name=imgOn value="/images/whtnew1.jpg"> <param name=HLink value="/News/newBulletin.htm"> <param name=target value="_self"> </APPLET> </td> </tr> %} <tr> <td> <APPLET CODE="rollOver.class" codebase="/applets/" WIDTH=50 HEIGHT=50> <param name=imgOff value="/images/vndsrv0.jpg"> <param name=imgOn value="/images/vndsrv1.jpg"> <param name=HLink value="/cgi-bin/db2www/VND90040.ndm/input?"> <param name=target value="_self"> </APPLET> </td> </tr> </TABLE> %endif </td> </tr> </table> </center></div> <!-- ******************************** //--> <!-- bottom of menu //--> <!-- ******************************** //--> <table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" class="TEXT"><a href="javascript:history.back()" onMouseOver="highlightButton( 'Back', 'backOn' );window.status='Return to previous page';return true;" onMouseOut="highlightButton( 'Back', 'backOff' );window.status=' ';return true;"><img src="/images/btn_back_only.gif" alt="Previous page" width="34" height="18" border="0" name="Back"></a></td> </tr> </table> </body> </html> %} %{ ********************** End of Source ************************%}
The HTML INPUT block of the script will display the table generated by the DTW_SQL block( the function call is @SHOWPOS). The HTML block named UPDATE will get the table, then call the RPG program passing the variables identifying the key fields VND_NBR, INV_NBR, as input prarameters and the table as an I/O parameter.