RPG has evolved considerably since its early days as a report generator to its present status as a major application development language for the iSeries. Today it continues to thrive as it moves on to its next role as a development language for Web applications.
There are two major reasons RPG is good for developing new applications with browser, as opposed to green-screen interfaces.
First is the flexibility of interfacing with iSeries applications via a browser. A browser interface is more esthetically pleasing to most end users, and it's possible to fit much more information on the screen. This lets developers expand a browser application as needed to avoid the struggle of squeezing in data and abbreviating labels. The browser also offers more flexibility in presenting data and accepting input. For example, applications can present data as a graph and input controls can range from simple text fields to check boxes to data-driven drop-downs, an impossibility on a green screen.
A second benefit of using RPG to build a browser interface is that it enables faster application development than for green- screen applications, if you have the right tools. One tool that makes faster Web development with RPG possible is Profound Logic Software's RPG Smart Pages (RPGsp), a development tool structured specifically for the task of producing RPG-based applications with browser interfaces.
Although the enjoyment of writing traditional RPG/CGI browser applications can rank below a trip to the dentist, RPGsp's development environment takes the pain out of the process by eliminating CGI complexities. It does this by providing numerous wizards that guide programmers through common application development tasks and by automating most common Web development tasks.
Take, for example, the job of building a file maintenance application with list/view/change/delete capabilities. You could expect to spend days constructing such functions using traditional CGI or display file/green-screen programming techniques. RPGsp lets you build this type of application over any combination of files in just a few minutes and you'll end up with an application that actually executes faster than traditional CGI or green-screen solutions.
There are several approaches to building Web content. The most common is to build Web pages using static HTML information. Some of these static HTML pages are still manually coded, but most are generally built with specialized HTML designer tools.
Because static pages aren't very exciting and have limited functionality, a better way of generating Web pages is to use programs that output HTML dynamically. Dynamic content can pull information from databases and interact with users, which makes Web pages more engaging. But programs that produce dynamic HTML content are fairly difficult to create for anything beyond simple applications. This is because concatenating raw HTML, especially with a language like RPG, can get complicated.
RPGsp offers a new method of writing Web applications, one that lets developers include dynamic data and executable code directly within an HTML page, similar to Java Server Page servlets. This means you can use a sophisticated HTML designer to build your page, then code your dynamic logic side-by-side with the HTML, all without leaving RPGsp's development environment.
An RPG Smart Page is an intelligent HTML document that programmers control via RPG code that resides within that document. The RPGsp Development Environment includes everything you need to build dynamic content, design HTML, and code custom RPG logic for Web applications.
You can install and configure RPGsp's Integrated Development Environment (IDE) from the CD or Web site (downloadable at rpgsp.com or profoundlogic.com). The IDE is the PC portion of the product that has everything you need for designing, coding, and compiling Web applications powered by RPG. The first developer to connect to a particular iSeries system from the IDE is prompted to upload server components and to configure the Web server, a process that's completely automated and should take about five minutes. After you've configured the server, the RPGsp IDE launches a small test program to make sure it's ready for use. The default configuration gets you started, but you can change it later manually or with the help of the RPGsp server configuration utilities accessed via the Tools menu.
There are several ways to start building your first Web application. You can begin with a blank page and then add HTML elements and RPG logic to it, or you can accelerate the process with one of the application-building wizards.
Most wizards are accessible from the Wizards menu. There, you'll find various options for automatically building HTML subfiles, creating forms, converting DDS definitions to HTML, and other functions.
Let's start with an HTML subfile, which is a basic listing of records (a common type of application). When you select this option, you'll first be prompted for general information such as program name, title, and theme. A theme is an HTML template that simulates the look of your application. The environment includes several sample themes that you can choose from. You can also build your own themes to represent your company's standard Web appearance. The theme selection window will list the available themes and show a preview of each.
Next, the wizard asks you to select a database file and fields over which the application is to be built (Figure 1). You can build the application over multiple files by clicking the Related Files button to specify file relationships. Once you've selected the appropriate files, RPGsp automatically presents the available file fields. Select the fields you want to display in the subfile by double-clicking them, and then click Next.
The next screen lets you select various application features. For example, you can make the records searchable by the key of a file (such as an Item Number), or you can make the subfile a complete file maintenance application by selecting the view/change/delete options, and so on. If you're just getting started with dynamic Web development, try to keep your project simple to make it easier for you to grasp the basic concepts and to keep you from having to work with too much code. When you've specified the application's features, press Finish, and RPGsp will assemble the application right before your eyes.
At this point, you already have a working subfile application that you've generated in just a few minutes. To run it, select "Launch in Browser" from the Build/Run menu, or click the corresponding icon on the toolbar. Your new application will appear in a separate browser window (Figure 2).
So now you have a working application, but how does it really work, and how do you make changes to it?
The RPGsp IDE is an environment that somewhat resembles Microsoft Visual Studio. It lets you make changes to your application using one of several views: Design, RPG Only, or All Code.
The Design view lets you modify the HTML portion of the document in a WYSIWYG manner. You can accomplish virtually all HTML tasks within the Design view. For example, you can insert, move, resize, and modify elements visually. You'll notice that each HTML element has a number of assigned attributes that you can alter from the properties window. For example, to change the alignment attribute of an element, first click to select the element, and then double-click "align" in the properties window for choices (Figure 3).
A few special elements also appear as black boxes with yellow text on them. The text represents embedded RPG variables or expressions, sometimes referred to as output fields. This is what makes your application dynamic. At runtime, RPGsp replaces these elements with iSeries data or anything else your RPG code puts into these fields.
The field representing the image file name appears a little differently than the rest of the output fields. Instead of displaying the file name, an actual image appears when you run a particular application. How did the wizard know to treat this particular field that way? The answer is that RPGsp's built-in database repository lets you use HTML, JavaScript, and RPG to define how to display each input or output field. The good news is that you don't have to code these definitions from scratch because there are wizards available to help you build various definitions, which can include dynamic images, edit code fields, pop-up calendars, databound drop-down boxes, and other features.
RPGsp also offers an RPG Only view that shows you the RPG code that drives the application and puts data into the output fields you see in the Design view. Selecting this view reveals the source code's simplicity. Standard RPG code without complicated APIs retrieves the data from the iSeries. In fact, if this application wasn't using any of the wizard options (e.g., Search, View, Change, Delete), it would need only five lines of RPG code! (The code could simply repeat an HTML table row as we read data from a file within a loop.) A comparable CGI program would use more than 100 lines of more complicated code. Once the fundamentals of your application are in place thanks to the wizard, you can start adding your own custom RPG logic to create calculated fields, data from additional files, and so forth.
RPGsp's IDE provides all the necessary tools for adding new and modifying existing RPG code within a Web application. RPG editing features such as syntax highlighting, F4 prompting, IntelliSense code completion, a complete ILE RPG reference, realtime matching of IF/ENDIF and DO/ENDO structures, and a built-in compiler are all at your fingertips. In fact, you can also use the whole environment as an advanced code editor for traditional RPG development. For example, in addition to Web applications, you can open, edit, and compile RPGLE, CL, DDS, and CMD source member types directly from the IDE. Your RPG-based Web application could also interface with existing RPG programs or ILE objects. Or you could copy code from an existing RPG program into your Web application. There are many ways in which being able to work on both traditional RPG applications and Web applications within the same development environment could be handy.
Although you can accomplish many HTML tasks within the Designer, you'll need to work with HTML at the code level at some point. The All Code view makes this possible by showing you both the RPG and the HTML code (Figure 4). Here, you'll notice that your RPG code is actually embedded within HTML <SCRIPT> tags using the "language= RPGLE" attribute, while RPG variables (or output fields) are within <% and %> tags. Unlike JavaScript, which is a client-side script that responds to events and runs on the end user's PC, the RPGLE script is a server-side script that runs on the iSeries.
Similar to the RPG view, the All Code view provides many code editing features for both HTML and RPG. For example, you can use the properties window to modify HTML in a point-and-click manner, use IntelliSense completion to get a listing of the most common HTML tags, or access a complete HTML reference via the F1 key. The HTML code is well separated from the RPG and even appears on a different color background. It's also important to note here that you can maintain your .rpgsp pages within other visual environments such as Macromedia's Dreamweaver, IBM's WDSc, or Microsoft Visual Studio. RPGsp automatically integrates with these and selected other popular external designers and editors.
Something else that RPGsp brings to the table is flexible sequencing. The strict rules of traditional RPG no longer apply. For example, your file and field declarations don't necessarily have to be at the top of all your code.
So far, we've created a Web application, compiled it, launched it within a browser, and played with the code. One thing we haven't done yet is save our work. When it comes to saving RPGsp pages, we have a choice between the iSeries integrated file system (IFS) system, a local network-connected PC, or the iSeries Library system. This flexibility lets you share .rpgsp files, e-mail them, and even work with them offline from the iSeries. The "Save File" and "Open File" dialogs within RPGsp have three tabs across the top, which enable you to select the desired file system type.
Typically, you'll use the IFS for storing image files, static HTML pages, cascading style sheets, and the like. RPGsp compiles dynamic pages into an iSeries library, and you can store these files anywhere on any system, but most commonly, this will also be somewhere on the IFS.
As part of the installation process, RPGsp creates a samples directory on a local file system (e.g., a PC). This directory contains a number of code examples that you can compile and run on your iSeries. Some are simple examples, such as the various page counters. Others are more complex, such as shopping carts or dynamic graphs. These examples, along with the RPGsp wizards, can give you a leg up on RPG-based browser development right from the start.
The features we've explored here are just the basic tools available in RPGsp for building browser-accessible iSeries applications. There are more wizards and automation tools that can simplify application building and turn tasks that might take hours manually into something you can generate in a few seconds with a wizard. The important point is that Web development with RPG doesn't have to be difficult. A tool such as RPGsp can help you take the task of building Web applications in stride.
Alexander Roytman is chief technical officer of Profound Logic Software, Inc. He has worked with RPG and Web applications for more than 10 years. You can reach him at aroytman@profoundlogic.com.
|
VENDOR CONTACT INFORMATION
|
| Profound Logic Software, Inc. (937) 439-7925 profoundlogic.com or RPGsp.com RPG Smart Pages |