02 Mrz Set up PCase for macro development
PCase is the leading Case Tool for OpenEdge . The user can extend PCase with macros. These macros are ABL programs, mostly used for code generation or data import and export.
PCase comes with a bunch of predefined macros, these can be used as examples.
This article describes how to join a project (OpenEdge Architect / Studio) with PCase, so that everything for macro development is ready. For preparation PCase must be downloaded and installed for the version of OpenEdge which will be used for the work.
The screen-shot shows a typical macro usage situation, where two tables are selected and the little green wheel in the upper right is clicked and a wizard shows the table macros – which are default macros of PCase.
The macros exist on different content levels of PCase data (model, relation, table, difference…).
To develop and add user macros from an OpenEdge project to PCase, PCase and the project must know each other:
- Set up PCase DB with DB server.
- Add PCase classes to OE project, so that a project related macro can inherit PCase classes and call PCase functionality.
- Extend PCase macro search path, so that PCase can find the macros in the Studio / Architect project.
Set up PCase with DB server
Normally, only the PCase process is connecting the PCase DB.
But the project also needs to connect it, therefore we need a DB server, to allow multiple connects.
When PCase is installed with the default settings, then PCase ist installed in the OpenEdge installation directory. PCase has an independant ABL run time, so an Eclipse (Architekt / Studio) project does not know anything about it.
OE Installation: | d:\dlc\113 |
PCase base directory: | d:\dlc\113\oeide\eclipse\plugins\de.iap.t4p_2.1.0\PCase |
Macro directory: | [base]\macros |
The PCase DB (t4p) is installed in a 'db' directory inside the PCase base directory. Setting up the DB server is like setting up any other OpenEdge DB (using OpenEdge Explorer/Management or a script/batch).
Set up copy or move DB using one of these:
- A) Set up server for original location
- B) procopy t4p to new location
- C) Move and repair the t4p DB
The server should have -L 100000 set, that is a good value - some operations must run in a large transaction.
PCase uses the information in startup.pf to connect the t4p DB.
In my installation for example I connect with: -db "t4p" -H localhost -S 55001
ADD PCASE CLASSES TO A PROJECT
Step one: Add the PCase DB to the project:
- Open project properties
- Go to Progress OpenEdge database connections
- Then go to “Configure database connections”
- Add a new one, call it like “PCase DB Shared”
- DB: t4p -H localhost -S 55001
(No SQL connect, no autostart) - Save DB and add it to the project
Screenshot is showing Read Only mode, sorry, will be updated.
Step two: Add PCase libraries to PROPATH
- Open project properties
- Go to Progress OpenEdge PROPATH
- Add these two entries at the end of the list:
External Directory: d:\dlc\113\oeide\eclipse\plugins\de.iap.t4p_2.1.0\PCase
External Library: D:\dlc\113\oeide\eclipse\plugins\de.iap.t4p_2.1.0\PCase\pc11.pl
Add project related propath as needed.
EXTEND PCASE MACRO SEARCH PATH
During start PCase scans the file system for OpenEdge classes, which are macros. A PCase macro is imlementing a specific interface (which will be discussed in the next PCase article), and PCase is scanning for this interface.
If PCase should find the macros from the project, then the project path must be added to the PCase macro search path.This is done in the file “startup.p“, which resides in the PCase directory.
e.g. in my example: d:\dlc\113\oeide\eclipse\plugins\de.iap.t4p_2.1.0\PCase\startup.p
First the project needs to be added to the propath of PCase. Then PCase is able to find resources (programs, images…) in user created macros.
/* ke, 01 Mar 2017; Add you project path here. */ PROPATH = "D:\dev\small-projects\IAP\PCase Macros\," + PROPATH.
Second the user (OE Architect/Studio) project must be added to find macros. It is best practice to let point the search path to a subdirectory. PCase will scan all class files which are in that directory and the subdirectories – so using the root directory of a large project will produce a log of scan calls. It is possible to add multiple directories with multiple calls.
In the example below the first call is the default call, the second call is the additional for user project macros.
DYNAMIC-INVOKE("t4p.pcase.macro.handler", "registerFolder", "./macros", "macros"). /* Add you project macros here, Parameters: Path, package */ DYNAMIC-INVOKE("t4p.pcase.macro.handler", "registerFolder", "D:\dev\small-projects\IAP\PCase Macros\macros", "macros").
The path, pointing to the directory where the macros reside, is simple.
The second one is needed to expand the relative search path to the object call path.
Example:
Project directory: | D:/dev/proj1 |
Macro directory: | D:/dev/proj1/pcase/macros/tables/tblmacro1.cls |
PCase Search: | D:/dev/proj1/pcase/macros |
Relative name: | tables/tblmacro1.cls -> tables.tablemacro1 |
Object call: | pcase.macros.tablesmacros.tablemacros |
To be able to call the object, the resulting package is “pcase.macros”, to expand “tables.tblmacro1” to “pcase.macros.tables.tblmacro1”.
Resulting in this call:
DYNAMIC-INVOKE("t4p.pcase.macro.handler", "registerFolder", "D:/dev/proj1/pcase/macros", "pcase.macros").