The LANSA OPEN command can be used to keep file(s) open until a specific CLOSE command is issued against them.

For instance, imagine a small order processing system that could be visualized like this:

                               ORDWRK
                                     |
                      ----------|----------
                     |               |              |
              ORD001  ORD002  ORD003

When a user enters this system and begins jumping from ORD001 to ORD002 to ORD003, and so on, a fair amount of computer resource can be wasted opening and closing files used by all the functions.

For instance, all 3 functions might use files TABLES (system tables), ORDHDR (order header details) and ORDLIN (order line details).

Thus when the user exits from ORD001 all 3 files are closed. When the user invokes ORD002, all 3 files are opened again. This continual opening and closing is a waste of computer resource and degrades response times.

To fix this problem we might code a "file opener" called ORD004 that looked like this:

     OPEN FILE(TABLES) USE_OPTION(*KEEPOPEN)
  OPEN FILE(ORDHDR) USE_OPTION(*KEEPOPEN)
  OPEN FILE(ORDLIN) USE_OPTION(*KEEPOPEN)
  CALL PROCESS(ORDWRK)

which would fit into the existing system like this:

                               ORD004
                                     |
                                     |
                              ORDWRK
                                     |
                      ----------|----------
                     |               |              |
               ORD001  ORD002  ORD003

In this situation, the implicit OPEN and CLOSE requests issued by ORD001, ORD002 and ORD003 are ignored, which results in much faster processing.

  • No labels