Home > AS/400 Tips > iSeries programmer tips > Getting started with CGIDEV2 -- Part 3
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Getting started with CGIDEV2 -- Part 3


Paul Tuohy
09.07.2005
Rating: -4.92- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


My previous articles on CGIDEV2 ("Getting Started with CGIDEV2 – Part 1" and "Getting started with CGIDEV2 -- Part II"), I discussed how to write a program using CGIDEV2 to produce a simple report for the Web and how to write a "paging" report. I also introduced the basic format of an HTML form. In this article, it is time to look at how you can write a simple subfile program and a maintenance program.

Figure 1 shows an example of a "Load All" style subfile Web page. The user can add a new product by keying in the new product code and clicking the Add button. Alternatively, he can update or delete an existing product by simply clicking on the product code.

[TABLE]

Figure 1: A "Load All" style subfile Web page

Figure 2 shows the Web page displayed when the user opts to add a new product. The user enters the values and clicks the Add button to add the product.

[TABLE]

Figure 2: Adding a new product

Figure 3 shows the Web page displayed when the user selects an existing product. The user makes the required changes and clicks either the Change or Delete button.

For both add and change, the category code is selected from a drop down box; whereas the user selects a category description it is actually the category code that is returned to the program. This is the HTML equivalent of an F4 prompt where the list of available options is of a manageable size.

Also note how the picture of the product is displayed.

[TABLE]

Figure 3: Maintaining an existing product

The subfile page
Figure 4 shows the HTML for the subfile page. In the tablestart section the definition of the form addCode allows for the entry of a new product code by issuing a call to CVALL002B when the Add button is selected. Each product code listed in the table (tableline section) has a hyperlink to call CVALL002B with the product code as a parameter.

Figure 4: HTML f


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
iSeries programmer tips
Groovy programming on IBM i
EGL Rich UI on IBM i: Do you Dojo?
Running PHP open source applications: NOBODY needs authority
Programming for the Web on the IBM i, what is possible
Using geocoding on AS/400 to enhance your Web presence
The best technologies and tools for System i programmers in 2009
Seven IBM i project lessons learned in 2008
Documenting nested program structures on the AS/400
What is an integrated database?
An automated CL method of moving a query from AS/400 to Excel

Web Development
Migrating from RPG to EGL on IBM i
Groovy programming on IBM i
Running PHP open source applications: NOBODY needs authority
Zend Web software teams up with IBM System i
The best technologies and tools for System i programmers in 2009
Seven IBM i project lessons learned in 2008
AS/400 lessons from the past, present, and future: A holiday tale
Application modernization strategies for System i
RPG application modernization for i5
Web skills crucial to iSeries programmer professional development

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
WebSphere Development Studio Client (WDSC)  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


or "Load All" style subfile

Are you ready for the complicated subfile program? Figure 5 shows the source of the CGIDEV2 program CVALL002A. Your eyes do not deceive you; that is all there is. The program bears a striking resemblance to the original report program in that it simply lists all of the products. The enormous benefit of using HTML is that the program does not need to process the subfile because any actions are initiated directly from the HTML (i.e. all calls to CVALL002B are initiated from the HTML).

Figure 5: The subfile program

The maintenance program
Before we look at the maintenance program, I just want to point out that this is just one of many ways of providing a maintenance function. In this example there is one program that provides for the loading, displaying and validation of the Web page and as well as adds, updates or deletes the record. Another option is to divide this into separate programs for the load/display and the validation/process.

Figure 6 shows the HTML for the maintenance program. The Web page is basically a form that calls the program CVALL002B. The main sections are changebutton and addbutton (towards the end of the page); one of those will be written depending on whether a product is being added or changed. All of the submit buttons have the same name of CGIOption, which is used by the maintenance program to determine if a product is to be added, updated or deleted. Also make a note of the selectoption section, which is used to generate the drop down list for category selection; the lines preceding and following selectoption identify the HTML select name. And then there are the MsgStart, MsgL1 and MsgEnd sections, which are used to display error messages.

Figure 6: HTML for the maintenance program

Figure 7 shows the CGIDEV2 maintenance program CVALL002B. The main points of the mainline are as follows:

Figure 7: The maintenance program

As in previous CGIDEV2 programs, the usual criteria about binding directories, copy members and work fields apply, but the important items to note are as follows:

Figure 8: HTML generated from the CrtTagOpt subprocedure

I think you can safely say that the logic for a maintenance program is not that complicated.

I am sure that you noticed that there is no looping logic in either program. Since there is no persistence between the program and the browser, there is no need for the program to loop: a program receives data, processes it and sends a Web page.

One step further
Now you know the basic principles of how you can use CGIDEV2 to write subfile and maintenance programs. In the next article I will start looking at some of the other strange and wonderful things you can do with CGIDEV2.

---------------------------
About the author: Paul Tuohy is CEO of ComCon, an iSeries consulting company. He is the author of Re-Engineering RPG Legacy Applications and is one of the quoted industry experts in the IBM Redbook "Who Knew You Could Do That With RPG IV?"


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts