Difference between revisions of "Net.Data"

From MidrangeWiki
Jump to: navigation, search
(initial page...will still need a lot of work)
 
(No difference)

Latest revision as of 06:33, 2 April 2008

Net.Data [1] is a scripting language available on the iSeries. It can be used to generate web applications that interact with the existing iSeries tables and software.

Net.Data code and html can be freely mixed to produce the required output.

Webserver Configuration

The Net.Data functionality is provided by program QSYSCGI/DB2WWW.

An easy way to use Net.Data is to copy DB2WWW to a library of your choice and to configure an iSeries web server instance with an alias that includes the path to the DB2WWW program and the path your Net.Data source code.

Assuming that your Net.Data source code is stored as members in physical source file MACRO in library MYCGI, the following definition can be added to your web server configuration:

ScriptAlias /macro/ /QSYS.LIB/MYCGI.LIB/DB2WWW.PGM/QSYS.LIB/MYCGI.LIB/MACRO.FILE/
<Directory /QSYS.LIB/MYCGI.LIB>                                                   
   Order Allow,Deny                                                                
   Allow From all                                                                  
</Directory>                                                                       

This will allow browser access at the following address: http://your.iseries.ip.address/macro/A001.MBR/listtables.html (where A001 is the name of a member in source file MACRO and listtables.html is the name of a HTML section in that member.)

Note: The configuration file for iSeries web server instances can generally be found under /www/<instance name>/conf/httpd.conf.

Example Source Code

0001.00 %{ *** ============================================================== *** %}    
0002.00 %{ ***                                                                *** %}    
0003.00 %{ ***  Example Net.Data Source file                                  *** %}    
0003.01 %{ ***  This example will list all tables on the system               *** %}    
0003.02 %{ ***  that have names starting with B                               *** %}    
0003.03 %{ ***  It will the call an iSeries program (RPG/CL/C) and display    *** %}
0003.04 %{ ***  any output that the program writes to STDOUT                  *** %}
0004.00 %{ ***                                                                *** %}    
0005.00 %{ *** ============================================================== *** %}    
0006.00                                                                                 
0007.00 %{ *** ============ DEFINE BLOCK =========== *** %}                             
0008.00                                                                                 
0009.00 %DEFINE DTW_PRINT_HEADER = "NO"                                                 
0010.00 %DEFINE DATABASE=""                                                             
0011.00 %DEFINE SYSLIB = ""                                                             
0012.00 %DEFINE RTN="0"                                                                 
0013.00                                                                                 
0014.00 %{ *** ===== FUNCTION DEFINITION BLOCK ===== *** %}                             
0015.00                                                                                 
0016.00 %FUNCTION(DTW_SQL) LISTTABLES(IN SYSLIB) {                                      
0017.00 Select TABLE_NAME, TABLE_TEXT from $(SYSLIB).SYSTABLES                          
0018.00   where TABLE_NAME like 'B%' order by TABLE_NAME                                
0019.00 %REPORT{                                                                        
0020.00  %ROW{                                                               
0021.00   $(V1)- $(V2) </br>                                                 
0022.00  %}                                                                  
0023.00 %}                                                                   
0024.00 %MESSAGE {100 : "<P ALIGN=CENTER>No records found</P>" : CONTINUE %} 
0025.00 %}                                                                   
0026.00                                                                      
0027.00 %FUNCTION(DTW_DIRECTCALL) MYPGM(IN CHAR(100) SOMEINPUT)                    
0028.00 {                                                                    
0029.00 %EXEC {MYPGM.PGM %}                                                  
0030.00 %}                                                                   
0031.00                                                                      
0032.00 %{ *** =========== HTML BLOCK ============== *** %}                  
0033.00                                                                      
0034.00 %HTML(listtables.html){                                              
0035.00 Content-type: text/html                                              
0036.00                                                                      
0037.00 <HEAD>                                                               
0038.00 </HEAD>                                                              
0040.00 <BODY>                                                                    
0041.00 <h2><center>List of tables on the system starting with B</center></h2>    
0042.00 @LISTTABLES("QSYS2")                                                      
0043.00 <h2><center>STDOUT output from my program</center></h2>                                                              
0044.00 @MYPGM("some input")                                                      
0045.00 </BODY>                                                                   
0046.00 %}                                                                        
0047.00