Sat, Apr
5 New Articles

RPG Programmers Meet Lotus Notes

  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

In June 1970, E.F. “Ted” Codd presented to the world his concept of how data should be stored. His article, “A Relational Model of Data for Large Shared Data Banks,” was published in the Communications of the ACM, and you can read it on the Web at www1.acm.org:81/classics/nov95/toc.html if you’d like. In the early 1980s, a full 10 years later, RDBMSs began to appear, and, by the late 1980s, the transition was more or less complete. The old network, hierarchical, and inverted-list database management systems were history.

I remember reading an article during the middle ’80s about another person who broke ranks with Codd and Chris J. Date (another RDBMS proponent). This associate, whose name I’ve forgotten, remarked to the press that Codd and Date had sold the world on a model that was too simple for solving real-world problems. Although I’ve forgotten his name, I’ve never forgotten his complaint. As much as I like relational database management systems, I agree that they are not appropriate for some types of data storage. I’ve been watching since then to see what other types of database models would be invented and what types of applications they would prove useful for.

Lotus Notes is one such database model that provides an alternative to the RDBMS. In this article, I compare and contrast Notes to DB2/400. I can’t make an exhaustive comparison in so few words, but I hope you will at least get an idea of what Notes is about and how it differs from the RPG/CL/DDS world AS/400 programmers are so familiar with.

Structural Differences

The first thing an AS/400 programmer or manager needs to understand about Notes is that it is not an RDBMS. An RDBMS stores data in tables, or (as AS/400 programmers call them) physical files. Each table contains a set of similar entities. Data is organized into rows (records) and columns (fields). A database, in relational terms, is a collection of tables. A Notes database, on the other hand, is a collection of documents, which consist of fields. Notice that there are four levels of organization in an RDBMS but only three in Notes.

The difference in structure exists because of the difference in purpose. Notes databases are not intended to store transactional data. A purchasing agent, for example, creates a transaction called a purchase order when placing an order with a supplier. In a relational database, all purchase orders are stored in one or more tables (physical files),

which would adhere to the RDBMS rules of normalization. Although you can use Notes to create a purchase-order application, an RDBMS would most likely be more appropriate because of the transactional nature of the application. But you can use Notes to supplement an RDBMS application by automating its work flow requirements.

Notes was designed to automate work flow, and it can be used to automate the purchase-order process. Suppose a purchasing agent must get approval from other people in certain circumstances, such as spending more than a certain amount of money. Instead of passing around a piece of paper on which managers “sign off,” the purchasing agent could use a Notes application to get approval.

Notes was also designed with distribution of documents in mind. The replication feature allows an entire database or a subset to be copied from one machine to another and synchronizes the changes users make. For example, a Notes application might automatically send a manager (via replication) the purchase-order request documents that await his approval. When the manager changes a request document, the server’s and manager’s replicas no longer agree with one another. When the manager next replicates, Notes copies his changes to the server and the server and workstation are once again in sync.

Yet another difference between Notes and RDBMS is in the way sets relate to one another. One of the fundamental tenets of RDBMS is the join process. For example, a purchase-order master file contains a vendor number. To find that vendor’s name, the programmer joins the purchase-order master file to the vendor master file. The system matches the data based on common vendor account numbers. Notes has no such capability. That is not to say that Notes database documents cannot reference one another. They can but not in this way.

The Creation Process

The AS/400 has a command-line interface, which may be supplemented with menus. To create a library, a programmer types CRTLIB, presses the F4 key, fills in the blanks, and presses Enter. Lotus Notes is a visual environment. A Notes database is created interactively. The Notes programmer points and clicks, typing as necessary, to build a database.

An AS/400 physical file is created in a batch process. A programmer keys DDS for a physical file into a source physical file member. When the programmer executes the Create Physical File (CRTPF) command, a program reads the DDS and creates a physical file. The Notes programmer interactively creates a form, in which all the fields to be contained in documents are defined. The Notes form defines the structure of the data and provides a GUI screen that can be used for editing and presenting the Notes documents in the database. Figure 1 shows a form used in a job postings database.

When CRTPF finishes, the programmer has an empty physical file in which to store data but no processing logic or infrastructure. That is, the file has no environment in which to reside. The AS/400 programmer still must create menus and write programs before users can be productive with the database.

