Brief: Remote access to the AS/400 can be painfully slow. This article describes a simple programming technique that can significantly improve response time.
Applications running on remote workstations generally have much slower response times than those running on locally attached workstations. If you've ever worked on a remotely attached workstation, you know what I'm talking about. You can actually watch the screen "paint," several lines at a time, from the top of the screen to the bottom. Even with today's faster modem speeds and data- compression algorithms, running an application on a remote workstation can be a frustrating experience.
Fortunately, there are a few DDS keywords which can help improve the response time of applications running under these conditions. I'll show you how you can code your display files to reduce the amount of data being sent to a workstation. The application screens will look the same to the end user, but they will refresh much more quickly. To prove this, I ran a test by dialing in to MC's AS/400 at 9600bps. I ran a typical application program twice. The first time, the display file did not contain any of the keywords discussed in this article. My response time was around 3 seconds per transaction. By adding these keywords to the display file, my response time improved to almost 1 second per transaction!
Even if you currently do not have any remote users accessing your applications, you may still want to use this technique. Response time for local users would improve slightly, though probably not noticeably. However, you would be better prepared to meet the growing demand for remote access to AS/400 applications in the future.
The Problem
Most applications are not written with the remote user in mind. It's not too difficult to understand why this happens. Programmers usually have an office located near the computer room. They develop applications on locally attached workstations; when they test the applications, they find that the response time is very good. When a remote user runs this same application, the response time is unacceptably slow. If the user complains, the programmer usually blames the communications hardware for the poor response time. After all, everyone knows that remote connections through modems are slower than local connections. A simple display file programming technique can improve re-sponse time for applications run by remote users. I've developed a sample application that shows how to accomplish this.
A Typical Example
A typical application screen consists of a number of fields and constants. Often, the same screen needs to be presented to a user more than once. For example, consider the customer inquiry screen shown in 1. When the user selects a customer number, he is presented with the customer name and address. He selects another customer number and obtains a different name and address in the same screen format. Each time the user makes a selection, he sees the same screen with different names and addresses.
A typical application screen consists of a number of fields and constants. Often, the same screen needs to be presented to a user more than once. For example, consider the customer inquiry screen shown in Figure 1. When the user selects a customer number, he is presented with the customer name and address. He selects another customer number and obtains a different name and address in the same screen format. Each time the user makes a selection, he sees the same screen with different names and addresses.
Now think about what happens internally when this application is run. Every time the user selects a new customer number, OS/400 sends all of the fields and constants to the user's workstation. The fields containing customer information need to be sent each time, since they're changing for each customer. But what about the constants? They don't change from one customer to the next. Even though the constants are already on the screen, OS/400 sends them anyway. This causes more data to be sent than necessary. With a remote workstation, this unnecessary transmission of data can degrade response time noticeably.
To make matters worse, an attribute byte precedes every field and constant on the screen. These bytes control screen attributes such as normal, high intensity and reverse image. These bytes are also sent to the workstation, adding to the traffic on the line.
DDS to the Rescue
DDS gives you an effective way to deal with this situation. By adding a few keywords to your display file, you can control which fields, constants and attributes OS/400 sends to the workstation. Instead of sending the whole screen, you can send only the portions of the screen which have changed since the last time the screen was sent.
To make this technique work, place the Put with Explicit Override (PUTOVR) keyword at the record level of your display file. This prevents the transmission of constants, fields and attributes after the first write of the display file record. On all subsequent writes of this record, OS/400 will send the fields or attributes only if they are explicitly overridden.
To override a field, specify the Override Data (OVRDTA) keyword on the field you want to override. This keyword causes OS/400 to send both the field and its attribute to the workstation. Specify the Override Attribute (OVRATR) keyword on a field or constant to override an attribute. This causes only the attribute byte to be sent. 2 provides an overview of the data sent to the workstation when these keywords are applied.
To override a field, specify the Override Data (OVRDTA) keyword on the field you want to override. This keyword causes OS/400 to send both the field and its attribute to the workstation. Specify the Override Attribute (OVRATR) keyword on a field or constant to override an attribute. This causes only the attribute byte to be sent. Figure 2 provides an overview of the data sent to the workstation when these keywords are applied.
As with most DDS keywords, there are a few restrictions. First, you can't use the PUTOVR keyword in a subfile record, or in a record format which contains the PUTRETAIN keyword (a similar but less effective keyword than PUTOVR). One final restriction: you can't specify OVRDTA on a constant. Now that you know when not to use these keywords, let's look at an example which shows how you can use them.
3 shows the DDS for the display file used in the customer inquiry application discussed earlier. To keep this example simple, I've used only the PUTOVR and OVRDTA keywords. (OVRATR appears in a later example.)
Figure 3 shows the DDS for the display file used in the customer inquiry application discussed earlier. To keep this example simple, I've used only the PUTOVR and OVRDTA keywords. (OVRATR appears in a later example.)
The PUTOVR keyword is only in effect if the record is already on the display. The first time the RMTDSP record is written, the system automatically ignores the PUTOVR keyword-all fields and constants are sent to the workstation. When the user enters a customer number, the program loads the screen fields with customer information and resends the RMTDSP record. This time, the record is already displayed on the screen, so the PUTOVR keyword is active. PUTOVR keeps OS/400 from sending constants, such as the heading and field prompts. Instead, the screen simply retains the constants from the first write of the record format. OS/400 resends to the workstation only those fields which have the OVRDTA keyword specified (in this example, the customer address information). Sending only those fields decreases the amount of data transmitted which substantially improves response time.
Sending Attributes
The sample display file in 1 contains no special attributes, but most display files are more complex than this. For example, you may need to change a display attribute to high intensity or reverse image to alert the user to an error condition. You can use the OVRATR keyword to accomplish this.
The sample display file in Figure 1 contains no special attributes, but most display files are more complex than this. For example, you may need to change a display attribute to high intensity or reverse image to alert the user to an error condition. You can use the OVRATR keyword to accomplish this.
4 shows some partial DDS for another display file. This example contains one constant and one field. The constant, 'Status code', is displayed as either normal or high intensity, depending on the condition of indicator 30. The STSCDE field is displayed as normal or reverse image, depending on the condition of indicator 40. I've coded the OVRATR keyword in both cases, to point out the effect it has on display file efficiency.
Figure 4 shows some partial DDS for another display file. This example contains one constant and one field. The constant, 'Status code', is displayed as either normal or high intensity, depending on the condition of indicator 30. The STSCDE field is displayed as normal or reverse image, depending on the condition of indicator 40. I've coded the OVRATR keyword in both cases, to point out the effect it has on display file efficiency.
Assume that both indicators are off when the program is called. The program ignores the PUTOVR keyword the first time the record format is written to the screen. The constants, fields, and attributes are all sent to the workstation. Since OVRATR is specified on the 'Status code' constant, OS/400 resends the constant's attribute byte to the workstation for every subsequent write of the record format. When indicator 30 is off, the normal attribute is sent. When indicator 30 is on, the high-intensity attribute is sent. In either case, the constant itself is not resent to the workstation.
The STSCDE field behaves in a similar fashion. Since the OVRATR keyword is specified, the attribute byte for the field is always sent to the workstation. In this case, when indicator 40 is off, the normal attribute is sent. When indicator 40 is on, the reverse-image attribute is sent. STSCDE is an input- capable field, making it unnecessary to resend the contents of the field to the workstation. (Since the user supplies the value for this field, the program can simply leave the value on the screen unmodified.) Therefore, I used the OVRATR keyword instead of the OVRDTA keyword.
Changing screen attributes with this technique can be extremely efficient. A screen containing 24 rows and 80 columns could contain as many as 1920 bytes of data. If you need to change one attribute on a crowded screen, the difference in response times with and without this technique can be substantial.
Remember Your Remote Users
The technique described in this article can give remote users much better response time with very little effort on your part. DDS gives you the ability to decide how much data to send to a workstation. It's up to you to take advantage of this capability. If you keep these techniques in mind when you code your applications, you will reduce not only the amount of traffic on the communication line but also the frustration level of your remote users.
Robin Klima is a senior technical editor at Midrange Computing.
REFERENCES DDS Reference (SC41-9620, CD-ROM QBKA7402). Guide to Programming Displays (SC41-0011, CD-ROM QBKA7902).
Turbocharge Remote Applications
Figure 1 Customer Inquiry Screen
Customer Inquiry Customer number . . . 53157 Customer name . . . . GEORGE HENDERSON Address . . . . . . . 938 PALM DR City . . . . . . . . LOS ANGELES State . . . . . . . . CA Zip code . . . . . . 90846 F3=Exit
Turbocharge Remote Applications
Figure 2 Data Sent on Subsequent Writes
UNABLE TO REPRODUCE GRAPHICS
Turbocharge Remote Applications
Figure 3 Example Using OVRDTA Keyword
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A R RMTDSP A PUTOVR A 1 33'Customer Inquiry' A DSPATR(HI) A 5 2'Customer number . . .' A CSNUM 5 B 5 25 A 7 2'Customer name . . . .' A CSNAME 25 O 7 25 A OVRDTA A 9 2'Address . . . . . . .' A CSADDR 25 O 9 25 A OVRDTA A 11 2'City . . . . . . . .' A CSCITY 15 O 11 25 A OVRDTA A 13 2'State . . . . . . . .' A CSSTAT 2 O 13 25 A OVRDTA A 15 2'Zip code . . . . . .' A CSZIP 5 O 15 25 A OVRDTA A 23 2'F3=Exit' A COLOR(BLU) *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
Turbocharge Remote Applications
Figure 4 Example Using OVRATR Keyword
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A R RMTDSP A PUTOVR A 5 2'Status code' A OVRATR A 30 DSPATR(HI) A STSCDE 1 B 5 15 A OVRATR A 40 DSPATR(RI) *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
LATEST COMMENTS
MC Press Online