A properly configured OpenEdge project requires an active database connection and without it, essential features such as compilation and code completion are either limited or non-functional. This section focuses on enabling seamless integration between the development environment and a local OpenEdge database for a streamlined coding experience.

As an example, the following steps establish a connection to the sports2020 database by adding a dbConnections block to the openedge-project.json file, enabling both compilation through the AVM and code completion through the ABL language server using the associated schema file:

  1. To enable database connectivity in your OpenEdge project, update the openedge-project.json project configuration file with the following dbConnections block:
    
    "dbConnections": [
      {
        "name": "sp2k",
        "connect": "-db db/sports2020 -ld sp2k -RO",
        "schemaFile": "dump/sports2020.df",
        "aliases": ["sports"]
      }
    ]
    Note: The schemaFile attribute is important for enabling code completion in the ABL Language Server. ABL Virtual Machine (AVM) handles compilation and requires an active database connection with the correct name and aliases. In contrast, code completion is powered by the Java-based language server, which does not connect to the database directly. Instead, it relies entirely on .df dump files for schema awareness. To ensure consistent and reliable code completion, it is recommended to always include the database schema file in your code repository.
  2. After updating the configuration, restart the ABL language server.
    You may encounter the following error at this stage:
    OpenEdge client ended because it couldn't connect to a database.
    To investigate this error, navigate to .builder/clientlog0.log and review the log for specific error messages. For example, the following log output indicates that the local database is missing and needs to be created.
    Connecting to DB 'sp2k': '-db db/sports2020 -ld sp2k'
    Unable to connect to 'sp2k'
    ** Cannot find or open file C:\workspace\myProject\db\sports2020.db, errno = 2. (43)
  3. To create and initialize database using Proenv:
    1. Open Visual Studio Code and switch to the Terminal tab.
    2. Click the ➕ icon to open a new terminal.
    3. Select Proenv from the dropdown.

      The Proenv environment that matches the OpenEdge version of your project is automatically launched and initialized at the root directory of your project.

      Within this environment, an Ant buildfile, which automates database creation is already configured and available. However, you can create your own xml file in the root of the project to configure database creation. Here is an example of the xml file:
      <?xml version="1.0" encoding="utf-8"?>
      <project name="myProject">
          <property environment="env" />
          <property name="DLC" value="${env.DLC}" />
      
          <taskdef resource="PCT.properties">
              <classpath location="${DLC}/pct/PCT.jar" />
          </taskdef>
      
          <ProgressVersion dlcHome="${DLC}" fullVersion="dlc.version.full" />
          <echo message="${dlc.version.full}" />
          <PCTVersion />
      
          <target name="db">
              <mkdir dir="target/db" />
              <PCTCreateDatabase sourceDB="${DLC}\sports2020" destDir="db" dbName="sports2020" dlcHome="${DLC}"/>
          </target>
      </project>
      
      After the Proenv terminal is active, run the following command to create the sports2020 database in the db directory:
      %DLC%\ant\bin\ant db
      This command creates the \target\db directory within your project to store the database files. It also sets up the foundational structure of the database in this location, making it ready for use by the AVM for compliation and language server for code completion through schema files.
  4. To validate compilation and code completion:
    1. Restart the ABL language server and modify src/test1.p to include a reference to the customer table.
    2. Save and compile the file.
    3. Hover over the table name in a FIND or FOR EACH statement to view full table details and index usage.
    4. Confirm that code completion is active for table and field names.