Features
Your First Pocket PowerBuilder Application
Your First Pocket PowerBuilder Application
Oct. 28, 2003 01:37 PM
The mobile enterprise application development market is continuously evolving. A short time ago, developers were focused on building wireless Internet applications using technologies such as WAP.
Over the past couple of years, the preferred
architecture for enterprise
applications has shifted toward a
smart client model where the mobile
application incorporates persistent data
storage and synchronization. To address
the changing application model, new
development tools, including PenRight!
MobileBuilder, AppForge MobileVB, and a
number of Java tools came to market.
These tools deliver a rich slate of components
and strong database access, but still
don't address a key aspect of smart client
development – data synchronization (see
"Synchronization Is the Key" sidebar).
Pocket PowerBuilder, a new mobile
application development tool, supports all
aspects of smart client application development,
including data synchronization.
While new to the mobile market, it has a
long heritage in the enterprise application
space. As the name suggests, Pocket
PowerBuilder is based on the Sybase
PowerBuilder product, which has built a
name for itself by providing unmatched
productivity in building enterprise database
applications. All of the key features
from PowerBuilder have been incorporated
into Pocket PowerBuilder, making it a
formidable mobile application development
tool.
Some unique features that allow Pocket
PowerBuilder to excel in enterprise mobile
application development include:
Easy-to-use, productive IDE: The Pocket
PowerBuilder Integrated Development
Environment (IDE) provides a complete
set of components, built-in functions,
and wizards that make building mobile
applications a snap. The environment is
full of GUI painters that provide dragand-
drop development for every aspect
of your application.
DataWindow component: The
DataWindow component brings a
whole new level of richness to mobile
computing. It provides rapid data
access and manipulation along with a
variety of sophisticated presentation
styles (grids, tables, freeform, graphs)
with no coding necessary.
Database integration: Pocket
PowerBuilder integrates directly with
SQL Anywhere Studio, providing developers
with all the technologies they
require to build smart client applications
in a single package.
Synchronization support: Pocket
PowerBuilder has addressed the synchronization
component of smart client applications
by including a synchronization
wizard that takes the developer through
every aspect of adding enterprise database
synchronization to their applications.
The wizard outputs a set of components
and windows that are fully modifiable,
and control all synchronization
aspects within the mobile application.
Getting Started
When developing smart client mobile
applications, several items outside of the
development environment have to be
addressed – creating a remote database, creating
synchronization logic, and starting a
synchronization server. These are not specific
to the mobile development tool, but are
related to the mobile database and synchronization
technology used. In this case, the
Adaptive Server Anywhere (ASA) database
and MobiLink synchronization technology
from SQL Anywhere Studio are used, as
they're included in the Pocket PowerBuilder
package. These technologies offer integration
with other enterprise databases on the
server-side including Sybase Adaptive
Server Anywhere, Sybase Adaptive Server
Enterprise, Oracle8i and 9i, Microsoft SQL
Server, and IBM DB2. Figure 1 depicts a
smart client architecture.
Before a mobile application is developed,
the following three steps need to be
performed:
1. Create a Remote Database
Defining the remote database is one of
the most important steps in creating a
mobile application. It defines what data is
available to the remote user, consequentially
dictating the functionality of the
remote application. In general, the
remote database is much smaller than
the consolidated database (for obvious
reasons!). It will typically have a subset of
the schema from the consolidated database,
although this is not an absolute
requirement. The most important thing is
that the data types of the remote data
being synchronized match the corresponding
consolidated database data types.
The Database Painter in Pocket
PowerBuilder can be used to create
the remote ASA database. This will
work well for developers who are intimately
familiar with their consolidated
database schema. If this isn't the
case, a data-modeling tool may be a
better choice. The database administration
tool that comes with SQL
Anywhere Studio includes a migration
utility that can be used to create a
remote ASA database with the same
schema as an existing enterprise database.
2. Creating Synchronization Logic
The synchronization logic controls the
subset of data that flows between the
remote and consolidated databases. It
defines what data is synchronized and
how the changes are applied at each
end. It's a critical component of smart
client applications (see sidebar). When
using MobiLink Synchronization, a
variety of technologies including SQL,
Java, and any .NET programming language
can be used to define the synchronization
logic.
3. Starting the Synchronization Server
Communication between the mobile
application and the enterprise goes
through a synchronization server. This
server can either reside on the same
machine as the enterprise database or
on a machine of its own.
Pocket PowerBuilder can be used to
start the MobiLink Server from within
the IDE. There are also options available
to have a default set of synchronization
scripts created for you, providing
a great starting point for developing
custom synchronization applications.
Building a Smart Client Pocket PowerBuilder Application
When developing occasionally connected
mobile applications in Pocket
PowerBuilder, five key steps have to be
performed. Each of these steps will be
addressed at a high level. If you're looking
for an in-depth tutorial on Pocket
PowerBuilder, you can purchase or download
an evaluation copy from Sybase at
www.sybase.com/pocketpowerbuilder,
and go through the SalesDB tutorial
that's included with the product.
Step 1: Create the Database Profile
The Pocket PowerBuilder application
is developed using the remote database,
not the consolidated. This is logical, since
the deployed application will be running
on a Pocket PC device and won't have
direct access to the consolidated database.
Before developing the application, a
Database Profile for the remote database
has to be created. In Pocket
PowerBuilder select the Tools —>
Database Profile… menu option to create
the profile for the remote database.
This database profile will be used
throughout the entire application development
process.
Step 2: Design the Application's Forms
The Pocket PowerBuilder development
environment contains four main areas:
1. The PowerBar located at the top of the
IDE is where all of the most common
actions can be invoked.
2. The Workspace View on the left side of
the IDE is where projects are managed
and is the main navigation area for a
Pocket PowerBuilder application.
3. The Application Painter is where
Windows are designed using drag-anddrop
development. There are a variety
of views for an application including a
WYSIWYG Layout View, a Code View, an
Event List, and a Function List.
4. The debug/output console is where the
developer will find build information as
well as warnings or errors that may
occur.
The first item that needs to be created
when starting a new application is an
application workspace. Within the workspace,
targets are then added; multiple targets
can exist within a single workspace.
Inside of the target is where the developer
can then add new Pocket PowerBuilder
Objects (Windows, menus, non-visual
objects, etc.), DataWindows, database and
synchronization components, and projects.
When designing a smart client mobile
application, developers typically start by
designing the application's layout. This
involves creating a number of forms
(Windows) and adding visual components
to them. Most Pocket PC applications
consist of multiple screens that are
navigated by menus and tab controls
(MDI applications are not supported on
Windows CE). Since the screen size of
Pocket PC devices is significantly smaller
than that of desktops, the user interface
and navigation of the handheld application
require special attention. Pocket
PowerBuilder has some features that are
specifically designed to make Pocket PC
development straightforward. These features
include a menu painter, tab controls,
Soft Input Panel (SIP) integration,
default window sizes to match those on a
Pocket PC device, and specialized window
controls such as Smart Minimize (X) and
Close (OK). All of these properties are
accessed using property sheets as shown
in Figure 2.
In addition, Pocket PowerBuilder
comes with a rich set of prebuilt components
to facilitate the development of
sophisticated mobile applications. A partial
list of these controls includes
Command Button, Picture Button,
CheckBox, Radio Button, Static Text, List
View, Tree View, List Box, DropDown List
Box, Edit Mask, Single Line Edit, MultiLine
Edit, Progress Bar, and Scroll Bars. These
components are used frequently during
mobile application development. For
sophisticated database integration and
presentation logic, the DataWindow component
is a powerful option.
Step 3: Create DataWindow Components
When it comes to creating data-driven
applications, the DataWindow is Pocket
PowerBuilder's crown jewel. The
DataWindow provides the ability to incorporate
database access (SQL inserts,
deletes, updates, etc.) and advanced presentation
logic (Freeform, Graphs, Grids,
Groups, and Tabular) into a single component.
The ease-of-use and robustness of
this component considerably increases
the productivity of mobile application
developers. Figure 3 shows a DataWindow
component using a graph presentation
style.
Once the user interface is created,
PowerScript is used to add business logic
to the application, ideally by using nonvisual
objects. The separation of presentation
logic from business logic has been
identified as the preferable development
strategy for some time now, and it definitely
makes sense for Pocket PowerBuilder applications.
At this point, the application can interact
with the remote ASA database, but it
doesn't have any form of enterprise integration.
This is where enterprise data synchronization
comes into play.
Step 4: Add Synchronization Support to the Mobile Application
This is the final and traditionally one
of the more difficult stages of application
development. Logic has to be added to
the client application to communicate
with the MobiLink Client as well as to
provide the application user with the ability
to change any synchronization options
that may need to be altered at runtime.
Fortunately for Pocket PowerBuilder
developers, this has all been automated
with the MobiLink Synchronization wizard
as shown in Figure 4.
The wizard goes through every detail
required to add synchronization to a
Pocket PowerBuilder client application.
During the wizard, the developer will be
required to specify:
Information on how to connect to the
remote database
Which publications are going to be
used
How status information is going to be
displayed to the application user
Which MobiLink Client options are
required
How much control the application user
will have at runtime
The names of the objects that are generated
into the application
The output of the wizard depends
largely on the options that were selected
on the wizard pages. Minimally the wizard
will create an NVO that controls the
MobiLink Synchronization client and a
generated function to instantiate the NVO
and launch a synchronization request.
Beyond these two items, it's also possible
to automatically create a MobiLink status
window to display the synchronization
status, as well as a window to allow the
application user to change the MobiLink
command-line parameters at runtime.
Both of these generated windows can be
used as is, or can be customized by the
application developer.
At this point all the developer has to do
is add the appropriate code to start the
synchronization request. This is usually
added in the click event of a menu item,
but can be located anywhere within an
application. The code to launch the synchronization
will look like this:
// Start synchronization
if gf_sync_salesapi("ml_username", "ml_password")
<> 0 then
MessageBox("Error", " MobiLink
Synchronization Error. ");
End if
// Fetch data
f_refresh_orders(-1)
Step 5: Deploy the Application
Once the synchronization component
of the application has been implemented,
it's time to test/deploy the application.
Pocket PowerBuilder provides integrated
deployment to the following environments:
Desktop machine: Provides a quick way
to test the user interface and database
integration without having to deploy
the files to an emulator or device.
Pocket PC emulator: Microsoft has made
available a software emulation of the
Windows CE operating system in the
form of the Pocket PC Emulator. This
provides a way to get a more accurate
representation of how an application will
work without having a physical device.
Pocket PC device: The best way to
determine the characteristics of an
application is by testing it on a physical
Pocket PC device. A device provides a
true indication of an application's user
interface and performance. Similar to
an emulator, the Pocket PowerBuilder
VM and related database files have to
be installed onto the device before
application testing is possible.
For smart client applications, two
additional items need to be deployed
along with the mobile application:
The ASA database engine
The ASA database and DSN files
Finally, for organizations that have
larger numbers of remote users or users
in many geographies, mobile software
deployment and management software is
worth looking into. Manage Anywhere
Studio from iAnywhere Solutions provides
a way to centrally manage all of the
mobile assets within an organization.
Conclusion
Smart client mobile applications with
database and synchronization provide a
way for organizations to guarantee anytime,
anywhere data access to their
mobile workers. Pocket PowerBuilder has
all the components required to develop
sophisticated smart client applications.
With the tight database integration and
MobiLink Synchronization wizard, Pocket
PowerBuilder will drive the development
of smart client mobile applications for
years to come.
SYNCHRONIZATION IS THE KEY
With the shift from online only to smart client application models in mobile computing,
a new emphasis has been placed on mobile database and synchronization technologies.
While most developers clearly understand the issues surrounding a mobile
database, there are often many questions around what should be included in an enterprise
synchronization product. Here are a few key items to take into consideration:
Network protocol support
Creation of synchronization logic
How data is partitioned for the remote users
Support for conflict and error handling
Ability to synchronize with a multiple enterprise databases
Security features
When evaluating mobile application technologies, pay particular attention to the
synchronization component of the solution. A complete solution will address the main
issues listed above in a flexible, open manner. In smart client applications, this technology will integrate your mobile data with your enterprise systems.
About Martyn MallickMartyn Mallick is Senior Software Engineer in Product Management and Wireless Solutions Evangelist for iAnywhere Solutions, a subsidiary of Sybase Inc and the author of Mobile and Wireless Design Essentials (Wiley 2003, ISBN 0471214191, www.amazon.com/mallick)