IBM i > TIPS & TECHNIQUES > APPLICATION DEVELOPMENT

Generating Documents Using Net.Data


In today's super-connected world, knowledge is power. Decisions that shape the financial course of business must be made quickly based on the latest reliable information available. That information must be accessible through various avenues from the Internet-wireless and traditional PCs, cellular phones, as well as other devices and applications. Because of this great diversity, data must be presented in various formats such as HTML for browser clients, XML for browser and application clients, wireless markup language (WML) for wireless clients, and Excel for application clients.

Net.Data is one method of accomplishing data presentation in various formats. This article will explain how to generate HTML, XML and Excel documents with Net.Data, which is delivered as a standard part of the IBM TCP/IP Connectivity Utilities/400 (OS/400* V3R2, V3R7, V4R1 and V4R2), and IBM HTTP Server for AS/400 (V4R3 and subsequent releases). There are no extra to buy and no software to download and install. All of the AS/400 TCP/IP and HTTP Server software comes standard with OS/400 but is optionally installed. The following optional software should be installed on your system for the following versions of OS/400:

  • For OS/400 V3R2, V3R7 and subsequent versions and releases (57xx-SS1): IBM TCP/IP Connectivity Utilities/400 (57xx-TC1)
  • For OS/400 V4R3 and subsequent versions and releases (57xx-SS1): IBM HTTP Server for AS/400 (57xx-DG1)

The following example runs the Net.Data macro on a V4R4 system.

Configuration
The HTTP server had the directives in
Example 1. A directive can either be inserted using the WRKHTTPCFG CL command or through a browser-based HTTP configuration by using the ADMIN HTTP server (HTTP://system:2001). The ADMIN HTTP server must be started by issuing the following CL command:

STRTCPSVR *HTTP
HTTPSVR(*ADMIN)

A library, NETDATADEV, must be created and the DB2WWW program object moved from library QHTTPSVR to library NETDATADEV.

Finally, the macro is stored in the IFS directory /AMRA. To create the AMRA IFS directory, use the following CL command:

MKDIR /AMRA

Generating Documents
Using various scenarios, I will illustrate how Net.Data, a server-side scripting language that simplifies the creation of dynamic documents, can be used to generate various documents in HTML, XML and Excel formats. Once generated, these documents will be used by other applications and sent to different devices. The documents that will be generated for this example will be based on data stored in a DB2 database file partlib/partfile (see
Example 2).

For simplicity, the documents will show all of the items and information in the database file. One macro, the Net.Data script file, will handle the generation of all of the documents formats. The macro will have three HTML blocks, each generating a different document. The following example shows the skeleton macro, formats.mac, with the HTML blocks:

%DEFINE DTW_PRINT_HEADER = "NO"
%HTML(generateHTML.html) {%}
%HTML(generateExcel.csv) {%}
%HTML(generateXML.xml) {%}

Nadir Amra is an advisory software engineer at IBM, Rochester, Minn. Nadir can be reached at amra@us.ibm.com.



Advertisement

Advertisement

2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

A PPP Monitor Utility

Here's a program developed to programmatically obtain the status of a PPP connection

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters