ASNA WingsRPG™ Reference Manual |
Walkthrough Step 3 - Adding the Handler Keyword
Adding the Handler Keyword
Setting up a program to work with
Wings is a matter of adding a single continuation line to the WORKSTN
file declaration in the ILE RPG program. All you need to do is insert
Handler('ASNAWINGS'
) into the CUSTINQ's F-Spec continuation line as
shown in Figure 3-1. For more detail on the Handler see the
Add Handler Keyword help
section. Also note that the source files must be ILE RPG and the Display
File externally referenced; if they're currently RPG/400, they'll have
to be converted with CVTRPGSRC
before using Wings.
Note – SEU was not updated to expect the Handler keyword, so the following message will always be displayed when using SEU to add the handler:
The keyword is not recognized; keyword is ignored.
The program will compile and run normally. There are no plans to update SEU to expect the handler, as IBM no longer supports it.
Figure 3-1.
Once compiled with the Handler in place, the program object is now ready to use a Wings display file. However, many Wings customers want their users to be able to use either the Wings version of the application or to be able to use the original green-screen version of the application. Wings can accommodate that by using the same source code to create a Wings-ready program objects while also retaining the ability to create the original green screen program objects. ILE RPG's conditional compilation option, detailed below, is the recommended way to do this. If you want to handle that later skip ahead to step 4.
ILE RPG's Conditional Compilation
The ILE RPG compiler can conditionally include code based on compilation "conditions." These conditions are specified with compile commands such as CRGBNDRPG using the DEFINE keyword. Conditional compilation, along with the ability to target a specific object output library, provides the basis of the scheme to create two program objects from a single ILE RPG source member; one for use with Wings and one for use with the 5250 display file.
An overview of the recommended library structure used in conditional compilation is shown in Figure 3-2 on the next page.
Figure 3-2.
Preparing an application to be conditionally compiled as a Wings-ready program object is a matter of adding three lines of code as shown below in lines 31-33 of Figure 3-3.
Figure 3-3.
The first line (line 31) provides logic that lets RPG's conditional compilation identify this as a Wings-ready program, the second line (line 32) adds the OAR handler keyword, and the last line (line 33) closes the conditional compilation test.
Any program with the above logic included can be compiled as
Wings-ready using (for example) CRTBNDRPG
, as shown in Figure 3-4.
Notice the "WINGS
" condition described with the DEFINE
keyword; or the
source can be compiled without the WINGS
condition to create a non-Wings
program.
Figure 3-4.
Once these steps are complete, we have the ability to create two program objects from the single ILE RPG source member. One for use with Wings and one for use with the traditional display file. The next step is to open Visual Studio.