OEDK Tutorial Getting Started OpenEdge 11.7
OEDK Tutorial Getting Started OpenEdge 11.7
© 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
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.
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
https://wbt.progress.com
Additional Information
https://www.progress.com/support/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
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.
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
https://www.progress.com/.
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.
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.
https://community.progress.com/
OpenEdge Development:
https://community.progress.com/community_groups/openedge_development/
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/
Mobile:
https://community.progress.com/community_groups/mobile/
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.
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/
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.
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.
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.
AdminServer
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)
Prerequisites
Complete the following task prior to doing this lab:
Complete the steps in Installing the Progress® OpenEdge® Developers Kit
document
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.
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.
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.
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.
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).
4. Close the workbench by clicking on the in the top right of the window.
The confirmation dialog is displayed.
The Help menu includes links for Help Contents, ABL Message, Search,
Samples, Tutorials, and others, as shown in the screenshot below:
From here enter a topic of your choice to locate information on that topic.
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.
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.
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.
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.
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.
d. Name the folder db and press Enter. This creates a new directory that
you will use to hold the database.
g. Click Save.
The New Physical Database Name field displays:
C:\OpenEdge\WRK\db\sport.db
Note: This makes a copy of a Sports2000 database, which is included in the OpenEdge
Developers Kit, and names the new copy sport.
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.
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.
The Services window opens and you should see the AdminService for
OpenEdge included in the list of services.
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.
Tip: For this tutorial you can use an easy to remember password such as progress.
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.
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.
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.
Whenever the password for OpenEdge Explorer is changed, the password used to
access OpenEdge Explorer must be updated in Developer Studio.
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
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.
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.
5. After a short time click F5 or the Refresh button to refresh the page.
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.
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
In this section you will define a connection to the sport database for the workspace.
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.
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.
Now that the database connection is defined for the workspace it can be associated
with project within that workspace.
5. Click OK. A message in the Console view shows that the database connection
is available for this project.
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
3. Using the Connections view (located in the lower-left), select sport under
Connection Profiles.
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.
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.
From the TABLE node you can see that there are 25 tables defined in the
database.
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.
The DB Details view provides additional details based on the selected node in the
DB Structure view.
2. Select the DB Details view. In this example the OpenEdge Table tab is
selected. It displays table properties.
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.
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.
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.
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.
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).
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.
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
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.
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.
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.
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.
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 */
2. Move the cursor into the OpenEdge Editor area and right-click. This displays
the context menu for the editor.
4. Type or copy the following code into the displayCustomer.p after the
comment.
find first customer.
display customer.name.
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.
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.
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.
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):
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.
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.
In this section you will use ABL code to read multiple records from an OpenEdge
database using a FOR EACH loop.
2. Right-click on the programs folder and select Paste from the context menu.
3. Change the name to displayCustomer2.p (adding a ‘2’ to the end), and then
click OK.
/* File : displayCustomer2.p
Purpose: ABL example of a FOR EACH loop */
for each customer:
display customer.name customer.contact customer.country.
The FOR EACH reads each record in the database customer table and then
displays the name, contact, and country for each customer.
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.
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.
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.
/* File : displayCustomer3.p
Purpose: Look at an error in an ABL program */
find next customer.
display customer.
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.
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.
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).
1. Hover over the error Description in the Problems view that is on line 3.
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.
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)".
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.
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
A new folder is created to hold the ABL programs that you’ll be working with in
this section.
3. In the New Folder dialog, set Folder name to ABL, and click Finish.
This new folder will be used to hold ABL programs.
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.
/* 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).
The DO loop ends when iCounter is 10. As expected, the program finishes
after displaying ‘Current count: 10’.
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.
/* File : 02_First_Last.p
Purpose: ABL example FIND using LAST and FIRST */
FIND LAST Department.
DISPLAY DeptName DeptCode SKIP '-----------------'.
4. Save the file (Ctrl + S) and run the program (Ctrl + F11).
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.
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.
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 .
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.
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.
/* File : 04_Matches.p
Purpose: Example using ABL MATCHES */
FOR EACH supplier WHERE Supplier.Name MATCHES "*Sports*":
DISPLAY Name.
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.
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.
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.
/* 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.
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).
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.
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.
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.
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
1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.
/* File : 06_Create_Record.p
Purpose: ABL example of creating a database record */
DEFINE VARIABLE iOrderLine AS INTEGER NO-UNDO.
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.
d. The ASSIGN statement defines values for five fields for the new
record.
1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.
/* File : 07_Update_Record.p
Purpose: ABL example of updating a database record */
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.
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).
6. Right-click on the ABL folder in myProj, and select New → ABL Procedure.
/* 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.
/* 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.
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.
1. Right-click on the ABL folder in myProj, and select New → ABL Procedure.
/* 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.
4. Save the file (Ctrl + S) and run the program (Ctrl + F11).
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.
6. Click OK to continue.
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
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.
Information: For a more detailed introduction to queries read the chapter on Using Queries in
the ABL: ABL Essentials manual.
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.
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
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.
…
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
…
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.
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.
3. Skip to Step 9, if the sport database has already been created, otherwise
continue to the next step to create the sport database.
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.
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
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.
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.
/* 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.
The DO loop ends when iCounter is 10. As expected, the program finishes
after displaying ‘Current count: 10’.
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.
/* File : 02_First_Last.p
Purpose: ABL example FIND using LAST and FIRST */
FIND LAST Department.
DISPLAY DeptName DeptCode SKIP '-----------------'.
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.
This program has two ‘FOR loop’ queries, each one showing different options for
selecting records.
/* 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.
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.
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.
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.
/* File : 04_Matches.p
Purpose: Example using ABL MATCHES */
FOR EACH supplier WHERE Supplier.Name MATCHES "*Sports*":
DISPLAY Name.
END.
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.
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.
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.
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.
/* 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.
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.
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.
10. Comment the second DEFINE statement and uncomment the third DEFINE
statement that contains "footballs | helmets", and then run the program.
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.
/* File : 06_Create_Record.p
Purpose: ABL example of creating a database record */
DEFINE VARIABLE iOrderLine AS INTEGER NO-UNDO.
The new record is created, assigning 5 values. Let’s walk through the code.
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.
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 .
/* File : 07_Update_Record.p
Purpose: ABL example of updating a database record */
DEFINE VARIABLE cOrdNum AS INTEGER INITIAL 44 NO-UNDO.
This code locates each OrderLine record for the select Order and then
discounts the price for the order line item by 10%.
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%.
/* 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.
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.
We can see at the top information from the Order record, displaying the
Customer Name and the Order Num.
/* 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.
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.
7. Click OK to continue.
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.
/* 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.
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.
t. After this query is no longer needed CLOSE QUERY is called, which frees
the system resources used by the query.
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
…
OpenEdge Developers Kit: Getting Started with OpenEdge Page 100 of 101
© 2017 Progress Software Corporation. All rights reserved.
Tutorial Summary
Congratulations!
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.
OpenEdge Developers Kit: Getting Started with OpenEdge Page 101 of 101
© 2017 Progress Software Corporation. All rights reserved.