This article takes you on a quick tour of an enterprise mobile app created with ASNA Mobile RPG. It shows how easy and fast it can be to create a mobile app to run on a smartphone or tablet. Screen shots from both smart phones and tablets are included, but all of the panels displayed are available on both smartphones and tablets. A deep-dive how-to approach isn’t taken here; rather, this article is intended to show how a mobile app with a measure of sophistication can be created with ASNA Mobile RPG.  If you’re not familiar with Mobile RPG, you might want to look at this article in this newsletter first. You can also read more about ASNA Mobile RPG on our Website.

The use case for this application is a hierarchical commercial network (General Manager, Sales Directors, Sales Rep, and Point of Sale) for which business results are shown by level and how Point-of-Sale (POS) orders are handled.

This application’s features include:

  • Show graphical business results (sales vs. budget)
  • Browse between different hierarchical levels (commercial director, sales rep, POS)
  • Show POS data and its location with Google Maps
  • Use of device native elements (phone calls)
  • Order entry from the point of sale, with product images help

Below is a screenshot of the logon screen (Figure 1a) and the CEO menu panel (Figure 1b).

Figure 1a. Login screen

Figure 1b. CEO menu

ASNA Mobile RPG display files are simply extensions to familiar traditional display file idioms. They are composed of record formats, fields and constants and their behavior is (mostly) driven by indicator states just as traditional display files are. Three record formats are used to create the panels in Figures 1a and 1b. One each for the two panels and then a shared error messages format. These three formats are stored in the same mobile display (just as they probably would be in a traditional display file).

With Mobile RPG, after you’ve created a mobile display file (with Mobile RPG’s mobile display file designer), you export that mobile display to a traditional display file. This traditional display file serves as a “proxy” for the mobile display file to the RPG program on the IBM i. At compile time, the RPG program uses this exported display file but at runtime it uses the Mobile RPG mobile display file. The DDS source created by Mobile RPG to export and generate the display file object is shown below in Figure 1c.

A                                      DSPSIZ(27 132 *DS4)
A                                      INDARA             
A          R HOMELOGIN                                    
A                                      OVERLAY            
A            LOGINLANG      2A  B  1  2                   
A            LOGINUSER     10A  I  1  6                   
A            LOGINPWD      10A  I  1 18                   
A          R FERROR                                       
A                                      OVERLAY            
A            IOERROR       50A  O  1  2                   
A          R HOMEMENU                                     
A                                      OVERLAY            
A            IOUSUDESC     50A  O  1  2                   
A            LOGINLANG      2A  B  1 54
Figure 1c. The traditional display file DDS created from the ASNA Mobile RPG display file

By tapping the Total per month option the annual sales chart panel appears (as shown in Figure 2a). The panel in Figure 2a uses Mobile RPG’s chart control. Selecting a month from Figure 2a’s chart displays daily sales data as shown in Figure 2b. This panel uses Mobile RPG’s subfile control to display its tabular data. Selecting a month can be done using the dropdown at the bottom of Figure 2a or tapping the appropriate bar in the chart data of Figure 2a.

Figure 2a. Sales chart

Figure 2b. Sales chart data displayed as a table

Both subfile and graph controls are represented in the exported IBM i display file as traditional subfiles. The resulting DDS generated from this export is shown below in Figures 2c and 2d.

A          R GRAPHMENU                                     
A                                      OVERLAY             
A            IOUSUDESC     50A  O  1  2                    
A            IOTITULO      25A  O  2  1                    
A            IOMESDET       2Y 0I  2 28                    
A          R FERROR                                        
A                                      OVERLAY             
A            IOERROR       50A  O  1  2                    
A          R VENN0ASFL                 SFL                 
A            CHMES          2A  O  1  2                    
A            DTVENTAS      11Y 2O  1  6                    
A            DTPTO         11Y 2O  1 19                    
A            DTUNIS        11Y 2O  1 32                    
A            N1ADTA         1Y 0I  1 45                    
A          R VENN0ASFC                 SFLCTL(VENN0ASFL)   
A                                      SFLSIZ(2)           
A                                      SFLPAG(1)           
A N99                                  SFLDSP              
A N99                                  SFLDSPCTL           
A  99                                  SFLCLR              
A                                      OVERLAY             
A            IOCATTIT      20   M
Figure 2c. The subfile generated from the chart shown in Figure 2a.
A          R VENN0A1SFL                SFL                  
A            DIAACT         2Y 0O  1  2                     
A            DTVENTAS       9Y 2O  1  6                     
A            DTPTO          9Y 2O  1 17                     
A            DTUNIS         9Y 2O  1 28                     
A          R VENN0A1SFC                SFLCTL(VENN0A1SFL)   
A                                      SFLSIZ(15)           
A                                      SFLPAG(1)            
A N99                                  SFLDSP               
A N99                                  SFLDSPCTL            
A  99                                  SFLCLR               
A                                      OVERLAY              
A            IOUSUDESC     50A  O  2  2                     
A            IOTITULO      25A  O  3  1
Figure 2d. The subfile generated from the tabular data shown in Figure 2b.

The underlying RPG program isn’t at all aware that its logic is driving a mobile app. That RPG program reads and writes to the subfiles as defined in Figures 2c and 2d. The RPG that populates these subfiles is shown below in Figure 2e. Note that this RPG is simply regular RPG–there is nothing unique or special about it. With ASNA Mobile RPG,  you simply use the RPG skills you already have to create great mobile apps! At runtime, this subfile data is redirected to the Mobile RPG display file where it is rendered as the chart and the tabular data.

FVENN0AFM  CF   E             WORKSTN Handler('MOBILERPG')            
F                                     Sfile(VenN0ASfl:VenN0ARRN)      
FMRVENN1C  IF   E           K DISK                                    

DUsuDesc          S             50A                                   
DAnoAct           S              4S 0                                 
DMesAct           S              2S 0                                 
DMesParm          S              2S 0                                 
DVenN0ARRN        S              4S 0                                 

 *********************************************************************
 * Entry parameters                                                   
 *********************************************************************
C     *ENTRY        PLIST                                             
C                   PARM                    UsuDesc                   

 *********************************************************************
 * Key access definition                                              
 *********************************************************************
C     KN1C          KLIST                                             
C                   KFLD                    AnoAct                    
C                   KFLD                    MesAct                    

 *********************************************************************
 * Use the RPG-Cycle to manage the display                            
 *********************************************************************
C                   Eval      ioUsuDesc = UsuDesc                     
C                   Eval      AnoAct = *YEAR                          
C                   Eval      ioTitulo = 'Ventas año ' +              
C                                        %EditC(AnoAct: '3')          
C                   ExSr      FillGraphSr                             
C                   ExFmt     GraphMenu                               
C                   Select                                            
 * End/Back                                                           
C                   When      *In03 Or *In12                          
C                   ExSr      ExitSr                                  
 * Dropdown month selection                                           
C                   When      *In06                                   
C                   Eval      MesParm = ioMesDet                      
C                   ExSr      MesDetSr                                
 * Graph tapping selection                                            
C                   When      *In09                                   
C                   ReadC(E)  VenN0ASfl                               
C                   If        Not %Error                              
C                   Eval      MesParm = %Int(%Trim(chMes))            
C                   ExSr      MesDetSr                                
C                   EndIf                                             
C                   EndSl                                             
 *********************************************************************
 *************************** SUBROUTINES *****************************
 *********************************************************************
C     ExitSr        BegSr                                             
C                   Eval      *InLR = *On                             
C                   Return                                            
C                   EndSr                                             
 *********************************************************************
C     FillGraphSr   BegSr                                             
C                   Eval      *In99 = *On                             
C                   Write     VenN0ASfc                               
C                   Eval      VenN0ARRN = 0                           
C     1             Do        12            MesAct                    
C     KN1C          SetLl(E)  MRVENN1C                                
C     KN1C          ReadE(E)  MRVENN1C                                
C                   Eval      dtVentas = 0                            
C                   Eval      dtPto = 0                               
C                   Eval      dtUnis = 0                              
C                   DoW       Not %Eof And Not %Error                 
C                   Eval      dtVentas += (N1EUR / 1000)              
C                   Eval      dtPto += (N1PTO / 1000)                 
C                   Eval      dtUnis += (N1UNI / 1000)                
C     KN1C          ReadE(E)  MRVENN1C                                
C                   EndDo                                             
C                   Eval      chMes = %EditC(MesAct: '3')             
C                   Eval      VenN0ARRN += 1                          
C                   Write     VenN0ASfl                               
C                   EndDo                                             
C                   Eval      ioCatTit = 'Month'                      
C                   Eval      *In99 = *Off                            
C                   Write     VenN0ASfc                               
C                   EndSr                                             
 *********************************************************************
C     ErrorSr       BegSr                                             
C                   DoW       *In12 = *Off                            
C                   ExFmt     FERROR                                  
C                   EndDo                                             
C                   Eval      *In12 = *Off                            
C                   EndSr                                             
 *********************************************************************
C     MesDetSr      BegSr                                             
C                   CALL      'RVENN0A1'                              
C                   PARM                    AnoAct                    
C                   PARM                    MesParm                   
C                   PARM                    UsuDesc                   
C                   EndSr                                             
 *********************************************************************
Figure 2e. The RPG that populates Figure 2c and 2d’s subfiles

When the user selects the Total per sales director option (from the panel shown in Figure 1b) a list of sales people is displayed as shown below in Figure 3. Note that for anyone with a phone number a link is provided to initiate a phone call to that person.

Figure 3. The sales director list

Mobile RPG’s integrate well with mobile devices’ intrinsic facilities (eg, text messaging, telephone, GEO location and images).  To initiate a phone call, Mobile RPG provides a special case hyperlink that when tapped invokes the mobile device’s telephone dialer.

Double-clicking on a sales director’s row shows that director’s sales data. Selecting the All item displays a pie chart showing cumulative sales per sales director.

Figure 4a. The sales director sales bar chart

Figure 4b. The sales director accumulative sales pie chart

These screens provide navigation to other levels of the app (eg, navigating from sales director to sales rep, and from sales rep to POS).

The next set of images show the same app running on an iPad tablet. ASNA Mobile RPG supports Apple, Android, and Windows 8-based tablets.

Figure 5a. User login

Figure 5b. POS menu

Accessing the Location option shows the customer’s location using Google Maps.

Figure 6a. POS panel with a Google map

Like its charts and tabular data, Mobile RPG presents the map control to the RPG program as a traditional subfile. The DDS below in Figure 6b is generated when panel shown in Figure 6a is exported to a traditional display file.

A          R MAPSMENU                                         
A                                      OVERLAY                
A            IOUSUDESC     50A  O  1  2                       
A            PVCODI         3Y 0O  1 54                       
A            PVDESC        50A  O  2  1                       
A            PVDIR1        50A  O  3  1                       
A            PVCPOS         5A  O  3 53                       
A            PVPOBL        50A  O  4  1                       
A            PVPROV        50A  O  5  1                       
A            PVTELF         9A  O  5 53                       
A            PVTELFT        9   M                             
A            PVTELFU       10   M                             
A          R FERROR                                           
A                                      OVERLAY                
A            IOERROR       50A  O  1  2                       
A          R LOCPVSFL                  SFL                    
A            FULLADDR     128A  O  2  1                       
A          R LOCPVSFC                  SFLCTL(LOCPVSFL)       
A                                      SFLSIZ(2)              
A                                      SFLPAG(1)              
A N99                                  SFLDSP                 
A N99                                  SFLDSPCTL              
A  99                                  SFLCLR                 
A                                      OVERLAY
 Figure 6b. The DDS generated by Mobile RPG to display a Google map.

The RPG to populate the map’s subfile is shown below in Figure 6c.

FLOCPVFM   CF   E             WORKSTN Handler('MOBILERPG')            
F                                     Sfile(LocPVSfl:LocPVRRN)        

FMRPVEN    IF   E           K DISK                                    

DUsuDesc          S             50A                                   
DCodParm          S              3S 0                                 
DLocPVRRN         S              4S 0                                 

 *********************************************************************
 * Entry parameteres                                                  
 *********************************************************************
C     *ENTRY        PLIST                                             
C                   PARM                    CodParm                   
C                   PARM                    UsuDesc                   

 *********************************************************************
 * Use the RPG-Cycle to manage the display                            
 *********************************************************************
C                   Eval      ioUsuDesc = UsuDesc                     
C                   ExSr      FillMapsSr                              
C                   ExFmt     MapsMenu                                
C                   Select                                            
C                   When      *In03 Or *In12                          
C                   ExSr      ExitSr                                  
C                   EndSl                                             
 *********************************************************************
 *************************** SUBROUTINES *****************************
 *********************************************************************
C     ExitSr        BegSr                                             
C                   Eval      *InLR = *On                             
C                   Return                                            
C                   EndSr                                             
 *********************************************************************
C     FillMapsSr    BegSr                                             
C                   Eval      *In99 = *On                             
C                   Write     LocPVSfc                                
C                   Eval      LocPVRRN = 0                            
C     CodParm       Chain(E)  MRPVEN                                  
C                   Eval      FullAddr = %Trim(PVDIR1) + ', ' +       
C                                        %Trim(PVPOBL) + ', ' +       
C                                        %Trim(PVCPOS)                
C                   Eval      PVTELFT = PVTELF                        
C                   Eval      PVTELFU = PVTELF                        
C                   Eval      LocPVRRN += 1                           
C                   Write     LocPVSfl                                
C                   Eval      LocPVRRN += 1                           
C                   Write     LocPVSfl                                
C                   Eval      *In99 = *Off                            
C                   Write     LocPVSfc                                
C                   EndSr                                             
 *********************************************************************
Figure 6c. The RPG to populate the map’s subfile shown in Figure 6b.

Tapping on the Orders option (shown in Figure 5b) displays the POS orders.

Figure 7a. Open orders panel

Figure 7b. Open order detail

Figure 7c. Changing an order

As you can see, creating mobile applications for the IBM i is now easy and fast with ASNA Mobile RPG and requires no special skills. You only need to know RPG to create great mobile apps with ASNA Mobile RPG.

With ASNA Mobile RPG:

  • The entire program is written on the IBM i with RPG.
  • The learning curve is minimal and results are immediate.
  • Mobile RPG integrates with native elements of mobile devices.

Mobile applications are rapidly moving from luxury to necessity. With Mobile RPG, you can keep your business competitive, adopt powerful new business workflows, and put answers in the hands of your mobile workforce.