0% found this document useful (0 votes)
28 views

OEDK Tutorial Getting Started OpenEdge 11.7

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

OEDK Tutorial Getting Started OpenEdge 11.7

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 101

OpenEdge® Developers Kit:

Getting Started with OpenEdge

OpenEdge Developers Kit: Getting Started with OpenEdge Page 1 of 101


© 2017 Progress Software Corporation. All rights reserved.
Notices

© 2017 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.

These materials and all Progress® software products are copyrighted and all rights are reserved by Progress
Software Corporation. The information in these materials is subject to change without notice, and Progress
Software Corporation assumes no responsibility for any errors that may appear therein. The references in
these materials to specific platforms supported are subject to change.

Business Making Progress, Corticon, DataDirect (and design), DataDirect Cloud, DataDirect Connect,
DataDirect Connect64, DataDirect XML Converters, DataDirect XQuery, Deliver More Than Expected,
Icenium, Kendo UI, Making Software Work Together, NativeScript, OpenEdge, Powered by Progress,
Progress, Progress Software Developers Network, Rollbase, SequeLink, Sitefinity (and Design),
SpeedScript, Stylus Studio, TeamPulse, Telerik, Telerik (and Design), Test Studio, and WebSpeed are
registered trademarks of Progress Software Corporation or one of its affiliates or subsidiaries in the U.S.
and/or other countries. AccelEvent, Analytics360, AppsAlive, AppServer, Arcade, BravePoint,
BusinessEdge, DataDirect Spy, DataDirect SupportLink, DevCraft, DigitalFactory, Fiddler, Future Proof,
High Performance Integration, JustCode, JustDecompile, JustMock, JustTrace, OpenAccess, ProDataSet,
Progress Arcade, Progress Profiles, Progress Results, Progress RFID, Progress Software, ProVision, PSE
Pro, SectorAlliance, Sitefinity, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects,
SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery,
SmartViewer, SmartWindow, WebClient, and Who Makes Progress are trademarks or service marks of
Progress Software Corporation and/or its subsidiaries or affiliates in the U.S. and other countries. Java is a
registered trademark of Oracle and/or its affiliates. Any other marks contained herein may be trademarks of
their respective owners.

Please refer to the Release Notes applicable to the particular Progress product release for any third-party
acknowledgements required to be provided in the documentation associated with the Progress product.

The Release Notes can be found in the OpenEdge installation directory and online at:
https://community.progress.com/technicalusers/w/openedgegeneral/1329.openedge-product-
documentation-overview.aspx.

For the latest documentation updates see OpenEdge Product Documentation on Progress Communities:
(https://community.progress.com/technicalusers/w/openedgegeneral/
1329.openedge-product-documentation-overview.aspx).

April 2017

Last updated with new content: Release 11.7.0

OpenEdge Developers Kit: Getting Started with OpenEdge Page 2 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tutorial Sections

Section name Page

GETTING STARTED WITH PROGRESS® OPENEDGE® ............................................................................ 4


DEFINITIONS AND ABBREVIATIONS ..................................................................................................... 12
LAB 01: GETTING STARTED WITH DEVELOPER STUDIO ...................................................................... 14
LAB 02: STARTING AN OPENEDGE DATABASE SERVER ...................................................................... 23
LAB 03: CONNECTING A DATABASE TO A PROJECT ............................................................................. 33
LAB 04: A LOOK AT THE OPENEDGE RDBMS .................................................................................... 38
LAB 05: WORKING IN THE OPENEDGE EDITOR ................................................................................... 46
LAB 06: A LOOK AT ABL..................................................................................................................... 59
LAB 07: MODIFYING DATABASE RECORDS WITH ABL ....................................................................... 70
LAB 08: WORKING WITH ABL QUERIES ............................................................................................. 76
LAB 09: OPTIONAL - ABL GUI PROCEDURE EDITOR .......................................................................... 80
TUTORIAL SUMMARY ........................................................................................................................ 101

OpenEdge Developers Kit: Getting Started with OpenEdge Page 3 of 101


© 2017 Progress Software Corporation. All rights reserved.
Getting Started with Progress® OpenEdge®

Welcome to this tutorial on getting started with Progress OpenEdge using the
OpenEdge Developers Kit

Welcome to this tutorial on getting started with Progress OpenEdge. The tutorial
introduces OpenEdge by guiding you through hands on exercises where you’ll code
using OpenEdge Advanced Business Language (ABL), work with data in the
OpenEdge RDBMS, and become familiar with a number of OpenEdge application
development tools.

Upon completing this tutorial you’ll have an understanding how you can develop
applications using OpenEdge. You’ll have gained knowledge of many of the
capabilities provided by the OpenEdge platform. You’ll also know how to find
additional information to put your newly acquired knowledge to use.

The tutorial is designed to work with the OpenEdge Developers Kit: Classroom
Edition. This is a free version of OpenEdge has everything required for you to get
started with using the Progress® OpenEdge® Platform. The Classroom Edition
includes Progress Developer Studio for OpenEdge (Developer Studio).

Please see Installing the Progress® OpenEdge® Developers Kit document which
covers installation of the Developers Kit. This tutorial can also be used with a
commercial install of Progress Developer Studio for OpenEdge.

Enjoy the tutorial!

OpenEdge Developers Kit: Getting Started with OpenEdge Page 4 of 101


© 2017 Progress Software Corporation. All rights reserved.
OpenEdge Courses Included with the Classroom Edition of OpenEdge Developers Kit

There are three free courses that are included with the Classroom Edition of OpenEdge
Developers Kit. These can be viewed on-line. It’s not necessary to take these courses
prior to going through the tutorial. They are provided as additional learning resources.

It’s recommended that these courses be taken in the order listed here.
1. Introduction to Progress OpenEdge
2. Introduction to Progress OpenEdge Integration
3. Developing a Progress OpenEdge ABL Application

Follow these steps to access these courses:


 Go to the Progress Education Community (PEC) by selecting this link:

https://wbt.progress.com

 Enter your Progress ID and Password.

 To take a course, select it from the list under Enrollments.

Additional Information

The links below provide additional information on OpenEdge.

OpenEdge Product Evaluation Support:

https://www.progress.com/support/evaluation

Go to this link to find answers to frequently asked questions regarding your


OpenEdge product evaluation.

Progress Community:

https://community.progress.com/

Progress Community provides a format for asking questions, sharing ideas, and
having in-depth technical discussions with Progress partners, customers and
Progress product experts.

OpenEdge webinars:

https://www.progress.com/resources/webinars

A number of webinars are accessible from this link.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 5 of 101


© 2017 Progress Software Corporation. All rights reserved.
At the time this tutorial is being created the latest one is on the OpenEdge 11.7
release. View this webinar to see how to make your business a success with
the latest release of OpenEdge 11.7 + Mobility; titled Progress® OpenEdge®
11.7: It’s All About ‘Apptitude’.

Contact a Progress Sales Representative:

https://www.progress.com/contact-us

If you are ready to move forward with a product purchase, an upgrade, or have
questions, don’t hesitate to go to this link to locate a Progress Sales Representative.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 6 of 101


© 2017 Progress Software Corporation. All rights reserved.
Progress OpenEdge

The Progress OpenEdge Platform is a widely used software development platform


that empowers businesses to create enterprise business applications. Below are a
few examples showing the broad range of industries that continue to succeed using
OpenEdge based applications.

Select the link below to learn more about the OpenEdge Platform and how you can
make it a part of your successful business strategy:

https://www.progress.com/openedge/overview

To find out more about Progress Software visit:

https://www.progress.com/.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 7 of 101


© 2017 Progress Software Corporation. All rights reserved.
Overview of the tutorial

This tutorial contains labs designed to walk you through a hands-on set of steps
which highlight a number of areas in the OpenEdge Platform. Each lab focuses on
a particular topic that supports OpenEdge application development. After
completing the labs you’ll have a broad overview of OpenEdge and the powerful
tools that it includes. To keep the flow going, the tutorial contains minimal
explanations of tasks. For times when you would like additional information on a
particular topic, many references and links are provided throughout the tutorial.

Note: This tutorial works with OpenEdge 11.7. It should not be used with earlier versions of
OpenEdge since some screen layouts have changes and features have been added that are not
available in prior releases of OpenEdge.

Optionally, start working with ABL code first

The last lab has been included for developers that want to start by taking a look at
ABL. Advanced Business Language (ABL) is Progress Software Corporation's
language for developing business applications. This high-level language supports
procedural, dynamic, and object-oriented programming. It’s used for both client
and server application development. You can jump ahead to lab 09 now if this is
your preference.

Prerequisites
General knowledge of using a Microsoft Windows is needed. It’s also helpful to
have basic knowledge of application development. However, this is not required
since the labs are designed to guide you through each step.

Prior to this tutorial the Classroom Edition of the OpenEdge Developers Kit needs
to be installed. Please see Installing the Progress® OpenEdge® Developers Kit
for more information on installation.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 8 of 101


© 2017 Progress Software Corporation. All rights reserved.
Progress Community

You can ask questions and find answers on Progress Community:

https://community.progress.com/

For example there are a number of Forums on a variety of Progress Software


products and topics.

A sampling of the available Progress Forums:

 OpenEdge Development:

https://community.progress.com/community_groups/openedge_development/

This forum covers OpenEdge development of business software applications


across many industries and regions.

 OpenEdge RDBMS:

https://community.progress.com/community_groups/openedge_rdbms/

Everything you need to know about the OpenEdge RDBMS can probably be
found in this group.

 OpenEdge General:

https://community.progress.com/community_groups/openedge_general/

This form covers application development platform resources for OpenEdge


developers, partners and users.

 Mobile:

https://community.progress.com/community_groups/mobile/

The Mobile form provides developers with a way to communicate, collaborate,


and comment on Progress mobile application topics.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 9 of 101


© 2017 Progress Software Corporation. All rights reserved.
OpenEdge Documentation

The place to find in-depth technical information on OpenEdge is the OpenEdge


documentation set. Documents can be viewed on-line in either PDF or HTML
format or downloaded for off-line viewing. The tutorial was created using
OpenEdge 11.7.

Viewing the current OpenEdge Release documentation supporting full search:

You’ll find latest version of the OpenEdge documentation at this link:

https://documentation.progress.com/output/ua/OpenEdge_latest/index.html

From here you can view all of the manuals. A nice feature of this site is that
searches are supported across the entire documentation set. This is a real time
saver since you don’t need to search each individual manual to find references to a
particular search.

Downloading the entire OpenEdge Release 11.7 documentation set:

If you’d like to have off-line access to all of the OpenEdge manuals then you can
choose from one of these options to download the documents in PDF and HTML
formats:
https://documentation.progress.com/

Once downloaded and unzipped, open the start.pdf to access the


documentation set in PDF formats or the index.html file to launch the help
system.

Best practices and enterprise level applications are not included in


the tutorial

The focus of this tutorial is to introduce a number of the features in the OpenEdge
Platform, emphasizing functionality. A goal of the tutorial is simplicity of
presentation using a minimal number of steps to present each feature. The tutorial
does not focus on best practices, since this would significantly increase the size of
the tutorial. The sample applications and tutorial code are not intended to be
production level code. For example, the tutorial code has very little of the error
handling that would be needed in an actual enterprise application.

When you’re ready to dig deeper into a particular topic you’ll find best practices in
the OpenEdge documentation, in OpenEdge courses, and on Progress Community.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 10 of 101


© 2017 Progress Software Corporation. All rights reserved.
About this tutorial

The labs were written for OpenEdge 11.7. These labs are provided as is with no
support.

Throughout the tutorial icons are used to identify several types of text that provide
supplemental information:

Cautions alert you to important information to help you avoid potential problems. You
should always read Cautions.

Notes provide you with additional details about the current task, but which are not required to
complete the step. It’s recommended that all Notes be read.

Information indicates where to find more information on a topic.

Tips provide suggestions on good programming practice.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 11 of 101


© 2017 Progress Software Corporation. All rights reserved.
Definitions and Abbreviations

This section provides brief definitions to some of the major components that are
part of the OpenEdge Platform. In addition, abbreviations are listed for some of
the terms.

 ABL Virtual Machine (AVM)

An AVM runs as a separate process on the system and is used to


compile and execute ABL programs. AVMs are available on
Windows, Linux and UNIX. However, the OEDK: Classroom Edition,
and therefore the AVM, is only supported on Windows 64-bit.

 AdminServer

A central server process that must be running as a service on any host


that runs an OpenEdge server product. It is used to consolidate and
coordinate configurations used by server products running on a host.

 Advanced Business Language (ABL)

Progress Software Corporation's language for developing business


applications. This high-level language supports procedural, dynamic,
and object-oriented programming. It is used for client and server
development.

 Eclipse development platform

An industry-standard development environment. It includes a standard


plug-in architecture for adding custom features. The Progress
Developer Studio for OpenEdge is built on the Eclipse platform.

 GUI for .NET Client

An ABL Client that displays a UI that provides native support for


.NET forms in ABL. All .NET forms, .NET controls, and .NET
foundation classes can be directly viewed, communicated with, and
manipulated using ABL event-driven and object-oriented programming
syntax.

 OpenEdge AppServer (AppServer)

An OpenEdge Application Server that provides application services to


ABL and Open Clients.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 12 of 101


© 2017 Progress Software Corporation. All rights reserved.
 OpenEdge Explorer (OEE)

A Web application that provides a developer or administrator


configuration and management functionality for OpenEdge processes.

 OpenEdge Relational Database Management System


(OpenEdge RDBMS, OpenEdge Database)

The OpenEdge RDBMS is an open, scalable, highly available, and


reliable database solution that supports a virtually unlimited number of
users and transactions with minimal administration and maintenance,
and world-class security compliance.

 Progress Application Server for OpenEdge


(PAS for OpenEdge, Progress Application Server for OpenEdge)

An OpenEdge Application Server used for executing application


business logic. It comes with built-in adapter processes that allow your
application to be accessed by a variety of clients including ABL,
browser-based, and mobile. It runs in a Tomcat Web Server and
includes a Session Manager and multiple agents. Each agent is an ABL
Virtual Machine (AVM) that can compile and execute its own ABL
code.

 Progress OpenEdge Developers Kit (Developers Kit, OEDK)

A free version of OpenEdge that has everything required for you to get
started using the Progress® OpenEdge® Platform. The Classroom
Edition includes Developer Studio (with AVM, ABL, development
versions of AppServer, OpenEdge RDBMS, and PAS for OpenEdge)

 Progress Developer Studio for OpenEdge (Developer Studio)

An Eclipse-based tool used for developing ABL applications and for


packaging resources that are used by external applications and
OpenEdge clients of all types.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 13 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 01: Getting started with Developer Studio
Overview
This lab provides hands-on exercises to get you started using Progress Developer
Studio for OpenEdge (Developer Studio). Developer Studio is built on the
Eclipse platform. Eclipse is installed as part of the Developer Studio installation.

Information: Information on Developer Studio can be found in the OpenEdge manual:


Tools: Progress Developer Studio for OpenEdge Online Help.

Prerequisites
Complete the following task prior to doing this lab:
 Complete the steps in Installing the Progress® OpenEdge® Developers Kit
document

Creating a Workspace using Developer Studio

Developer Studio is the preferred tool for developing OpenEdge applications. This
section shows how to start Developer Studio and how to create a workspace. A
workspace contains projects, folders, and files. It also supports a wide variety of
settings that can be used to customize the workspace. Each time you start
Developer Studio either an existing workspace is selected or a new one is created.

1. Start developer studio by selecting


All Programs → Progress → OpenEdge 11.7 (64-bit) → Developer Studio

Tip: You’ll be starting Developer Studio often. It can save some time by placing shortcuts
in a folder on the desktop. To add these shortcuts create a desktop folder named OEDK. Add
shortcuts for these icons Developer Studio, OpenEdge Explorer, and others as needed.
For example, after creating the OEDK folder, copy each icon by selecting Start → All
Programs → Progress → OpenEdge. Then right-click on the icon and select Copy. Go to
the OEDK folder, right-click and click Paste to create the shortcut.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 14 of 101


© 2017 Progress Software Corporation. All rights reserved.
The Developer Studio splash screen displays during startup.

2. Create an Eclipse workspace by entering C:\OpenEdge\WRK\wsOEDK as the


Workspace name, and then clicking OK. For example:

Note: The directories OpenEdge and WRK were created during the install of Developers
Kit. A workspace can be created in almost any directory. The name wsOEDK was selected to
represent workspace for OpenEdge Developers Kit.

Note: This note describes terms used in Developer Studio, and also for Eclipse:
- Workspace is a work area that contains one or more projects. The projects may be related
as part of an application. Only one workspace is open at a time.
- Project contains directories and files. They have natures (facets) that are included in the
project to support features. For example support for editing and compiling code such as
ABL.
- Workbench is used to describe the grouping of tools that are available in a workspace.

Note: A workspace and its resources are physically located on a hard drive. It’s strongly
recommended that you do not directly modify any existing files in the workspace directory
unless you understand the consequences. A workspace can contain an entire development
project, or a portion of a development project.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 15 of 101


© 2017 Progress Software Corporation. All rights reserved.
The Welcome screen that appears the first time a workspace is opened.

Information: The icons on this welcome page can be selected to access additional
information on OpenEdge. You can access this page at any time by selecting Help → Welcome
from the Workbench menu.

3. Click the Workbench icon.


The Developer Studio workbench is displayed:

Note: The workbench supports a number of perspectives, each one designed for a different
type of development task. A perspective is made up of a set of views and an editor area. In this
case, the OpenEdge Editor perspective is open, as indicated in the upper-right tab of the
workbench. By default the OpenEdge Editor perspective includes seven views (tabs): Project
Explorer, Outline, DB Structure, Properties, Console, Problems, and Tasks.

Tip: It’s common for developers to have multiple workspaces. By default there isn’t any
quick way to see the current workspace name. You can modify the icon that you used to open
Developer Studio to include the name of the workspace by adding ‘-showlocation’ to the end of
the Target string like this: C:\Progress\OpenEdge\oeide\eclipse\eclipse.exe -vm
"C:\Progress\OpenEdge\jre\bin\javaw.exe" -showlocation.
(The -showlocation option may not work with Windows 8).

Note the workspace name shown below in the window title:

4. Close the workbench by clicking on the in the top right of the window.
The confirmation dialog is displayed.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 16 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tip: It’s common for developers to check the box Always exit without prompt, to avoid
having to click OK each time a workspace is closed. As with most options you can turn this
back on in the workbench preferences. You can toggle it on by selecting Window →
Preferences from the workbench menu and then going to General → Startup and Shutdown.

5. Click OK to confirm closing the workspace.

Locating information using Developer Studio

This section provides information on how to access on-line help in Developer


Studio. Developer Studio includes on-line help, tools to search for information,
and links to a variety of other resources that will assist you to learn more about
Developer Studio and OpenEdge.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. Access on-line help by selecting Help from the workbench menu.

The Help menu includes links for Help Contents, ABL Message, Search,
Samples, Tutorials, and others, as shown in the screenshot below:

OpenEdge Developers Kit: Getting Started with OpenEdge Page 17 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. Select Help Contents from the workbench Help menu.

From here enter a topic of your choice to locate information on that topic.

Creating an OpenEdge project in Developer Studio

In this section you’ll create a project. All folders and files are organized in projects
in Developer Studio. At a project level you can control a number of settings. For
example a database that is defined for a workspace can be associated with a project.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. From the workbench menu select: File → New → OpenEdge Project

3. Enter myProj for the Project name.


4. Select the General category from the left section.
5. Select the OpenEdge Basic project type and click Finish.
For more information about the project type, see the Developer Studio online
help.
6. Click Finish.
The project is created and is displayed in the Project Explorer view.
The Console view displays a message that an AVM started for myProj.
OpenEdge Developers Kit: Getting Started with OpenEdge Page 18 of 101
© 2017 Progress Software Corporation. All rights reserved.
Note: An AVM is an ABL Virtual Machine. It runs as a separate process on the system
and is used to compile and execute ABL programs. AVMs are available on Windows, Linux and
UNIX. However, the OEDK: Classroom Edition, and therefore the AVM, is only supported on
Windows 64-bit.

Tip: There can be a number of consoles available. The one shown above is the
ABL console, as indicated on the left side. Depending on the environment you can
see this console by clicking on the Console view toolbar . If there is only one
console then the selection options are disabled.

Creating an OpenEdge RDBMS

In later labs you’ll be writing ABL procedures that access data from an OpenEdge
RDBMS. In this section you’ll create a copy of an existing sample database that is
included with the OpenEdge Developers Kit. This is an existing OpenEdge
database that supports both ABL and SQL clients.

Information: Information on the OpenEdge RDBMS can be found in the OpenEdge


manuals: Getting Started: Database Essentials, and Data Management: Database Administration.

Note: This tutorial focuses on the OpenEdge RDBMS. However, OpenEdge supports a number
of data sources, including Oracle databases, Microsoft SQL Server databases, and ODBC data
sources. Collectively these are known as OpenEdge DataServers. OpenEdge ABL applications can
access data from each of these data sources within the same application.

Information: Information on OpenEdge DataServers can be found in the OpenEdge


manuals:
 OpenEdge Data Management: DataServer for Microsoft® SQL Server
 OpenEdge Data Management: DataServer for Oracle
 OpenEdge Data Management: DataServer for ODBC

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. Open the DB Navigator perspective from the workbench menu bar by


selecting:

OpenEdge Developers Kit: Getting Started with OpenEdge Page 19 of 101


© 2017 Progress Software Corporation. All rights reserved.
Window → Open Perspective → DB Navigator

The DB Navigator perspective becomes the active perspective. This


perspective contains views and functionality that supports working with
OpenEdge databases.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 20 of 101


© 2017 Progress Software Corporation. All rights reserved.
For example:

Note: There are now two open perspectives: OpenEdge Editor and DB Navigator. You
can switch between perspectives by selecting from the perspectives tabs in the upper-right of the
workbench

3. From the toolbar in the Connections view, click on the dropdown and select
Create OpenEdge Database to launch the Create Database wizard.

4. In the Create Database wizard:

a. For New Physical Database Name click the Files button.

b. Navigate to directory C:\OpenEdge\WRK.

c. Right-click in the file view to select New → Folder.

d. Name the folder db and press Enter. This creates a new directory that
you will use to hold the database.

e. Click the Open button. This opens directory C:\OpenEdge\WRK\db.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 21 of 101


© 2017 Progress Software Corporation. All rights reserved.
f. For File name enter sport.

g. Click Save.
The New Physical Database Name field displays:
C:\OpenEdge\WRK\db\sport.db

h. For the Start with option, select A copy of the SPORTS2000


database.

Note: This makes a copy of a Sports2000 database, which is included in the OpenEdge
Developers Kit, and names the new copy sport.

5. Click OK in the Create Database wizard to create the database.

6. Click OK to close the message box.

7. Close the DB Navigator perspective, by right-clicking on the DB Navigator


tab and selecting Close.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 22 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 02: Starting an OpenEdge Database server

Overview
An OpenEdge Database can be started in single user mode, or it can support
multiple connections if you start a server for it. For this tutorial you will start a
database server.

In this lab you’ll use OpenEdge Explorer to configure a database server for the
sport database. OpenEdge Explorer is a part of the OpenEdge Platform. It’s used
to configure and control database servers as well as other resources. The sport
database server will be configured to start whenever the Windows system is
rebooted.

Prerequisites
Complete Lab 01: Getting started with Progress Developer Studio for OpenEdge.

Confirm that the AdminServer is started

The OpenEdge installation creates a windows service. This windows service is the
AdminServer and it is set to start automatically. A number of OpenEdge features
depend on the AdminServer. This section will show how to view the service and
how to confirm that it’s running.

1. Open the Control Panel by selecting Start → Control Panel.


Alternatively you can go to directory: Control Panel\All Control Panel
Items.

2. Select Administrative Tools

OpenEdge Developers Kit: Getting Started with OpenEdge Page 23 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. Double-click Services

The Services window opens and you should see the AdminService for
OpenEdge included in the list of services.

By default, the AdminService is configured to start automatically when OEDK


is installed on Windows.

4. If the AdminServer is not running, then click on AdminService for


OpenEdge, and then click Start.

5. Close the Services window and the Control Panel.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 24 of 101


© 2017 Progress Software Corporation. All rights reserved.
Configuring OpenEdge Explorer

OpenEdge Explorer provides support for managing resources. Examples of


resources include databases and application servers. Using OpenEdge Explorer
you can configure, start and stop resources. You can also view status information
for resources including their running status.

Information: Information on OpenEdge Explorer can be found in the OpenEdge manual:


OpenEdge Management and OpenEdge Explorer: Getting Started.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. From the workbench menu select OpenEdge → Admin → OpenEdge


Explorer.

The login prompt for OpenEdge Explorer is displayed.

3. Enter Username: admin and Password: admin, and then click Login to
access OpenEdge Explorer.

Note: The first time that OpenEdge Explorer is accessed the Username and Password are
always admin/admin. The password must be changed during initial configuration the first time
OpenEdge Explorer is started.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 25 of 101


© 2017 Progress Software Corporation. All rights reserved.
4. Click the maximize icon, which is located in the top right of the editor, to
maximize the display of OpenEdge Explorer.

An alternative method to maximize any editor or view is to double-click the


name of the tab.

5. In the OpenEdge Explorer Configuration page enter a new password for


user admin, and click Submit. Retain and use this password the next time you
login to OpenEdge Explorer.

Tip: For this tutorial you can use an easy to remember password such as progress.

The option for Autostart OpenEdge Explorer is checked by default. This


setting should be retained so that OpenEdge Explorer is automatically started
whenever the AdminServer starts.

6. Click Submit to continue.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 26 of 101


© 2017 Progress Software Corporation. All rights reserved.
The second page of the initial configuration of OpenEdge Explorer provides
the option to provide information to Progress for the Customer Experience
Improvement Program.

Note: You can change any of the startup options at anytime by selecting Options from
the OpenEdge Explorer menu bar and then selecting General Configuration.

7. Click Submit to continue.

8. Click Start using OpenEdge Explorer.


OpenEdge Explorer is closed and reopened to allow the new password to take
effect.

Note: When OpenEdge Explorer is opened using Developer Studio it runs in a Web
browser in Developer Studio. You can also run OpenEdge Explorer by selecting the icon ,
which can be found by going to Start → All Programs → Progress → OpenEdge →
OpenEdge Explorer, or by entering in the default URL: http://localhost:9090/?tabs=dbadmin
Port 9090 is the default port for OpenEdge Explorer. OpenEdge Explorer includes support to
change the port number.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 27 of 101


© 2017 Progress Software Corporation. All rights reserved.
9. Log out of OpenEdge Explorer by selecting the ‘person’ icon in the top-
right and selecting Log out.

10. Double-click the OpenEdge Explorer tab to restore the workbench to display
the layout with all views.

Tip: To restore a perspective to the original layout select Window → Reset Perspective
from workbench menu.

11. Click on the tab for OpenEdge Explorer to close OpenEdge Explorer in
Developer Studio.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 28 of 101


© 2017 Progress Software Corporation. All rights reserved.
Updating the OpenEdge Explorer password in Developer Studio

Whenever the password for OpenEdge Explorer is changed, the password used to
access OpenEdge Explorer must be updated in Developer Studio.

Note: OpenEdge Explorer is an application that runs in a browser. Unlike Developer


Studio, which is used only for development, OpenEdge Explorer is also supported in production
environments. Since OpenEdge Explorer is browser based it can be accessed locally or via an
internet connection. This explains the need to update the security credentials in Developer
Studio whenever they are changed for OpenEdge Explorer.

1. To change the password, go to the Developer Studio workbench preferences by


selecting Window → Preferences. Then select Progress OpenEdge →
Server → OpenEdge Explorer Connections.

2. Select Explorer 1, and then click Edit.

3. Update the Password field to the current password.

4. Click Test Connection to confirm the connection.

5. Click OK to close the confirmation dialog.

6. Click Finish to save the change.

7. Click OK to close the workbench preferences.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 29 of 101


© 2017 Progress Software Corporation. All rights reserved.
Starting an OpenEdge Database Server

In this section OpenEdge Explorer is opened. This time OpenEdge Explorer is


opened in the default Web browser for your Windows system, instead of in the
Web browser in Developer Studio.

1. Open OpenEdge Explorer by selecting Start → All Programs → Progress →


OpenEdge → OpenEdge Explorer. OpenEdge Explorer opens in the default
browser for the Windows system.

2. From the OpenEdge Explorer Menu select Resources → Database.

This opens the Database Migration Utility. The database is being ‘migrated’
to allow OpenEdge Explorer to automatically start the database.

3. Type the following Database information for the sport database that was
created earlier in the tutorial.
a. Database Display Name: sport

b. Database Path and Filename: C:\OpenEdge\WRK\db\sport

c. Database Port: 5678

Tip: Any unused port can be specified for Database Port. If you use a different
port than the one specified then make sure to use that port throughout this and other
OEDK tutorials when configuring connections to the database.

d. Check the box for Autostart Database Broker:

OpenEdge Developers Kit: Getting Started with OpenEdge Page 30 of 101


© 2017 Progress Software Corporation. All rights reserved.
Keep the other defaults. For example:

Note: Developer Studio makes extensive use of the SQL connection. Some features in
Developer Studio will not work if ‘Both 4GL and SQL’ is not selected for Database
Broker Type. This option is selected by default.

4. Click Submit. The resource page for database sport is displayed:

Tip: In the screenshot above, in the upper-left, the breadcrumbs display


Resources/Local/sport. Breadcrumbs let you know where you are in OpenEdge Explorer and
can be used to navigate to a higher level page. For example clicking Resources displays the
Resources page for all resources.

The database C:\OpenEdge\WRK\db\sport is now a Managed Database.


OpenEdge Explorer can be used to manage the database including starting and
stopping the database server.

5. After a short time click F5 or the Refresh button to refresh the page.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 31 of 101


© 2017 Progress Software Corporation. All rights reserved.
You will see that the database server has started. This is the case because
Autostart Database Broker was checked when the database was configured.
When Windows is shutdown and is restarted, the database broker will be
automatically started for this database after the AdminServer service is started.

Tip: When using OpenEdge Explorer the status Polling is not available, so the status for
resources is always Not Polled. OpenEdge Explorer is a subset of OpenEdge Management.
OpenEdge Management provides a number of advanced features including polling, automated
notifications, monitoring the availability or resources and performance of resources.

6. To view a resource using OpenEdge Explorer, from the menu bar select
Resources → Go to Resources.
This shows all resources.

7. To find the sport database, in the Type box, select Database from the
dropdown, or type a ‘D’ and select Database.

8. Click on the line with the sport database, but not on the link. The Resource
Summary appears:

The database can be stopped or started directly from here by selecting the Start
and Stop buttons shown on the right.

Clicking the link opens the resource page for the sport database.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 32 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 03: Connecting a database to a project
Overview
The OpenEdge RDBMS (Relational Database Management System) is an integral
part of most OpenEdge applications. In this lab you’ll work with the sport
database, as you start to learn about OpenEdge Databases. The sport database was
defined in the workspace in Lab 2. Once a database is defined in the workspace it
can be associated with one or more projects. Associating a database with a project
is necessary to enable code in that project to access data in the database.

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database

Add a database connection to the workspace

In this section you will define a connection to the sport database for the workspace.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. Open the workbench preferences by selecting Window → Preferences from


the workbench menu bar, as shown below left.

3. From the preferences select Progress OpenEdge → Database Connections,


as shown above right.

4. Click New to add a new OpenEdge Database connection.


The Add OpenEdge Database Connection wizard is displayed.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 33 of 101


© 2017 Progress Software Corporation. All rights reserved.
5. Enter the following information to add a connection to the database server for
the sport database.
a. Connection name: sport
b. Physical name: C:\OpenEdge\WRK\sport.db
c. Host name: localhost
d. Service/Port: 5678
The host and port are the same ones that were used to configure the database
server. These values must match.

6. Click Test Connection, to test the ABL client connection to the database.

If you don’t see the dialog with ‘Connection succeeded’ then go back and
confirm the configuration. For example make sure that the physical name of
the database, the host name, and port number match the configuration for the
database in OpenEdge Explorer. Also confirm that the database server is
running in OpenEdge Explorer.

7. Click OK to close the OpenEdge Database Connection dialog box.

8. Click Next to go to the next page of the wizard.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 34 of 101


© 2017 Progress Software Corporation. All rights reserved.
Keep the defaults to Define a SQL Connection, and to Add a new SQL
connection. Although we will not be coding in SQL in this tutorial, we will be
using tools that make use of SQL.

9. Click Next to define a SQL connection.

Keep the defaults. The User ID will automatically be filled in with your User
ID.

10. Click Test Connection to confirm the SQL client connection to the database.
If the connection fails then review the parameters.

11. Click OK to close the Test connection dialog.

12. Click Next to continue to the last page of the wizard.

13. Confirm that Auto-start database server is not checked.


This is not needed since a database server has already been started using
OpenEdge Explorer.

14. Click Finish.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 35 of 101


© 2017 Progress Software Corporation. All rights reserved.
The database is shown in the list of connections. If you need to make any
changes then select the database and click Edit.

15. Click OK to close the workbench preferences.

Associating a database connection with a project

Now that the database connection is defined for the workspace it can be associated
with project within that workspace.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. In Project Explorer, right-click on myProj, and select Properties from the


context menu.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 36 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. With the properties for the project open, select Progress OpenEdge →
Database Connections.

4. Check the sport Connection Name.

5. Click OK. A message in the Console view shows that the database connection
is available for this project.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 37 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 04: A look at the OpenEdge RDBMS
Overview
Prior to this lab we’ve been accessing an OpenEdge database, but information
hasn’t been provided on how to view the database. In this lab you’ll learn more
about the OpenEdge RDBMS (Relational Database Management System) by
looking at the sport database using the DB Navigator perspective.

Information: Information on the OpenEdge RDBMS can be found in the OpenEdge


manuals: Getting Started: Database Essentials, and Data Management: Database Administration.

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database
 Lab 03: Connecting a Database to a Project

Start a SQL connection to the sport database

The DB Navigator perspective uses OpenEdge SQL to interact with databases. In


this section a SQL connection is made to the OpenEdge RDBMS.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. From the workbench menu bar select Window → Open Perspective → DB


Navigator, to open the DB Navigator perspective.

3. Using the Connections view (located in the lower-left), select sport under
Connection Profiles.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 38 of 101


© 2017 Progress Software Corporation. All rights reserved.
Note: If Active Connections also displays sport then the database is already connected and
the next step can be skipped.

4. Double-click sport to create a SQL connection to the sport database. The


sport connection is shown under Active connections.

Note: The OpenEdge RDBMS supports connections from both ABL clients and SQL
clients. This tutorial does not cover accessing the OpenEdge RDBMS using SQL. However,
the DB Navigator does use SQL so this connection needs to be started.

Tip: If the database does not connect then stop and restart the database using OpenEdge
Explorer. Since DB Navigator uses SQL to access the database instead of ABL, it may be that
SQL is not active for the connection.

View the database schema using the DB Structure view

In this section you’ll review the database schema by working with the DB
Structure view. Database schema is Meta information that is defined in the
database to specify how the data in the database is organized.

1. Select the DB Structure view (located in the upper-right). There is a tab for
the connected sport database.

Tip: The database displayed in the DB Structure view is the one that is currently selected
in the Connection view. In this case there is only one database connection available.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 39 of 101


© 2017 Progress Software Corporation. All rights reserved.
2. Expand the Database node, the SPORT node and the TABLE node.

From the TABLE node you can see that there are 25 tables defined in the
database.

3. Expand the Customer node and the Indexes node.

As shown below-left, from the Indexes node you can see that there are 5
indexes defined.

4. Expand each Index node, as shown in the screenshot above-right. The fields
that are used to define each index are displayed. The (A) indicates that the
index component is ascending.

5. Under the Customers node, expand the Columns node.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 40 of 101


© 2017 Progress Software Corporation. All rights reserved.
The 18 after Columns lets us know that there are 18 columns defined on the
table. You can see at a glance what data type is defined for each field and the
default format that is used to display the field.

Other types of information provided by the DB Structure view include


information on: database details, meta-schema, database triggers, views,
and sequences.

View database details using the DB Details view

The DB Details view provides additional details based on the selected node in the
DB Structure view.

1. Using the DB Structure view, select the Customer table.

2. Select the DB Details view. In this example the OpenEdge Table tab is
selected. It displays table properties.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 41 of 101


© 2017 Progress Software Corporation. All rights reserved.
The tabs in the DB Details view can be selected to see different types of
information regarding the selected table. Some of the tabs have similar names,
such as Columns and OpenEdge Columns. The first one provides SQL
information, while the second contains ABL information. In this section
you’ll review some of the information provided by this view.

3. Select on the OpenEdge Columns tab.

The tab shows information on the schema definition for each field (column)
that is defined for the table including Name, Data Type, Format, Label,
Column Label, Initial Value, Description, Order, Decimals, Extent, Help,
Mandatory, Case-sensitive, and Validation.

4. Select the OpenEdge Indexes tab.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 42 of 101


© 2017 Progress Software Corporation. All rights reserved.
This tab shows information on the index and the fields that are included in each
index.

Note that for the CustNum index, the Primary column has a value of Yes.
There can be only one index per table that has this value set to Yes. This
means when a query is run the default sorting will be based on this index.

You can code your ABL queries in a way that changes which index is selected.
For example if there is a WHERE clause that uses field Country, the AVM
(compiler) selects the CountryPost index to optimize record access and to
display fields in the order specified in that index.

5. Select the Row Count tab. The number of records that are currently in the
table is displayed. In this case the Customer table contains 1117 records.

6. Select the Preview tab in the DB Details view. Data for every column in the
database is displayed for the first 80 rows.

Tip: The number of rows displayed can be modified by going to the DB Navigator
properties and changing the Preview row limit. To modify this property, or any other DB
Navigator property open the workbench preferences Window → Preferences, and then go to
Progress Databases → DB Navigator.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 43 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tip: From the above tip, you may have noticed that there are several properties for setting
SQL values in DB Navigator properties. The DB Navigator perspective includes a SQL editor.
Here’s an example of how to create and run a SQL program that accesses the sport database.

1. Confirm that the sport database is connected in the Connections view.

2. Click the button in the Connections view to create a SQL file.

3. Select the sport database and the SPORT schema in the SQL editor.

4. Enter this SQL code to display data from the Customer, Order, and OrderLine tables:
SELECT Customer.Name, Order.OrderNum, SUM(ExtendedPrice)
FROM PUB.Customer, PUB.Order, PUB.OrderLine
WHERE Customer.CustNum = Order.CustNum
AND Order.Ordernum = OrderLine.Ordernum
GROUP BY Customer.Name, Order.Ordernum;

5. Click the button in the SQL editor to run the program. The SQL Results view shows
the returned records. Data displays the customer name from the Customer table, the order
numbers from the Order table, and a calculated summary for the extended price columns for all
of the OrderLine records associated with the order.

6. Enter Ctrl + S to save the program. The Save As dialog is displayed.

7. Select myProj, and right-click to display the context menu.

8. From the context menu select New → Folder and create a folder named SQL.

9. Select myProj → SQL folder, enter File name mySelect.sql, and click OK. The program is
saved in the SQL folder.

10. Click on the tab to close the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 44 of 101


© 2017 Progress Software Corporation. All rights reserved.
Information: Information on OpenEdge SQL can be found in the OpenEdge manuals:
Data Management: SQL Development and Data Management: SQL Reference.

7. Select any table in the DB Structure view, and then, using the DB Details
view, click on the Add Table button (located in the upper left of the DB
Details view).

The Add Table dialog is displayed:

This is included in the lab to point out that you can use the features in DB
Navigator to modify the database schema. You can add, edit and delete
schema including tables, indexes, columns, sequences, triggers, and other parts
of the database.

8. Click Cancel to close the Add Table dialog.

9. Close the DB Navigator perspective.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 45 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 05: Working in the OpenEdge Editor
Overview
The OpenEdge Editor is a part of Developer Studio and includes many features that
can increase your productivity. Some of these are introduced in this lab.

You’ll be introduced to ABL, which stands for Advanced Business Language.


OpenEdge ABL is a very powerful language that allows you to perform complex
tasks with a minimal amount of code.

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database
 Lab 03: Connecting a Database to a Project
 Lab 04: A Look at the OpenEdge RDBMS

Create an ABL procedure

In this section a folder (directory) is added to the project. Then a new ABL
procedure is created in the folder. Code is added to the program and run,
displaying data from the database.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. In Project Explorer, right-click on project myProj and select New → Folder


from the context menu.

3. In the New Folder dialog, for Folder name enter programs, and then click
Finish.
The programs folder is created in project myProj. The programs folder will be
used to hold ABL programs.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 46 of 101


© 2017 Progress Software Corporation. All rights reserved.
4. Right-click on the programs folder, and select New → ABL Procedure.

Tip: To create a new resource, such as an ABL Procedure, it’s placed in the selected
project or folder. If it was created in the wrong location you can move it to the desired location
by selecting it with the left mouse button and then dragging to the desired location.

5. In the New ABL Procedure dialog:


a. For File name enter displayCustomer.p.
b. Uncheck the box for Error-handling statement.

6. Click Finish to create the procedure file.


This creates the ABL program displayCustomer.p.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 47 of 101


© 2017 Progress Software Corporation. All rights reserved.
As can be seen in the Project Explorer view, the displayCustomer program is
in the programs folder of the project.

The program was automatically opened in the OpenEdge Editor, which is


located in the upper-right area of the workbench. The tab in the OpenEdge
Editor includes the name of the program.

The Console view includes a message showing that the new program was
automatically compiled.

Note: The .p file extension is used for an ABL procedure file. The .r file extension is used
for a compiled ABL programs and ABL class. By default files with the .r extension are not
displayed in the Project Explorer view, since developers do not work directly with these types of
files.

Comments start with ‘/*’ and end with ‘*/’, as shown above. Single line
comments are also supported by specifying ‘//’ at the start of a line. When the
procedure was generated it created a block comment at the top that includes the
name of the program and the time when it was created. You can add and
modify the text in the comments.

Write an ABL program to display data from the database

1. For learning purposes, delete the generated comments from the file and replace
them with the one comment lines below.
/* File : displayCustomer.p
Purpose: ABL example read and display data
from an OpenEdge database */

The ‘*’ that is in the tab name prior to displayCustomer.p ( )


indicates that the file has been modified.

2. Move the cursor into the OpenEdge Editor area and right-click. This displays
the context menu for the editor.

3. Select Save from the context menu to save the program.


After saving the program the ‘*’ is removed from the tab name. There is also a
new message in the Console view showing that the program was compiled on
save.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 48 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tip: The tutorial is presenting one way to accomplish each a task. There are often multiple
ways to accomplish these tasks. As an example a file can also be saved with the key
combination Ctrl + S, or by clicking the save button that is located on the workbench
toolbar when using the OpenEdge Editor perspective. The save button is only enabled when
there are changes that have not been saved.

4. Type or copy the following code into the displayCustomer.p after the
comment.
find first customer.
display customer.name.

The editor will look similar to this:

As shown above, the editor uses color coding to assist the developer in
quickly identifying the types of text that are in the editor.
For example text for:
* Green: is used for comments.
* Purple: is used for ABL reserved key words.
* Orange: is used for database resources.

ABL finds the first customer record in the sport database, and then displays the
value of the name field.

Note: The yellow triangle with the explanation point is a warning you that keywords are
not uppercased, which is the default is setting for the editor. This can be ignored. You’ll see how
to remove this warning later in the tutorial.

5. Save the program by selecting Ctrl + S.

Note: In the next step the program will be run. The editor runs the last saved version of the
program, not using any changes that have not been saved. If you run a program that has pending
changes a message box is displayed that provides the option to save the changes before running
the program. Select Yes to save and run, No to run without changes, or Cancel to not run the
program.

6. Run the program by selecting Run → Run As from the workbench menu bar,
or select Ctrl + F11. The program that is currently selected in the editor is run.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 49 of 101


© 2017 Progress Software Corporation. All rights reserved.
A Progress window opens to display the output of the program. In this case
the display shows the name of the field, which is Name, and the value for that
field, which is the customer name Lift Tours.

When the program was run it located the first customer record in the sport
database and then displayed the selected field from that record.

7. With the Progress window selected, Press the space bar to close the window.

Changing an OpenEdge Editor Preferences

How the OpenEdge Editor functions can be modified by setting properties in the
workbench preferences. It is common to keep most of the default settings. In this
lab well take a look at changing a few of the preferences.

1. In the OpenEdge Editor, for file displayCustomer.p, hover over the warning
in the marker bar. Text for the warning is displayed. In this case the
default editor setting expects ABL keywords to be in upper case.

Tip: The area that runs down the left side of the editor is known as the marker bar. The
area that runs down the right side of the editor is known as the overview ruler. Hovering over
indicators in either one of these can display information about a displayed indicator.
Some of the items that can be displayed in the marker bar are line numbers, lines that match a
search, debug breakpoints, and quick diff indicators.
Some of the items that are displayed in the overview ruler are warning, error, and search
indicators. The overview ruler spans the entire document, not just what is currently displayed in
the editor. You can select an indicator in the overview ruler to navigate to that part of the
program. Below is a list showing a number of the symbols used for the indicators (annotations):

OpenEdge Developers Kit: Getting Started with OpenEdge Page 50 of 101


© 2017 Progress Software Corporation. All rights reserved.
2. Open the workbench preferences (Window → Preferences) and then select
Progress OpenEdge → Editor.

The top-level Editor preferences are shown on the right. How a developer
chooses to set the editor to display and function on text is a personal choice.
For the tutorial a few preferences are modified to aid in the presentation. The
next steps take you through these changes.

3. Change these Editor settings


c. Check on Expand keywords
d. Check on Apply keyword(s) casing on save.
Since Case is set to Upper, all keywords will be changed to upper case
when the program is saved in the editor. This removes the warning
message. However, it’s not the only way to remove that message. For
example you could change Case to No action.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 51 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tip: You can reset the Editor preferences back to the original settings by
selecting the Restore Defaults button that is available at the bottom of the Editor
Preference page.

4. Click Apply to save the changes, and then click OK to close the preferences.

The warning for xxx is still displayed. One way to remove this error is to save
the program. Currently the save option is disabled, since there aren’t any
changes pending.

5. Add a space in the comment area and then click Ctrl + S to save the program.
The keywords are changed to upper-case on save and the warning message is
removed.

6. Close displayCustomer.p in the editor by clicking on in the tab.

Create an ABL program to display multiple records

In this section you will use ABL code to read multiple records from an OpenEdge
database using a FOR EACH loop.

1. Create a copy of program displayCustomer.p. Right-click on the


displayCustomer.p program and select Copy.

2. Right-click on the programs folder and select Paste from the context menu.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 52 of 101


© 2017 Progress Software Corporation. All rights reserved.
The dialog Name Conflict is displayed.

3. Change the name to displayCustomer2.p (adding a ‘2’ to the end), and then
click OK.

4. Open displayCustomer2.p in the OpenEdge Editor by double-clicking on the


ABL program in Project Explorer.

5. Replace the code in the file with these lines of code:

/* File : displayCustomer2.p
Purpose: ABL example of a FOR EACH loop */
for each customer:
display customer.name customer.contact customer.country.

6. Save the program (Ctrl + S).

Your file looks similar to the following:

The FOR EACH reads each record in the database customer table and then
displays the name, contact, and country for each customer.

7. Run the program (Ctrl + F11).


The first set of customer records are displayed, showing values for the three
selected fields in the customer database table.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 53 of 101


© 2017 Progress Software Corporation. All rights reserved.
8. Press the space bar. The next set of customer records is displayed.
This is really amazing since ABL is:
e. Using defaults to retrieve records based on the table’s primary index.
f. Taking care of the looping.
g. Using default formats to display data
h. Avoiding record contention by reading records without locking the
records.

9. To exit the display, with the Progress window selected, click Esc, and then
press the space bar.
This terminates the program so that you don’t need to display each customer
record in the database.

10. Click on the in the tab for displayCustomer2.p to close the program.

Create another ABL program

In this section you will work with an ABL program that has an error in order to
learn about some of the ways to find out information when an error occurs.

1. Create a copy of program displayCustomer2.p. Right-click on the


displayCustomer2.p program and select Copy.

2. Right-click on the programs folder, select Paste from the context menu,
change the name to displayCustomer3.p, and click OK. Program
displayCustomer3.p is displayed in the programs folder.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 54 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. Double-click displayCustomer3.p to open the program in the OpenEdge
Editor.

4. Replace the code in the file with these lines of code:

/* File : displayCustomer3.p
Purpose: Look at an error in an ABL program */
find next customer.
display customer.

5. Save the program (Ctrl + S).


There was an error detected in this program when it was saved.

6. Select the Problems view.

The Problems view lists all of the errors and warnings for all of the programs
in the project. Your display may look a little different from the one shown
below. There are also options that allow the display to be customized.

Looking at errors using Developer Studio:


1. Project Explorer, error indicator on the folder holding the program.

2. Project Explorer, error indicator on the name of the program.

3. OpenEdge Editor, error indicator on the tab for the program.

4. OpenEdge Editor, error indicators on the lines where the error was
detected.

5. OpenEdge Editor, select top error marker for a total number of errors
detected in the program.

6. OpenEdge Editor, in the overview ruler an error indicator on each


line with an error relative to the overall file.
(Not a great example of this since there only three lines of code.)

OpenEdge Developers Kit: Getting Started with OpenEdge Page 55 of 101


© 2017 Progress Software Corporation. All rights reserved.
7. Problems view selected.

8. Problems view, a count of the total number of errors detected. The


count can be for multiple programs.

9. Problems view, a list of each detected error.

Tip: There is much more support provided by Developer Studio for resolving coding
problems and bugs. For example there is a separate perspective that is dedicated to debugging
(Debug perspective).

Information: Information on Debugging can be found in the OpenEdge manual:


Development Tools: Debugging and Troubleshooting.

Resolving the error

1. Hover over the error Description in the Problems view that is on line 3.

The description of the error becomes visible, as shown above.


The error description indicates that the display request cannot fit in the frame
that will display the output.

2. Double-click the error message to position to the line with the error on line 3 in
program displayCustomer3.p. The selected line is high-lighted as shown
below.

In this very simple program we can see that this is line 3. However, in a larger
program line numbers will help.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 56 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. Right-click in the marker bar and checking Show Line Numbers.

The line numbers are displayed next to the marker bar.

Why is there an error?


i. We know from the error message that the error is caused by the
inability to display a field in the Customer table.

j. Programs displayCustomer.p and displayCustomer2.p didn’t have


an error since the DISPLAY statement specified specific fields to be
displayed.

k. In displayCustomer3.p an attempt is made to display all fields. One


of the fields Customer exceeds the maximum size.

l. In an earlier lab you reviewed the OpenEdge Column definitions.


Column with the largest format is Comments. It has a format of 80
characters, which will not fit in the display frame.

4. Modify the DISPLAY line by adding ‘except comments’, which omits


Comments field from the fields to be displayed and save the program (Ctrl +
S).

DISPLAY Customer EXCEPT comments.

After the modification the code looks like this:

The error is resolved. All of the error indicators, including those in the marker
bar and in the Problems view are removed.

Tip: ABL provides ways to display fields that have a long format. For example an
alternative way to resolve this error would be to set the maximum amount of data to be
displayed. The error occurs because the data exceeds the default maximum display size of 80.
Entering the following line of code at the end of the program allows the data in the Comments
field to be displayed.
DISPLAY Customer.Comments FORMAT "x(50)".

OpenEdge Developers Kit: Getting Started with OpenEdge Page 57 of 101


© 2017 Progress Software Corporation. All rights reserved.
5. Run the program. The data for all of the fields in the selected Customer record
are displayed, except for the Comments field.

6. Press the space bar to close the program.

7. Close displayCustomer3.p in the editor by clicking on in the tab.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 58 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 06: A look at ABL
Overview
This lab focuses on how easy it is to access and work with data from an OpenEdge
database using ABL. ABL is a language that is optimized for business
applications. Using ABL you can read, update, and manipulate data with very few
lines of code relative to other languages. ABL runs in an AVM (ABL Virtual
Machine). An AVM is included with Developer Studio.

The lab only touches the surface of ABL, showing some of the power provided by
the language. More in-depth information on ABL is provided in the free courses
that are included with OpenEdge Developer Kit. Please see section OpenEdge
Courses Included with the Classroom Edition of OpenEdge Developers Kit in this
document for information on how to access these courses.

Information: Find more information on ABL in these manuals:


 ABL: ABL Essentials
 ABL: ABL Reference

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database
 Lab 03: Connecting a Database to a Project
 Lab 04: A Look at the OpenEdge RDBMS
 Lab 05: Working in the OpenEdge Editor

Creating a folder to hold ABL programs

A new folder is created to hold the ABL programs that you’ll be working with in
this section.

1. In Developer Studio, open the workspace wsOEDK, if it isn’t already open.

2. Select project myProj and right-click to select New → Folder.

3. In the New Folder dialog, set Folder name to ABL, and click Finish.
This new folder will be used to hold ABL programs.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 59 of 101


© 2017 Progress Software Corporation. All rights reserved.
Note: Project myProj already has a connection to the sport OpenEdge database. You’ll be
accessing this database connection in the ABL programs in this lab.

Using the DO loop, LEAVE statement, and MESSAGE statement

Earlier in the tutorial you entered a program that used a ‘FOR EACH loop’ to
display customers. Here’s another example of an ABL loop, a ‘DO loop’. The
program is controlled programmatically using a variable. The result is displayed in
message box.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter 01_DO-Loop.p, and
click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 01_DO_Loop.p
Purpose: ABL example of a DO loop */
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DO iCounter = 0 TO 20 BY 5:
MESSAGE "Current count:" iCounter VIEW-AS ALERT-BOX.
IF iCounter EQ 10 THEN
LEAVE.
END.

The message box will be displayed each time the ‘DO loop’ is executed.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

5. Click OK as each message box is displayed.

The DO loop ends when iCounter is 10. As expected, the program finishes
after displaying ‘Current count: 10’.

6. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 60 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using FIRST and LAST when finding a record

This program has two queries. It finds the FIRST and LAST values in a table
based on the selected index for the table. The index is automatically selected by
the database based on the query. In this case, for the ‘FIND FIRST’ query the
primary key DeptCode on table Department is used. For the ‘FIND LAST’
query the non-primary index DeptCode on table Employee is selected by the
database since the query uses that field in the WHERE clause.

Tip: A database table can have many indexes defined. Indexes are used to sort the records
based one or more fields in the table. Records returned by a query are ordered based on the selected
index. The database engine selects an index based on the information provided in the query, for
example the field(s) referenced in a WHERE clause. In cases where it isn’t clear which index to
select the primary index is selected.

The below screenshot shows the 3 indexes defined on the Employee table, as seen in the DB Details
view of the DB Navigator perspective, with the OpenEdge Indexes tab selected. The EmpNo
index is defined on one field, EmpNum. As seen in the 4th column this index is the primary index for
this table. The index sort order for the index is ascending (Asc).

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter 02_First_Last.p, and
click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 02_First_Last.p
Purpose: ABL example FIND using LAST and FIRST */
FIND LAST Department.
DISPLAY DeptName DeptCode SKIP '-----------------'.

FIND FIRST Employee


WHERE Employee.DeptCode EQ Department.DeptCode.
DISPLAY Employee WITH 1 COLUMN.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

OpenEdge Developers Kit: Getting Started with OpenEdge Page 61 of 101


© 2017 Progress Software Corporation. All rights reserved.
In first query finds the LAST department. The column used for last depends
on the selected index. In this case the primary index is selected, which is on
DeptCode. The query returns Dept finance and DeptCode 700.

The SKIP statement skips to the next line and displays dashes, separating the
returned by the next query.

The second query returns employee number 36 and includes the expected
DeptCode of 700.

As shown below is a Preview of the data in the Department table, using the
DB Navigator perspective and DB Details view. All of the records in the
Department table are displayed, showing that the largest value in the
DeptCode field is 700.

5. Press the space bar to close the Progress window.

6. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 62 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using FOR loops to access database records

This program has two ‘FOR loop’ queries, each one showing different options for
selecting records.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter 03_FOR_Loop.p, and
click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:


/* File : 03_FOR_Loop.p
Purpose: ABL example using a FOR EACH loop and WHERE */
FOR EACH Customer WHERE Balance >= 40000:
DISPLAY Name Balance.
END.

FOR EACH Customer WHERE Customer.CustNum LT 4:


DISPLAY CustNum Customer.Name FORMAT "x(15)"
Customer.Comments FORMAT "x(20)".
END.

The first ‘FOR loop’ returns records from the Customer table for each
customer that has a balance greater than or equal to 4000. The query returns
the name and balance for all customers that have a balance exceeding 40,000.

The second ‘FOR loop’ returns all customer records where the customer
number (CustNum) is less than 4. The DISPLAY outputs three fields. Two
uses the FORMAT qualifier to set how many characters of each field will
display.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

As seen above, the first ‘FOR loop’ shows records for each customer where
there balance exceeds $40,000 .

OpenEdge Developers Kit: Getting Started with OpenEdge Page 63 of 101


© 2017 Progress Software Corporation. All rights reserved.
Unlike the previous queries, there isn’t an index that orders the records based
on the query. As can be seen in the screenshot below, there isn’t an index on
that includes the Balance field. While it would be more efficient to define an
index on this field if it is a commonly used query (since it would avoid return
the records in the requested order), the database handles the query by accessing
the records using the CustNum index, the primary index , to return the
requested records.

5. Press the spacebar to see the results from the second query.

The second ‘FOR loop’ shows records from the customer table where the
customer number is less than 4 . The database selects the CustNum index
on the database, which is defined on the CustNum field to efficiently return the
records.

6. Press the space bar to close the Progress window.

7. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 64 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using MATCHES

The MATCHES statement is used in this query to select records that match a
character string. It isn’t possible to create a database index to handle MATCHES.
However, this type of query is valuable since you can search on any character
string in any CHARACTER field defined in the database. Wild card characters are
supported including ‘.’ for a particular character and ‘*’ to match any group of
characters.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter 04_Matches.p, and
click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 04_Matches.p
Purpose: Example using ABL MATCHES */
FOR EACH supplier WHERE Supplier.Name MATCHES "*Sports*":
DISPLAY Name.
END.

DEFINE VARIABLE cString AS CHARACTER INITIAL ".324*" NO-UNDO.


FOR EACH Customer NO-LOCK
WHERE Customer.Address MATCHES(".324*"):
//WHERE Customer.Address MATCHES(cString):
//WHERE Customer.Address MATCHES("3.24*"):
DISPLAY Customer.Name FORMAT "x(15)"
Customer.Address FORMAT "x(15)"
Customer.City FORMAT "x(10)"
Customer.State FORMAT "x(4)"
Customer.Country FORMAT "x(15)".
END.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

The first query uses MATCHES on the Name field of the Supplier table. It
returns where the Name field includes the string ‘Sports’ anywhere in the
name, thanks to the ‘*’ wild card.

5. Press the spacebar to see the results from the second query.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 65 of 101


© 2017 Progress Software Corporation. All rights reserved.
The second query uses MATCHES on the Address field of the Customer
table. In this example we don’t know the first digit for the address, but we
know that the next three digits are 324. The wild card for one character is used
prior to 324, followed by an asterisk to match any other characters (".324*").
The records were identified that matched the selection.

6. There are two variations included for the second query. You can try these out
by commenting the existing WHERE clause (by removing //), and un-
commenting one of the other WHERE clauses. Only one WHERE clause can
be uncommented.
a. Variation one shows how a defined variable, cString, can be used to
provide the value for the MATCHES statement. This is closer to a real
world example since it is likely that the value would be input in a
program and saved in a variable, as opposed to hard coding it in a
query. The output for this example is unchanged.

b. Variation two shows an example of finding string ("3.24*"). While


this is similar to the other string, it shows how to search for a string
where the second character is unknown, while the first, third, and
fourth are know.

7. Press the space bar to close the Progress window.

8. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 66 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using a Word Index

This example shows how to use a word index. A word index is similar to
MATCHES, since both support finding records in a character field based on a
string. However, a word index accesses the database using an index that is
designed for search on a word or the beginning of a word, rather than on any
character string. This makes the search more efficient.

Tip: A word index supports searching on multiple words for a given field. The ampersand (&)
represents a logical AND; the vertical line (|), exclamation point (!), or caret (^) represent a logical
OR. An asterisk (*) as a wildcard that can be used only at the end of a word.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter to 05_Word_Index.p,
and click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 05_Word_Index.p
Purpose: ABL example using a word index */
DEFINE VARIABLE cString AS CHARACTER INITIAL "Pearl Izumi" NO-UNDO.
//DEFINE VARIABLE cString AS CHARACTER INITIAL "NotHere" NO-UNDO.
//DEFINE VAR cString AS CHAR INIT "footballs | helmets" NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER INITIAL 0 NO-UNDO.

FOR EACH RefCall WHERE RefCall.Txt CONTAINS cString:


iCount = iCount + 1.
FIND Customer WHERE Customer.CustNum EQ RefCall.CustNum.
DISPLAY Customer.Name
RefCall.Txt LABEL "Reference Comment".
END.

IF iCount EQ 0 THEN
MESSAGE "No records match string value: '"
cString "'." VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Found " iCount " record(s) that matches string: '"
cString "'." VIEW-AS ALERT-BOX.

The RefCall table holds information about a sale. The Txt field is used to
hold notes that refer to a sale. A word index has been created on the Txt field.
In the code, the ABL CONTAINS clause is used to search a word index.

There are three DEFINE VARIABLE statements for cString, two of which are
commented out. You can uncomment the commented strings to see the
behavior when multiple records are found, or when no records are found, just
make sure that only one ‘DEFINE statement’ is uncommented for cString.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

OpenEdge Developers Kit: Getting Started with OpenEdge Page 67 of 101


© 2017 Progress Software Corporation. All rights reserved.
This query makes use of a word index that is defined on the RefCall table on
the Txt field, as can be seen below in the DB Details view, using the DB
Navigator perspective. Note the ‘Yes’ in the Word Index column .

5. Select OK in the message box, and Press the space bar to close the Progress
window.

6. Comment the first DEFINE statement and uncomment the second DEFINE
statement that contains "NotHere", and then run the program.
No values in the word index match the string, so no records are returned.
However, you still see the message box.

7. Select OK to close the message box.

8. Comment the second DEFINE statement and uncomment the third DEFINE
statement that contains "footballs | helmets", and then run the program.

This query provides an example of looking for multiple words. In this case if
the Reference Comment contains either footballs or helmets then the record is
returned. There are three records returned.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 68 of 101


© 2017 Progress Software Corporation. All rights reserved.
Tip: You may wonder why the display of the Reference Comment field is formatted as
an editor. This is because the formatting for that field is defined in the database schema
information in the RefCall table for that field, as seen in the View-AS column , by adding
VIEW-AS EDITOR … .

As with many areas in OpenEdge, if you wanted to change the code to display in the standard
way you could override the VIEW-AS EDITOR by adding VIEW-AS TEXT to the DISPLAY
command for that field.

9. Select OK in the message box, and Press the space bar to close the Progress
window.

10. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 69 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 07: Modifying database records with ABL

Overview
Using ABL you can read, update, and manipulate data with very few lines of code
relative to other languages. In this lab you’ll create, update, and delete records in
the database.

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database
 Lab 03: Connecting a Database to a Project
 Lab 04: A Look at the OpenEdge RDBMS
 Lab 05: Working in the OpenEdge Editor
 Lab 06: A look at ABL

Creating a new record in the database

This section shows how to create a new record in the database.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter to


06_Create_Record.p, and click Finish to create the procedure file. The file is
opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 06_Create_Record.p
Purpose: ABL example of creating a database record */
DEFINE VARIABLE iOrderLine AS INTEGER NO-UNDO.

FIND LAST Order.

/* Determine next OrderLine number for the selected Order */


FIND LAST Orderline
WHERE OrderLine.Ordernum EQ Order.Ordernum NO-ERROR.
/* Set iOrderline one higher than the last Orderline record. */
IF AVAILABLE OrderLine THEN
ASSIGN iOrderLine = Orderline.LineNum + 1.
/* There are no OrderLines for the selected Order */
IF NOT AVAILABLE OrderLine THEN
ASSIGN iOrderLine = 1.

/* Create a new OrderLine for the selected Order


and assign values */
CREATE Orderline.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 70 of 101


© 2017 Progress Software Corporation. All rights reserved.
ASSIGN Orderline.LineNum = iOrderline
Orderline.OrderNum = Order.OrderNum
Orderline.ItemNum = 7
Orderline.Price = 1.20
Orderline.Qty = 6.

DISPLAY Orderline WITH 1 COLUMN.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

The new record is created, assigning 5 values. Let’s walk through the code.

a. The last Order record is found. This is based on the Ordernum field.
The Ordernum index is selected since it is the primary index on the
table. As shown here the last Order Num is 6150 .

b. The FIND statement looks for the last OrderLine record for Order
6150. If it’s found it sets the variable iOrderLine to one greater than
the Linenum for the OrderLine. This makes the value for Linenum
unique, relative to the other records. If it is not unique then the ‘create’
will fail since there is a unique index orderline defined. The two
fields that define the orderline index , Ordernum and Linenum,
must be unique relative to all other records in the OrderLine table. If
an OrderLine record was not defined for the Order then it is the first
OrderLine and iOrderLine is set to 1.

c. The CREATE statement is used to create a new record. However, the


record is not written to the database until after the ASSIGN statement
executes.

d. The ASSIGN statement defines values for five fields for the new
record.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 71 of 101


© 2017 Progress Software Corporation. All rights reserved.
e. The DISPLAY statement displays the new record. The five values can
be seen. The Line Num is set to iOrderLine as shown in the Progress
window screenshot .

5. Press the space bar to close the Progress window.

6. Close the program in the editor.

Updating a record in the database

This section shows how to update an existing record in the database.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter to


07_Update_Record.p, and click Finish to create the procedure file. The file
is opened in the editor.

3. Replace the contents of the file with the lines below:

/* File : 07_Update_Record.p
Purpose: ABL example of updating a database record */
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.

FIND FIRST Order WHERE Order.Ordernum EQ cOrdNum NO-ERROR.

/* Apply 10% discount to each ordered item for Order 44 */


IF AVAILABLE Order THEN DO:
FOR EACH OrderLine
WHERE OrderLine.Ordernum = Order.Ordernum:
ASSIGN OrderLine.Price = OrderLine.Price * .90.
DISPLAY OrderLine.Ordernum OrderLine.Linenum
OrderLine.Itemnum OrderLine.Price.
END.
END.

This code locates each OrderLine record for the select Order and then
discounts the price for the order line item by 10%.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

OpenEdge Developers Kit: Getting Started with OpenEdge Page 72 of 101


© 2017 Progress Software Corporation. All rights reserved.
Note: The values in the price field may not match what you see in this screenshot. Each
time the program is run it is updating the selected records in the database. Each time the
program is called it reduces the price by 10%.

5. Press the space bar to close the Progress window.

6. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

7. In the New ABL Procedure dialog for File name enter to


07b_Update_Record.p, and click Finish to create the procedure file. The file
is opened in the editor.

8. Replace the contents of the file with the lines below.

/* File : 07b_Update_Record.p
Purpose: ABL example of updating a database record,
including output showing before and after values */
DEFINE VARIABLE beforePrice AS DECIMAL NO-UNDO.
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.

FIND FIRST Order WHERE Order.Ordernum EQ cOrdNum NO-LOCK NO-ERROR.


FIND FIRST Customer WHERE Customer.Custnum EQ Order.Custnum NO-LOCK.
DISPLAY Customer.Name LABEL "Customer Name" Order.Ordernum.

/* Apply 10% discount for each item for the selected Order */
IF AVAILABLE Order THEN DO:
FOR EACH OrderLine
WHERE OrderLine.Ordernum = Order.Ordernum EXCLUSIVE-LOCK:
ASSIGN
beforePrice = OrderLine.Price
OrderLine.Price = OrderLine.Price * .90.
FIND FIRST Item WHERE Item.Itemnum EQ OrderLine.Itemnum NO-
LOCK.
DISPLAY SKIP Item.ItemName FORMAT "x(20)"
beforePrice LABEL " Original Price"
OrderLine.Price LABEL "Discount Price"
WITH 1 COLUMN.
END.
END.

This example does the same thing as the first one but adds some code to show
what is going on in the transaction including the name of the customer, the
name of the item being discounted, and the before and after price for the item.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 73 of 101


© 2017 Progress Software Corporation. All rights reserved.
9. Save the file (Ctrl + S) and run the program (Ctrl + F11).

We can see at the top information from the Order record, displaying the
Customer Name and the Order Num.

For each OrderLine record three values are displayed: the Item name along
with the Original Price and the Discount Price, after applying the 10%
discount.

10. Press the space bar to close the Progress window.

11. Close the program in the editor.

Deleting a record in the database

This section shows how to delete a record in the database.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter to


08_Delete_Record.p, and click Finish to create the procedure file. The file is
opened in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 74 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. Replace the contents of the file with the lines below:

/* File : 08_Delete_Record.p
Purpose: ABL example of deleting a database record */
DEFINE VARIABLE cEmpNum AS INTEGER NO-UNDO.
DEFINE VARIABLE dStartDate AS DATE NO-UNDO.

FIND LAST Vacation EXCLUSIVE-LOCK NO-ERROR.

IF AVAILABLE Vacation THEN DO:


ASSIGN
cEmpNum = Vacation.EmpNum
dStartDate = Vacation.StartDate.
DELETE Vacation.
MESSAGE "Record deleted" VIEW-AS ALERT-BOX.
END.
ELSE DO:
/* For this example this message is displayed
when there are no vacation records */
MESSAGE "Record not found" VIEW-AS ALERT-BOX.
END.

FIND Vacation WHERE Vacation.EmpNum EQ cEmpNum AND


Vacation.StartDate EQ dStartDate NO-ERROR.
IF NOT AVAILABLE Vacation THEN
MESSAGE "Record does not exist." VIEW-AS ALERT-BOX.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

The message appears that the record is has been deleted.

5. Click OK to continue.

An attempt is made to re-read the record from the database. The record is not
found since it has been deleted.

The fields Vacation.EmpNum and Vacation.StartDate are used to look for


the record since these two fields make up the unique index on the table.

6. Click OK to continue.

7. Close the program in the editor.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 75 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 08: Working with ABL queries
Overview
Using ABL you can read, update, and manipulate data with very few lines of code
relative to other languages. In this lab you’ll create, update, and delete records in
the database.

You’ll also learn about ABL queries in this lab.

Prerequisites
Complete the following labs prior to doing this lab:
 Lab 01: Getting started with Progress Developer Studio for OpenEdge
 Lab 02: Starting a Server for an OpenEdge Database
 Lab 03: Connecting a Database to a Project
 Lab 04: A Look at the OpenEdge RDBMS
 Lab 05: Working in the OpenEdge Editor
 Lab 06: A look at ABL

Understanding ABL queries


The coding prior to this section provided examples of using blocks of ABL code to
access data and in some cases the examples iterated through a set of records.
Another way to access data using ABL is by using a query.

Unlike block-oriented statements, such as DO and FOR, queries don’t tie data
access to nested blocks of ABL procedures. An example of where this can be
useful is in event-driven applications. The interface can be written in a way that
provides the user with control on when and which records are read. For example,
with a button that can retrieve the next set of records each time it is selected.
Retrieving the next set of records can be independent of the block code where the
query is defined or opened. This provides flexibility for developers in how they
implement user interfaces and other programmatic events, as they determine the
flow of the application and the processing of data.

Queries provide these characteristics:


 Scope independence – You can refer to the records in the query anywhere in
your procedure.
 Block independence – You are not required to do all of your data access
within a given block.
 Repositioning flexibility independence – You can position to any record in
the result set at any time.

Information: For a more detailed introduction to queries read the chapter on Using Queries in
the ABL: ABL Essentials manual.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 76 of 101


© 2017 Progress Software Corporation. All rights reserved.
Example of an ABL query

In this section you’ll see how to code an ABL static query, which is created using a
DEFINE QUERY statement. In addition to static queries, ABL also supports
dynamic queries. Dynamic queries are coded using the CREATE QUERY
statement.

1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.

2. In the New ABL Procedure dialog for File name enter to 09_Query.p, and
click Finish to create the procedure file. The file is opened in the editor.

3. Replace the contents of the file with the lines below:


/* File : 09_Query.p
Purpose: Example of an ABL static query */
DEFINE QUERY qOrder FOR Customer, Order.
DEFINE VARIABLE iDemoCust AS INTEGER INITIAL 5 NO-UNDO.

OPEN QUERY qOrder FOR EACH Customer,


EACH Order OF Customer
BY Customer.CustNum BY OrderDate.

/* Repeat loop continues until the LEAVE statement is called */


REPEAT:
/* Get the next record from the current cursor position */
GET NEXT qOrder.
/* If the next record was not found then leave the loop */
IF NOT AVAILABLE(Order)
OR Customer.CustNum GT iDemoCust THEN
LEAVE.
/* When the customer is found display information */
IF Customer.CustNum EQ iDemoCust THEN
DISPLAY Customer.CustNum LABEL "Number"
Customer.Name LABEL "Customer" FORMAT "x(12)"
Order.Ordernum LABEL "Order" FORMAT "9999"
Order.Creditcard LABEL "Credit Card".
END.

CLOSE QUERY qOrder.

A walk through the sample code:

a. The DEFINE QUERY statement defines an ABL query.

b. Variable iDemoCust sets the customer number used for comparison.

c. The BY phrase sorts the results, which is useful if there isn’t an index on the
table to sort the records in the desired order.

d. The query can be repositioned and data can be accessed using GET with
FIRST, NEXT, PREV, LAST, and CURRENT. The REPEAT loop
processes records, reading a record each time GET NEXT is called. The GET
statement reads the next record from the current position of the cursor in the

OpenEdge Developers Kit: Getting Started with OpenEdge Page 77 of 101


© 2017 Progress Software Corporation. All rights reserved.
query. When first opened the query is positioned before the first record
returned by the query.

e. There are two IF statements. If an Order record is not available, or it if the


Customer record CustNum value is greater than iDemoCust, LEAVE is
called to stop the loop.

f. After this query is no longer needed CLOSE QUERY is called, which frees
the system resources used by the query.

4. Save the file (Ctrl + S) and run the program (Ctrl + F11).

The display shows data from the selected Customer record and for each Order
record for that Customer.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 78 of 101


© 2017 Progress Software Corporation. All rights reserved.
There are many ways to code ABL queries. Below is a code snippet with a
variation on the code above. The WHERE clause is used to set the customer
number in the OPEN QUERY, and since that is the only customer number
read the check is removed from the loop for iDemoCust. The code also
expands the code for ‘EACH Order OF Customer’, which is short hand for
specifying the WHERE clause. In addition, the QUERY-OFF-END clause
and specifying the quoted query name, qOrder, is used in place of ‘IF NOT
AVAILABLE(Order)’.


OPEN QUERY qOrder
FOR EACH Customer WHERE Customer.CustNum EQ iDemoCust,
EACH Order WHERE Order.CustNum EQ Customer.CustNum
/* Equivalent to ‘EACH Order OF Customer’ */
BY Customer.CustNum BY OrderDate.

REPEAT:
GET NEXT qOrder.
IF QUERY-OFF-END('qOrder') THEN
LEAVE.
IF Customer.CustNum EQ iDemoCust THEN

5. Press the space bar to close the Progress window.

6. Close the program in the editor.

Note: Skip the next lab since it shows the same ABL code examples that were presented in the
in labs 6 through 8. The only difference is that it uses the standalone ABL editor (GUI Procedure
Editor), instead of using Developer Studio.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 79 of 101


© 2017 Progress Software Corporation. All rights reserved.
Lab 09: Optional - ABL GUI Procedure Editor
Overview
This lab is optional, since it contains the same ABL code that is presented in labs 6
through 8. The difference between those three labs and this lab is that this is a
standalone lab. This means that you don’t need to complete any other labs prior to
this lab. Instead of using Developer Studio, this lab uses the simpler, ABL GUI
Procedure Editor. This is also known as the stand alone editor. This is lab is
designed for developers that want to get started immediately writing and running
ABL code.

Note: It’s recommended that you skip this lab if you completed labs 6 – 8. The ABL code, and
many of the steps, are nearly identical to those provided in this. The other labs in this tutorial focused
on coding in Developer Studio in order to showcase some of the powerful tools that it provides. For
larger projects, Developer Studio is the preferred development tool when working with OpenEdge
since it provides many features which are not available in the standalone editor. However, if you just
want to code in ABL, then the standalone ABL editor is a good choice.

This lab focuses on how easy it is to access and work with data from an OpenEdge
database using ABL. ABL is a language that is optimized for business
applications. Using ABL you can read, update, and manipulate data with very few
lines of code relative to other languages.

The lab only touches the surface of ABL, showing some of the power provided by
the language. More in-depth information on ABL is provided in the free courses
that are included with OpenEdge Developer Kit. Please see the OpenEdge
Courses Included with the Classroom Edition of OpenEdge Developers Kit
section in this document for information on how to access these courses.

Information: Another good starting point as you learn about ABL is the OpenEdge manuals:
 ABL: ABL Essentials
 ABL: ABL Reference

Prerequisites
The only perquisite is basic programming knowledge in any language.

Start the GUI Procedure Editor and connect to the sport database

In this section you’ll start the standalone ABL editor. You’ll also open the Data
Administration tool to create a copy of the sport database and to connect the
editor session to that database.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 80 of 101


© 2017 Progress Software Corporation. All rights reserved.
1. Open the standalone ABL editor by selecting All Programs → Progress →
OpenEdge 11.7 (64-bit) → GUI Procedure Editor, or select the icon shown
to the right.

The editor opens:

2. Select Tools → Data Administration from the Procedure Editor menu to


open Data Administration.

3. Skip to Step 9, if the sport database has already been created, otherwise
continue to the next step to create the sport database.

4. Use Windows Explorer to go to directory C:\OpenEdge\WRK and create a


sub-directory named db.

5. From Data Administration menu select Database → Create.

6. In the Create Database dialog:


a. Enter New Physical Database Name as
C:\OpenEdge\WRK\db\sport.db
b. Select A Copy of the Sports2000 Database.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 81 of 101


© 2017 Progress Software Corporation. All rights reserved.
7. Click OK. The sport database is created.

8. Connect the database to this editor by selecting Database → Connect from the
Data Administration menu.

Note: The Connect Database dialog is displayed automatically after creating a new
database, automatically filling in the Physical Name and the Logical Name. If this is the case
then you don’t need to select Connect from the Database menu.

9. In the Connect Database dialog, set the connection parameters:


c. Physical Name: C:\OpenEdge\WRK\db\sport.db (Browse button)
d. Logical Name: sport

These are the only parameters needed if you didn’t start a database server.

10. If you did start a database server then click the Options button and set these
parameters also:
e. Multiple Users: <checked>
f. Host Name: localhost
g. Service Name: 5678

OpenEdge Developers Kit: Getting Started with OpenEdge Page 82 of 101


© 2017 Progress Software Corporation. All rights reserved.
11. Click OK. The sport database is connected to the session.

12. Close Data Administration by selecting Database → Exit. The database


remains connected to the editor.

Note: The next time you start the standalone ABL editor you will need to reconnect the
database as you did above by opening Data Administration and entering the connection
information in the Connect Database dialog, following steps 8 through 11.

13. Use Windows Explorer to go to directory C:\OpenEdge\WRK and create a


sub-directory named ABL. This directory will be used to hold the ABL
programs that are created in this lab.

Tip: Here is sample of some of the editor commands:


> Run = F2
> Save = F6
> Next Buffer = F7
> Close proc = F8

Using the DO loop, LEAVE statement, and MESSAGE statement

This section provides an example of an ABL ‘DO loop’. The program is controlled
programmatically using a variable. The result is displayed in message box.

1. Type or copy the code below into the editor:

/* File : 01_DO_Loop.p
Purpose: ABL example of a DO loop */
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DO iCounter = 0 TO 20 BY 5:
MESSAGE "Current count:" iCounter VIEW-AS ALERT-BOX.
IF iCounter EQ 10 THEN
LEAVE.
END.

The message box will be displayed each time the ‘DO loop’ is executed.

2. Select F6 to save the program.

3. In the Save As dialog navigate to directory C:\OpenEdge\WRK\ABL.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 83 of 101


© 2017 Progress Software Corporation. All rights reserved.
4. Set the File name to 01_DO-Loop.p, and select Save.

5. Select F2 to run the program.

6. Click OK as each message box is displayed.

The DO loop ends when iCounter is 10. As expected, the program finishes
after displaying ‘Current count: 10’.

7. Select F8 to close the program.

Using FIRST and LAST when finding a record

This program has two queries. It finds the FIRST and LAST values in a table
based on the selected index for the table. The index is automatically selected by
the database based on the query. In this case, for the ‘FIND FIRST’ query the
primary key DeptCode on table Department is used. For the ‘FIND LAST’
query the non-primary index DeptCode on table Employee is selected by the
database since the query uses that field in the WHERE clause.

1. Type or copy the code below into the editor:

/* File : 02_First_Last.p
Purpose: ABL example FIND using LAST and FIRST */
FIND LAST Department.
DISPLAY DeptName DeptCode SKIP '-----------------'.

FIND FIRST Employee


WHERE Employee.DeptCode EQ Department.DeptCode.
DISPLAY Employee WITH 1 COLUMN.

2. Select F6 to save the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 84 of 101


© 2017 Progress Software Corporation. All rights reserved.
3. If it is not already selected, in the Save As dialog navigate to directory
C:\OpenEdge\WRK\ABL.

4. Set the File name to 02_First_Last.p, and select Save.

5. Select F2 to run the program.

In first query finds the LAST department. The column used for last depends
on the selected index. In this case the primary index is selected, which is on
DeptCode. The query returns Dept finance and DeptCode 700.

The SKIP statement skips to the next line and displays dashes, separating the
returned by the next query.

The second query returns employee number 36 and includes the expected
DeptCode of 700.

As shown below is a Preview of the data in the Department table, using


the DB Navigator perspective and DB Details view. All of the records in the
Department table are displayed, showing that the largest value in the
DeptCode field is 700.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 85 of 101


© 2017 Progress Software Corporation. All rights reserved.
Note: The DB Navigator perspective is referenced in this section with regard to
understanding the database schema and displaying the database data. More information on this
perspective can be found in this document in lab 04.

6. Press the space bar to close the Progress window.

7. Select F8 to close the program.

Using FOR loops to access database records

This program has two ‘FOR loop’ queries, each one showing different options for
selecting records.

1. Type or copy the code below into the editor:

/* File : 03_FOR_Loop.p
Purpose: ABL example using a FOR EACH loop and WHERE */
FOR EACH Customer WHERE Balance >= 40000:
DISPLAY Name Balance.
END.

FOR EACH Customer WHERE Customer.CustNum LT 4:


DISPLAY CustNum Customer.Name FORMAT "x(15)"
Customer.Comments FORMAT "x(20)".
END.

The first ‘FOR loop’ returns records from the Customer table for each
customer that has a balance greater than or equal to 4000. The query returns
the name and balance for all customers that have a balance exceeding 40,000.

The second ‘FOR loop’ returns all customer records where the customer
number (CustNum) is less than 4. The DISPLAY outputs three fields. Two
uses the FORMAT qualifier to set how many characters of each field will
display.

2. Select F6 to save the program.

3. If it is not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 03_FOR_Loop.p, and select Save.

5. Select F2 to run the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 86 of 101


© 2017 Progress Software Corporation. All rights reserved.
As seen above, the first ‘FOR loop’ shows records for each customer where
there balance exceeds $40,000 .

Unlike the previous queries, there isn’t an index that orders the records based
on the query. As can be seen in the screenshot below, there isn’t an index on
that includes the Balance field. While it would be more efficient to define an
index on this field if it is a commonly used query (since it would avoid return
the records in the requested order), the database handles the query by accessing
the records using the CustNum index, the primary index , to return the
requested records.

8. Press the spacebar to see the results from the second query.

The second ‘FOR loop’ shows records from the customer table where the
customer number is less than 4 . The database selects the CustNum index
on the database, which is defined on the CustNum field to efficiently return the
records.

9. Press the space bar to close the Progress window.

10. Select F8 to close the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 87 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using MATCHES

The MATCHES statement is used in this query to select records that match a
character string. It isn’t possible to create a database index to handle MATCHES.
However, this type of query is valuable since you can search on any character
string in any CHARACTER field defined in the database. Wild card characters are
supported including ‘.’ for a particular character and ‘*’ to match any group of
characters.

1. Type or copy the code below into the editor:

/* File : 04_Matches.p
Purpose: Example using ABL MATCHES */
FOR EACH supplier WHERE Supplier.Name MATCHES "*Sports*":
DISPLAY Name.
END.

DEFINE VARIABLE cString AS CHARACTER INITIAL ".324*" NO-UNDO.


FOR EACH Customer NO-LOCK
WHERE Customer.Address MATCHES(".324*"):
//WHERE Customer.Address MATCHES(cString):
//WHERE Customer.Address MATCHES("3.24*"):
DISPLAY Customer.Name FORMAT "x(15)"
Customer.Address FORMAT "x(15)"
Customer.City FORMAT "x(10)"
Customer.State FORMAT "x(4)"
Customer.Country FORMAT "x(15)".
END.

2. Select F6 to save the program.

3. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 04_Matches.p, and select Save.

5. Select F2 to run the program.

The first query uses MATCHES on the Name field of the Supplier table. It
returns where the Name field includes the string ‘Sports’ anywhere in the
name, thanks to the ‘*’ wild card.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 88 of 101


© 2017 Progress Software Corporation. All rights reserved.
6. Press the spacebar to see the results from the second query.

The second query uses MATCHES on the Address field of the Customer
table. In this example we don’t know the first digit for the address, but we
know that the next three digits are 324. The wild card for one character is used
prior to 324, followed by an asterisk to match any other characters (".324*").
The records were identified that matched the selection.

7. Press the space bar to close the Progress window.

8. There are two variations included for the second query. You can try these out
by commenting the existing WHERE clause (by removing //), and un-
commenting one of the other WHERE clauses. Only one WHERE clause can
be uncommented.
h. Variation one shows how a defined variable, cString, can be used to
provide the value for the MATCHES statement. This is closer to a real
world example since it is likely that the value would be input in a
program and saved in a variable, as opposed to hard coding it in a
query. The output for this example is unchanged.

i. Variation two shows an example of finding string ("3.24*"). While


this is similar to the other string, it shows how to search for a string
where the second character is unknown, while the first, third, and
fourth are know.

9. If it is open, press the space bar to close the Progress window.

10. Select F8 to close the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 89 of 101


© 2017 Progress Software Corporation. All rights reserved.
Using a Word Index

This example shows how to use a word index. A word index is similar to
MATCHES, since both support finding records in a character field based on a
string. However, a word index accesses the database using an index that is
designed for search on a word or the beginning of a word, rather than on any
character string.

Tip: A word index supports searching on multiple words for a given field. The ampersand (&)
represents a logical AND; the vertical line (|), exclamation point (!), or caret (^) represent a logical
OR. An asterisk (*) as a wildcard that can be used only at the end of a word.

1. Type or copy the code below into the editor:

/* File : 05_Word_Index.p
Purpose: ABL example using a word index */
DEFINE VARIABLE cString AS CHARACTER INITIAL "Pearl Izumi" NO-UNDO.
//DEFINE VARIABLE cString AS CHARACTER INITIAL "NotHere" NO-UNDO.
//DEFINE VAR cString AS CHAR INIT "footballs | helmets" NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER INITIAL 0 NO-UNDO.

FOR EACH RefCall WHERE RefCall.Txt CONTAINS cString:


iCount = iCount + 1.
FIND Customer WHERE Customer.CustNum EQ RefCall.CustNum.
DISPLAY Customer.Name
RefCall.Txt LABEL "Reference Comment".
END.

IF iCount EQ 0 THEN
MESSAGE "No records match string value: '"
cString "'." VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Found " iCount " record(s) that matches string: '"
cString "'." VIEW-AS ALERT-BOX.

2. Select F6 to save the program.

3. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 05_Word_Index.p, and select Save.

5. Select F2 to run the program.

The RefCall table holds information about a sale. The Txt field is used to
hold notes that refer to a sale. A word index has been created on the Txt field.
In the code, the ABL CONTAINS clause is used to search a word index.

There are three DEFINE VARIABLE statements for cString, two of which are
commented out. You can uncomment the commented strings to see the
behavior when multiple records are found, or when no records are found, just
make sure that only one ‘DEFINE statement’ is uncommented for cString.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 90 of 101


© 2017 Progress Software Corporation. All rights reserved.
6. Save the file (Ctrl + S) and run the program (Ctrl + F11).

This query makes use of a word index that is defined on the RefCall table on
the Txt field, as can be seen below in the DB Details view, using the DB
Navigator perspective. Note the ‘Yes’ in the Word Index column .

7. Select OK in the message box, and Press the space bar to close the Progress
window.

8. Comment the first DEFINE statement and uncomment the second DEFINE
statement that contains "NotHere", and then run the program.
No values in the word index match the string, so no records are returned.
However, you still see the message box.

9. Select OK to close the message box.

10. Comment the second DEFINE statement and uncomment the third DEFINE
statement that contains "footballs | helmets", and then run the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 91 of 101


© 2017 Progress Software Corporation. All rights reserved.
This query provides an example of looking for multiple words. In this case if
the Reference Comment contains either footballs or helmets then the record is
returned. There are three records returned.

Tip: You may wonder why the display of the Reference Comment field is formatted as
an editor. This is because the formatting for that field is defined in the database schema
information in the RefCall table for that field, as seen in the View-AS column , by adding
VIEW-AS EDITOR … .

As with many areas in OpenEdge, if you wanted to change the code to display in the standard
way you could override the VIEW-AS EDITOR by adding VIEW-AS TEXT to the DISPLAY
command for that field.

11. Select OK in the message box, and Press the space bar to close the Progress
window.

12. Select F8 to close the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 92 of 101


© 2017 Progress Software Corporation. All rights reserved.
Creating a new record in the database

This section shows how to create a new record in the database.

1. Type or copy the code below into the editor:

/* File : 06_Create_Record.p
Purpose: ABL example of creating a database record */
DEFINE VARIABLE iOrderLine AS INTEGER NO-UNDO.

FIND LAST Order.

/* Determine next OrderLine number for the selected Order */


FIND LAST Orderline
WHERE OrderLine.Ordernum EQ Order.Ordernum NO-ERROR.
/* Set iOrderline one higher than the last Orderline record. */
IF AVAILABLE OrderLine THEN
ASSIGN iOrderLine = Orderline.LineNum + 1.
/* There are no OrderLines for the selected Order */
IF NOT AVAILABLE OrderLine THEN
ASSIGN iOrderLine = 1.

/* Create a new OrderLine for the selected Order


and assign values */
CREATE Orderline.
ASSIGN Orderline.LineNum = iOrderline
Orderline.OrderNum = Order.OrderNum
Orderline.ItemNum = 7
Orderline.Price = 1.20
Orderline.Qty = 6.

DISPLAY Orderline WITH 1 COLUMN.

2. Select F6 to save the program.

3. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 06_Create_Record.p, and select Save.

5. Select F2 to run the program.

The new record is created, assigning 5 values. Let’s walk through the code.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 93 of 101


© 2017 Progress Software Corporation. All rights reserved.
j. The last Order record is found. This is based on the Ordernum field.
The Ordernum index is selected since it is the primary index on the
table. As shown here the last Order Num is 6150 .

k. The FIND statement looks for the last OrderLine record for Order
6150. If it is found it sets the variable iOrderLine to one greater than
the Linenum for the OrderLine. This makes the value for Linenum
unique, relative to the other records. If it is not unique the ‘create’ will
fail since there is a unique index orderline defined. The two fields
that define the orderline index , Ordernum and Linenum, must be
unique relative to all other records in the OrderLine table. If an
OrderLine record was not defined for the Order then it is the first
OrderLine and iOrderLine is set to 1.

l. The CREATE statement is used to create a new record. . However,


the record is not written to the database until after the ASSIGN
statement executes.

m. The ASSIGN statement defines values for five fields for the new
record.

n. The DISPLAY statement displays the new record. The five values can
be seen. The Line Num is set to iOrderLine as shown in the Progress
window screenshot .

7. Press the space bar to close the Progress window.

8. Select F8 to close the program.

Updating a record in the database

This section shows how to update an existing record in the database.

1. Type or copy the code below into the editor:

/* File : 07_Update_Record.p
Purpose: ABL example of updating a database record */
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.

FIND FIRST Order WHERE Order.Ordernum EQ cOrdNum NO-ERROR.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 94 of 101


© 2017 Progress Software Corporation. All rights reserved.
/* Apply 10% discount to each ordered item for Order 44 */
IF AVAILABLE Order THEN DO:
FOR EACH OrderLine
WHERE OrderLine.Ordernum = Order.Ordernum:
ASSIGN OrderLine.Price = OrderLine.Price * .90.
DISPLAY OrderLine.Ordernum OrderLine.Linenum
OrderLine.Itemnum OrderLine.Price.
END.
END.

This code locates each OrderLine record for the select Order and then
discounts the price for the order line item by 10%.

2. Select F6 to save the program.

3. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 07_Update_Record.p, and select Save.

5. Select F2 to run the program.

Note: The values in the price field may not match what you see in this screenshot. Each
time the program is run it is updating the selected records in the database. Each time the
program is called it reduces the price by 10%.

6. Press the space bar to close the Progress window.

7. Select F8 to close the program.

8. Type or copy the code below into the editor:

/* File : 07b_Update_Record.p
Purpose: ABL example of updating a database record,
including output showing before and after values */
DEFINE VARIABLE beforePrice AS DECIMAL NO-UNDO.
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.

FIND FIRST Order WHERE Order.Ordernum EQ cOrdNum NO-LOCK NO-ERROR.


FIND FIRST Customer WHERE Customer.Custnum EQ Order.Custnum NO-LOCK.
DISPLAY Customer.Name LABEL "Customer Name" Order.Ordernum.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 95 of 101


© 2017 Progress Software Corporation. All rights reserved.
/* Apply 10% discount for each item for the selected Order */
IF AVAILABLE Order THEN DO:
FOR EACH OrderLine
WHERE OrderLine.Ordernum = Order.Ordernum EXCLUSIVE-LOCK:
ASSIGN
beforePrice = OrderLine.Price
OrderLine.Price = OrderLine.Price * .90.
FIND FIRST Item WHERE Item.Itemnum EQ OrderLine.Itemnum NO-
LOCK.
DISPLAY SKIP Item.ItemName FORMAT "x(20)"
beforePrice LABEL " Original Price"
OrderLine.Price LABEL "Discount Price"
WITH 1 COLUMN.
END.
END.

This example does the same thing as the first one but adds some code to show
what is going on in the transaction including the name of the customer, the
name of the item being discounted, and the before and after price for the item.

9. Select F6 to save the program.

10. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

11. Set the File name to 07b_Update_Record.p, and select Save.

12. Select F2 to run the program.

We can see at the top information from the Order record, displaying the
Customer Name and the Order Num.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 96 of 101


© 2017 Progress Software Corporation. All rights reserved.
For each OrderLine record three values are displayed: the Item name along
with the Original Price and the Discount Price, after applying the 10%
discount.

13. Press the space bar to close the Progress window.

14. Select F8 to close the program.

Deleting a record in the database

This section shows how to delete a record in the database.

1. Type or copy the code below into the editor:

/* File : 08_Delete_Record.p
Purpose: ABL example of deleting a database record */
DEFINE VARIABLE cEmpNum AS INTEGER NO-UNDO.
DEFINE VARIABLE dStartDate AS DATE NO-UNDO.

FIND LAST Vacation EXCLUSIVE-LOCK NO-ERROR.

IF AVAILABLE Vacation THEN DO:


ASSIGN
cEmpNum = Vacation.EmpNum
dStartDate = Vacation.StartDate.
DELETE Vacation.
MESSAGE "Record deleted" VIEW-AS ALERT-BOX.
END.
ELSE DO:
/* For this example this message is displayed
when there are no vacation records */
MESSAGE "Record not found" VIEW-AS ALERT-BOX.
END.

FIND Vacation WHERE Vacation.EmpNum EQ cEmpNum AND


Vacation.StartDate EQ dStartDate NO-ERROR.
IF NOT AVAILABLE Vacation THEN
MESSAGE "Record does not exist." VIEW-AS ALERT-BOX.

2. Select F6 to save the program.

3. If not already selected, in the Save As dialog navigate to directory


C:\OpenEdge\WRK\ABL.

4. Set the File name to 08_Delete_Record.p, and select Save.

5. Select F2 to run the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 97 of 101


© 2017 Progress Software Corporation. All rights reserved.
The message appears that the record is has been deleted.

6. Click OK to continue.

An attempt is made to re-read the record from the database. The record is not
found since it has been deleted.

The fields Vacation.EmpNum and Vacation.StartDate are used to look for


the record since these two fields make up the unique index on the table.

7. Click OK to continue.

8. Select F8 to close the program.

Example of an ABL query

In this section you’ll see how to code an ABL static query, which is created using a
DEFINE QUERY statement. In addition to static queries, ABL also supports
dynamic queries. Dynamic queries are coded using the CREATE QUERY
statement.

Information: For a more detailed introduction to queries read the Using Queries chapter in
the ABL: ABL Essentials manual.

1. Type or copy the code below into the editor:

/* File : 09_Query.p
Purpose: Example of an ABL static query */
DEFINE QUERY qOrder FOR Customer, Order.
DEFINE VARIABLE iDemoCust AS INTEGER INITIAL 5 NO-UNDO.

OPEN QUERY qOrder FOR EACH Customer,


EACH Order OF Customer
BY Customer.CustNum BY OrderDate.

/* Repeat loop continues until the LEAVE statement is called */

OpenEdge Developers Kit: Getting Started with OpenEdge Page 98 of 101


© 2017 Progress Software Corporation. All rights reserved.
REPEAT:
/* Get the next record from the current cursor position */
GET NEXT qOrder.
/* If the next record was not found then leave the loop */
IF NOT AVAILABLE(Order)
OR Customer.CustNum GT iDemoCust THEN
LEAVE.
/* When the customer is found display information */
IF Customer.CustNum EQ iDemoCust THEN
DISPLAY Customer.CustNum LABEL "Number"
Customer.Name LABEL "Customer" FORMAT "x(12)"
Order.Ordernum LABEL "Order" FORMAT "9999"
Order.Creditcard LABEL "Credit Card".
END.

CLOSE QUERY qOrder.

A walk through the sample code:

o. The DEFINE QUERY statement defines an ABL query.

p. Variable iDemoCust sets the customer number used for comparison.

q. The BY phrase sorts the results, which is useful if there isn’t an index on the
table to sort the records in the desired order.

r. The query can be repositioned and data can be accessed using GET with
FIRST, NEXT, PREV, LAST, and CURRENT. The REPEAT loop
processes records, reading a record each time GET NEXT is called. The GET
statement reads the next record from the current position of the cursor in the
query. When first opened the query is positioned before the first record
returned by the query.

s. There are two IF statements. If an Order record is not available, or it if the


Customer record CustNum value is greater than iDemoCust, LEAVE is
called to stop the loop.

t. After this query is no longer needed CLOSE QUERY is called, which frees
the system resources used by the query.

2. Select F6 to save the program.

3. If not already selected, in the Save As to directory C:\OpenEdge\WRK\ABL.

4. Set the File name to 09_Query.p, and select Save.

5. Select F2 to run the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 99 of 101


© 2017 Progress Software Corporation. All rights reserved.
The display shows data from the selected Customer record and for each Order
record for that Customer.

There are many ways to code ABL queries. Below is a code snippet with a
variation on the code above. The WHERE clause is used to set the customer
number in the OPEN QUERY, and since that is the only customer number
read the check is removed from the loop for iDemoCust. The code also
expands the code for ‘EACH Order OF Customer’, which is short hand for
specifying the WHERE clause. In addition, the QUERY-OFF-END clause
and specifying the quoted query name, qOrder, is used in place of ‘IF NOT
AVAILABLE(Order)’.


OPEN QUERY qOrder
FOR EACH Customer WHERE Customer.CustNum EQ iDemoCust,
EACH Order WHERE Order.CustNum EQ Customer.CustNum
/* Equivalent to ‘EACH Order OF Customer’ */
BY Customer.CustNum BY OrderDate.

REPEAT:
GET NEXT qOrder.
IF QUERY-OFF-END('qOrder') THEN
LEAVE.
IF Customer.CustNum EQ iDemoCust THEN

7. Press the space bar to close the Progress window.

8. Select F8 to close the program.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 100 of 101
© 2017 Progress Software Corporation. All rights reserved.
Tutorial Summary

Congratulations!

You’ve completed the Getting Started with OpenEdge tutorial.


Here’s a brief summary of some of your accomplishments:
 Worked with Progress Developer Studio for OpenEdge to create a
workspace and projects, and modified the workspace preferences and
project properties to control the environment.

 Created an OpenEdge database and explored the database schema.

 Entered and ran a number of OpenEdge ABL programs that worked


with the OpenEdge database to display, add, update and delete records.

Now that you’ve complete this introduction to OpenEdge it time to move on to the next
steps so that you can take advantage of your new found knowledge by learning more
about OpenEdge and by creating your own OpenEdge applications.

A great next step is to go through the three free on-line courses that are included with
the Classroom Edition of OpenEdge Developers Kit by going to
https://wbt.progress.com to access these courses:
1. Introduction to Progress OpenEdge
2. Introduction to Progress OpenEdge Integration
3. Developing a Progress OpenEdge ABL Application

Check the OEDK web page documentation area for additional tutorials on OpenEdge
topics, including OpenEdge Developers Kit: Getting Started with Progress®
Application Server for OpenEdge.

If you have questions about this tutorial or about OpenEdge in general, then please post
your questions to the OpenEdge Forum on Progress Community. The Forum is a
place where users can start a thread or add to an existing thread on a particular topic.
Access to the Forum is available here:

https://community.progress.com/community_groups/openedge_development/f/19.

Thank you for your time.

OpenEdge Developers Kit: Getting Started with OpenEdge Page 101 of 101
© 2017 Progress Software Corporation. All rights reserved.

You might also like