IBM i RPG application Migration, modernization, and extension
Three-step workflow to create a Mobile RPG appASNA Mobile RPG builds on your RPG team’s existing skills to empower them to create smartphone and tablet apps for your IBM i with nothing but ILE RPG.
Simple process to create a mobile applicationMobile RPG uses a simple three-step workflow to create a mobile app. This workflow is quite similar to the general workflow of creating a traditional RPG program where you create display, compile it to a display file object, and then write an RPG program using that display file. Mobile RPG implements these three steps like this:
- Create the mobile UI. Mobile RPG provides a Windows-based mobile UI screen designer. You create mobile displays with it by dragging and dropping the user interface elements (eg, text boxes, charts, maps, lists, etc) you need on a display.
- Export it as an IBM i display file object. With your display created, it is a simple one-click operation to export the mobile display to a traditional IBM i display file. This display file will never be seen by eyeballs, rather is serves as a proxy to the mobile display so that you can compile an ILE RPG program against it.
- Write and compile an RPG program using the display Step 2 produced. With the proxy display file created, use whatever method you like (using SEU or Rational Developer or whatever other tools you normally use) to create the RPG source and then compile it against the IBM i display file. After this step, you can delete the IBM i display file–it is not used at runtime by Mobile RPG.
Broad array of user interface elementsThe Mobile RPG user interface designer provides a broad array of user controls, including:
- Text boxes and buttons
- Navigational menu bars
- Message text
- Chart (with chart types including column, bar, line and pie)
- Signature capture
- Barcode capture
- Geo location
A sampling of Mobile RPG’s icons
Mobile application icons built inIcons are intrinsic to mobile applications. They provide superb visual cues to your users showing how to initiate actions and navigate your mobile applications. Mobile RPG includes more than 225 icons (five of which are shown to the left) that you can easily assign to buttons or other user interface elements. These icons can easily be sized and colored.
RPG programming idioms built inMobile user interfaces do vastly different things than traditional green-screen interfaces do, but Mobile RPG needs to provide a natural way for an RPG programmer to populate its user interface. For example, consider displaying a map of two addresses. Several of Mobile RPG’s user interface controls use subfiles as the bridge between modern mobile UI and RPG. This abbreviated example shows what this means. Consider the need to map two addresses on map. Mobile RPG provides a map control (called in the DDSGMap control) that displays an active Google map with dynamically provided addresses. Mobile RPG’s challenge is to map the list of addresses provided to the map control with an idiom that is easy for an RPG program to populate. The answer: an RPG subfile! After placing the map control on the mobile UI, you then set a handful of properties (properties are fields that define UI control behaviors). In the case of the map control, you provide an address field name and length, the RPG indicator that when on causes the subfile to clear (when its controller record format is written to), the subfile name, and the subfile controller name. These properties are shown in the yellow call-out box in the image below:
Mobile RPG’s DdsGMap control subfile properties
A quick at the RPGAfter creating this mobile UI, a simple point-and-click process exports the mobile UI to a traditional IBM i display file object. This object provides the display file object against which an ILE RPG is compiled. The simple RPG code to populate the Mobile RPG map control with two addresses is shown below. This little program writes two rows (each providing an address to the
MAPSBFsubfile in the ShowMap subroutine. Although this program is rendering only two addresses, you can easily map a complex route with many addresses by writing more address rows to the subfile. At runtime, IBM’s Open Access redirects the workstation data to the Mobile RPG mobile UI. With this exception of the
HANDLERkeyword on line 2, the RPG program is written with very simple, standard RPG techniques. This program uses ILE RPG’s freeform syntax, but that’s optional–you can write the RPG anyway you like!
H DftActGrp(*No) FMAP CF E WORKSTN Handler('MOBILERPG') F SFile(MAPSBF:MAPRRN) F Infds(infds) /copy RPMRDATA/QRPGLESRC,KeyMap D MAPRRN S 4P 0 /free AddrTo = 'San Antonio, TX'; AddrFm = 'Marion, IN'; ExSr ShowMap; Exfmt HomeMenu; Dow KeyPressed <> F03; If KeyPressed = F10; ExSr ShowMap; EndIf; Exfmt HomeMenu; EndDo; *INLR = *ON; Return; BegSr ShowMap; *IN99 = *ON; Write MAPCTRL; MapRRN = 1; Location = AddrFm; Write MAPSBF; MapRRN = 2; Location = AddrTo; Write MAPSBF; *IN99 = *Off; Write MAPCTRL; EndSr;