The Notes programmer has a database in which users can store documents as well as a form by which users can maintain and query that database. It is as if CRTPF generated a “work with” program as part of the file-creation process.

Notes provides an infrastructure in the form of a desktop, from which users can open databases and work with them. As an alternative, Notes databases can also be accessed through a Web browser. In fact, using browsers to access Notes databases is becoming more and more common. This is where the power of Lotus Domino server comes into the picture. Domino not only serves Notes applications to Notes clients but also can dynamically translate Notes applications to HTML for use with browser clients.

The term field is commonly used in reference to DB2/400 and Notes. Like a field in a physical file, a Notes field contains only one piece of information (one datum, if you

prefer) about a document. However, this datum can be quite different from the datum in an RDBMS. Notes fields can store numbers and character strings, as one would expect, but a Notes field can also store such things as graphical data, file attachments, and OLE objects
(i.e., spreadsheets). Users can change the contents of a Notes field by keying into a form, but fields may also be computed. To get an idea of how this works, imagine that DDS had a keyword that you could use at the field level. This keyword would specify a program name. Whenever a record was written to the database or updated in the database, this program would run and the field’s value would be computed. The closest DB2/400 feature is the trigger program, which works at the file level rather than at the field level.

Notes Views

A Notes view, also known as an index, is a row-and-column list of the documents in a database. It is similar to a logical file in two important ways. First, views provide different sort sequences over the documents. Figures 2 and 3 show two different views of the job postings database. In Figure 2, the documents are listed one per line and are sorted by job title. In Figure 3, documents are listed in a hierarchical view, sorted by department name. Second, a view can be made to display only selected documents. The Open Jobs view (Figure 3) shows only open postings.

When you create a database, Notes creates one view, which is organized by document number (a sequential number Notes assigns to a document when the document is created). This is similar to using Query/400 to view a physical file in relative record number order.

When you create a view, you must tell Notes how many columns the view should have and how each one gets its value. A column’s values may come from a simple action (a predefined function), another document field, or a formula (similar to a macro expression in a spreadsheet).

You may sort the view on one or more columns. Sorting may be in ascending or descending order, and character sorting may be case-sensitive or not. As shown in Figure 2, you may also allow users to dynamically choose sort sequences by column within a view. The user can change the sort sequence by clicking on a column heading.

Programming Notes

To many of you who have been in this business for a while, programming is synonymous with source code. Notes supports five basic modes of programming: simple actions, formulas, LotusScript, Java, and JavaScript. A set of C APIs is also available.

RPG programmers may be interested to know that they can reference the C APIs through ILE RPG if they’re running Domino on an AS/400. IBM Rochester has posted some sample code on the Web to illustrate how this is done. If you’re interested in this, point your Web browser to www.as400.ibm.com/snippets, choose Download Savefiles, and download the save file of the library called RNHLIB. FTP the downloaded file to a save file on your AS/400, then use the RSTLIB command to unpack it. Be aware that RPG IV programming will not transfer to other Notes platforms.

But I have digressed. I was about to tell you about the three basic modes of programming—simple actions, formulas, and LotusScript.

Simple actions are predefined routines that carry out various tasks. For instance, the Copy to database function copies a document to another database. The Send document function sends a document to someone by email.

Formulas are interpreted routines that are much like macros in spreadsheets. However, formulas can execute more than one command and can contain local variables.

LotusScript is an object-based programming language that is much like Visual Basic (VB). Unlike simple actions and functions, LotusScript gives you power over all of Notes. You can write structured code, incorporating the iteration and sequencing constructs

common to modern programming languages. Through predefined classes, you can control databases, documents, and fields.

Notes is not the only software product that uses LotusScript. Most Lotus products, as well as some third-party products, also support Lotus-Script. This means that a programmer who knows LotusScript can develop software to integrate different software products. LotusScript is actually a subset of VB, so much of the syntax and language functions you learn to use in LotusScript can be used in Microsoft VB-based development.

Notes provides an Integrated Development Environment (IDE) with which you can develop and debug LotusScript routines. This IDE provides three panes: the Design pane, the Debug window, and the Utility pane. The Design pane is the one in which you type LotusScript source code. The other two are visible only when you are debugging.

Programming can be placed behind many different types of components. For example, you might attach a formula to a field of a form to tell Notes to capitalize everything keyed into the field. If a user typed hr, Notes would change it to HR. Or you might place a button on a form. When the user clicks on the button, Notes saves and closes the document.

Agents and Actions

As you learn more about Notes programming, you will run into agents and actions. These are miniprograms that are more or less identical in structure but different in purpose. Both actions and agents support simple actions, agents, and scripts.

Actions are confusing because Notes uses the term action in two different ways. I alluded earlier to simple actions, predefined routines that you can take advantage of. Actions (without the adjective simple) are something else. Actions can run simple actions. This is called a simple action action. Have I confused you?

The main difference between actions and agents is this: Actions are usually executed on a client machine at a user’s request (e.g., by clicking a button). On the other hand, agents most often run on a server machine in response to an event, such as creating a document or clicking an Action button.

On the AS/400, security is based on user profiles. System administrators create user profiles and tell the system which objects each user can or can’t use. Notes uses a similar scheme but uses the term user ID. The user ID is stored in a file, which must be on an available disk when Notes is started. If your user ID is SMITH, Notes will look for a file called SMITH.ID. If it can’t find the file, Notes presents a window that asks you to specify the file to be used for the current user ID. It’s probably most convenient for you to keep your user ID on your workstation, but, for added security, you might prefer to keep it on a diskette, which you can store in a safe place when you aren’t using Notes. The user ID file contains a lot of information, including information about the user, public and private encryption keys, and certificates (electronic stamps that give you access to Notes servers).

Security is further defined via the Access Control List (ACL), which specifies which users can do which tasks. Some tasks that the ACL can control are creating, deleting, reading, and writing documents; creating agents and views; and creating agents in LotusScript or Java. Each database has its own ACL.

Security can also be further defined at the form and even the field level.

Notes Does the Job

I have been a user of Notes for a few years (we’ve been using Notes at Midrange Computing to manage articles as they work their way through the editorial process). Notes does a good job, and I would hate to try to use RPG to duplicate what Notes does for us.

I hope this whirlwind tour of Lotus Notes has been helpful to you. As I have begun to learn to develop Notes applications, I’ve learned what I already knew: Most everything


is just new ways to do the same old things. I know several RPG programmers who have learned to develop in Notes. If they can do it, so can you and I.


• “A Relational Model of Data for Large Shared Data Banks,” E.F. Codd, Communications of the ACM, June 1970. Reprinted in Communications of the ACM (Web Edition), November 1995, ww1.acm.org:81/classics/nov95/toc.html.

• IBM Code Snippets Web site: www.as400.ibm.com/snippets

Figure 1: Notes documents are defined though their data entry forms.

Figure 2: Views are similar in concept to logical files.

RPG_Programmers_Meet_Lotus_Notes05-00.png 612x406

RPG_Programmers_Meet_Lotus_Notes05-01.png 595x395

Figure 3: This view shows a subset of documents in hierarchical form.

RPG_Programmers_Meet_Lotus_Notes06-00.png 595x395

Ted Holt is IT manager of Manufacturing Systems Development for Day-Brite Capri Omega, a manufacturer of lighting fixtures in Tupelo, Mississippi. He has worked in the information processing industry since 1981 and is the author or co-author of seven books. 

MC Press books written by Ted Holt available now on the MC Press Bookstore.

Complete CL: Fifth Edition Complete CL: Fifth Edition
Become a CL guru and fully leverage the abilities of your system.
List Price $79.95

Now On Sale

Complete CL: Sixth Edition Complete CL: Sixth Edition
Now fully updated! Get the master guide to Control Language programming.
List Price $79.95

Now On Sale

IBM i5/iSeries Primer IBM i5/iSeries Primer
Check out the ultimate resource and “must-have” guide for every professional working with the i5/iSeries.
List Price $99.95

Now On Sale

Qshell for iSeries Qshell for iSeries
Check out this Unix-style shell and utilities command interface for OS/400.
List Price $79.95

Now On Sale



Support MC Press Online

$0.00 Raised:

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: