Professional Documents
Culture Documents
Epicor 10 CC PDF
Epicor 10 CC PDF
Contents
1 Introduction.........................................................................................................................5
2 Custom Code Conversion Guidelines.................................................................................5
2.1 ERP and ICE Tables.....................................................................................................................................5
2.2 Case Sensitivity..........................................................................................................................................6
2.2.1 Case Sensitivity in String Comparisons.............................................................................................6
2.2.2 Compilation Errors...........................................................................................................................6
2.3 Calling Method From Business Object........................................................................................................7
2.4 Accessing ERP Context From Within System Directive.................................................................................8
2.5 Throwing Exceptions..................................................................................................................................9
2.6 Calling Method From Standard Assembly...................................................................................................9
2.7 Compatibility Class..................................................................................................................................10
2.8 Replacing Resulting Dataset.....................................................................................................................11
2.9 Redundant Transaction Scope..................................................................................................................11
2.10 BufferCopy Considerations....................................................................................................................12
2.11 Working With Extended Data.................................................................................................................12
2.11.1 Create User-Defined Fields...........................................................................................................12
2.11.2 Access User-Defined Fields...........................................................................................................14
2.11.3 Loading Extended Data Into Various Objects................................................................................15
2.11.4 Transition Path.............................................................................................................................15
2.12 Obsolete ABL Code................................................................................................................................16
2.13 Migrating ABL Expressions.....................................................................................................................16
2.14 Using External Libraries..........................................................................................................................17
2.14.1 Create Project in Visual Studio.....................................................................................................17
2.14.2 Call External Assembly Using BPM...............................................................................................18
2.15 Debugging Using Visual Studio..............................................................................................................20
2.15.1 Locate BPM Sources.....................................................................................................................20
2.15.2 Download Debugging Project......................................................................................................20
2.15.3 Open Project in Visual Studio.......................................................................................................21
2.15.4 Create Custom Code Directive.....................................................................................................22
2.15.5 Compile the Project.....................................................................................................................24
2.15.6 Debug the BPM...........................................................................................................................25
2.15.7 How to Modify Sample Project.....................................................................................................27
2.16 Adding and Subtracting Date.................................................................................................................28
2.17 Subtracting Two Dates and Comparing to an Integer Value....................................................................28
2.18 ABL Find Last Conversion.......................................................................................................................28
2.19 Using Unassigned Local Variable Message..............................................................................................30
2.20 Epicor 10 Equivalent to Row Mod = A or U............................................................................................31
2.21 Displaying an Informational Message.....................................................................................................31
2.22 Converting a Number to a String in LINQ Expression..............................................................................31
2.23 Outputting Data to a File.......................................................................................................................32
2.24 Updating Database Tables......................................................................................................................33
2.25 Sample of BPM calling a .p file and the final Epicor 10 version................................................................34
2.26 Sample of a BPM That Sends an Email....................................................................................................36
1 Introduction
The Custom Code Conversion Utility converts snippets of Progress ABL code used in previous Epicor ERP releases
to .NET C# language used by the Epicor ERP 10 framework.
The primary goal of this utility is to support migration of customizations and BPM custom code conversions. The
purpose of this guide is to provide guidelines on what corrections and modifications users may need to perform
after the code is converted from ABL language to C#.
Note
You can access the conversion tool by clicking this link: https://scrs.epicor.com/ABLConversionweb/.
On the Log in dialog, enter your EPICweb or other assigned User Name and Password. Click Login.
Epicor programs belong to either the application system (ERP) or the tools system (ICE). In Epicor ERP 10, certain
schema changes were made. Sometimes conversion results may need to be adjusted to reference the correct
part of the Epicor application.
In the following example, a user-defined table reference needs to be changed from "ERP" to "ICE", where it
now belongs.
Erp.Tables.UD01 UD01;
The updated code should look like the following:
Ice.Tables.UD01 UD01;
By default, code written in C# treats string comparisons as case sensitive, which was not the case in ABL code.
String comparisons at the SQL server disregard the case, because the SQL server database is always set up as
case insensitive. The code converter attempts to compare two strings - string A and string B - using the following
code:
string.Compare(string A, string B, true)==0
Sometimes converted code's case is not accurate and must be adjusted manually. Also, when new custom code
is created, appropriate case must be taken into account.
string.Compare((string)ttJobHead_xRow["ShortChar02"], “Education”, true)!=0
Remember that C# is a case-sensitive language, and it may result in compilation errors. For example, look at the
simple below:
Notice that the error message has "customer" starting with a lower-case letter c.
This query will cause the following error message when you try to compile the BPM:
In order for the BPM to compile without errors, change the first line of the query to use an upper-case letter C
as shown below:
In the following example, the GetByID() method is called from the Tip Service. In order to make a call to the
TipService method from another directive, you first add TipService contract assembly to the reference, and then
make the call. The svc variable holds the Tip contract instance.
If within one code scope (for example, one action) several calls are made to the same contract, it is recommended
to call ServiceRenderer just once. For example:
• C# Code:
You can access Erp Context from within a system directive. For example, review the following code:
In a BPM directive created for system BO "UD10", you need to access Part table which belongs to Erp context.
The code should look like the following:
Note At the moment, the BPM context is either ErpContext (for application directives) or IceContext (for
system directives). Therefore, within the IceContext, you will not find certain ERP tables (for example, Part),
and you will need to use the process described above.
Epicor is working towards enhancing the BPM and making the default context unified. Once this is
implemented, the need of accessing another context within the BPM code will be eliminated.
Exceptions are used to indicate that an error has occurred while the program is running.
The following example displays how you can throw a business exception from within the code:
throw new Ice.BLException("My exception");
Note Within the BPM Workflow Designer, the Raise Exception workflow element is the preferred way of
throwing exceptions.
Use the following steps when calling a method from another assembly (non-external assembly).
3. You can now construct the code that calls a method from another assembly. For example:
If the Compatibility class is present in the converted code, you need to add a reference to Compatibility.dll, which
can be found in the Assemblies folder.
This class contains conversion routines and helper methods to comply with Progress ABL code functionality.
• ABL Code:
• C# Code:
The following topic describes how to replace your directive's resulting record with another record.
For example, you may have a method directive action on the GetByID() method which returns a Part ID. The usual
BPM procedure provides the directive code with retrieved Part record, which is held in the ttPart table. If, for
some reason, you want to replace the whole resulting record with another record that you may have retrieved
yourself using another method, then you have the following options:
• Set the values on ttPart
• Replace the whole dataset
Note Fetching the dataset and replacing the whole dataset using the Attach method eliminates the need
of writing a lot of code. This is especially useful when the resulting dataset contains several tables.
In the following example, the record is retrieved using a sample method FetchRecord() and the result is replaced
with myRec.
var myRec = myService.FetchRecord(id);
this.dsHolder.Attach(myRec);
Usually using the Transaction Scope is not required as it is handled by the base method such as Update(). In some
cases, the code converter adds an unnecessary Transaction Scope reference, which needs to be manually removed.
For example, this behaviour may occur when you have a join between a temp table and a database table:
• ABL Code:
• Converted C# Code:
In this example, to fix the code above, remove the highlighted lines.
The following section describes what you should consider when working with Extended Data and the process of
creating custom columns and their usage within the BPM functionality.
In the previous versions of the Epicor application, each table included a series of user-defined fields, such as
Character01, Date03, Number02. While these additional columns were mostly sufficient for customizations,
some users ran out of available columns. Then, during an upgrade, these user-defined fields were overwritten,
so users needed to export customizations and, after the upgrade was complete, import them back into the
application. This process sometimes required users to additionally update the tables/columns to make the
customization compatible with the new application version. In other Epicor installations, the predefined user-defined
columns might not have been used at all, and were causing unnecessary system load.
To address these issues, the Epicor application now incorporates this functionality as a database extension. If you
are building a BPM directive that needs unique fields, you create extended user-defined tables and add columns
to these tables. Since these tables are extensions from parent tables, they are not overwritten during an upgrade.
In Epicor ERP 10, use the following process to create extended user-defined fields.
Note The existing Epicor 9.05 user-defined columns that were utilized (contained data) are automatically
migrated to Epicor ERP 10 as extended data columns.
1. Create the extended user-defined tables and columns (fields) within the Epicor application. To do this,
navigate to System Setup > System Maintenance and open Extended User Defined Table Maintenance.
2. Find and select the table you need to extend. Click Save. The application adds a "_UD" suffix to the end
of the table identifier.
3. Add the needed custom columns to the extended user-defined table that you have created.
When you save each column, the application adds a "_c" suffix to the end of this table column. This suffix
will help you identify this custom column when you create BPM directives that reference this column.
4. Add the extended user-defined table to the database. To do this, link it to the database by clicking the
Actions menu and selecting either the Sync Current Table to the DB or Sync All Tables to DB option.
5. Regenerate the data model for the Epicor database. You or your system administrator runs this task on the
server that hosts your database. The data model is regenerated using the Epicor Administration Console.
As a result, the base and the user-defined tables are joined in the data model.
6. Pull the latest data model from the database and copy it to the local application server by restarting IIS.
After the data model is successfully regenerated, restart the IIS.
Important Do not skip this step!
Note Unlike previous versions of the Epicor application, running the Directive Update program and
Refreshing Signatures of directives referencing affected table(s) with UD columns is no longer needed,
as it is performed automatically.
The extended user defined table and columns are now fully integrated with the database. You can now monitor
and update these custom columns through BPM directives.
This topic describes how you can reference user-defined columns within BPM in Epicor ERP 10.
1. User defined tables and primary tables merge into one for the database context. When you construct a Data
or Method Directive workflow, user-defined columns display as part of the base table.
2. When you design a business activity query (BAQ) in BPM from within Data and Method Directives, user-defined
columns also appear as part of the base table.
3. When working with ttTables for Data Directives, user-defined fields appear as part of the primary table,
and can be directly accessed. For example:
ttABCCode.MyNewColumn_c
4. Method directives work with temporary (tt) tables using tablesets, and so you access them through different
syntax. These tablesets are defined in the business object's (BO) contract .dll file, so their format is fixed and
they are not regenerated with the data model. When building a method directive that refers to user-defined
fields in temporary tables, reference them using the <tablename>["UDField<>()"] syntax. For example:
ttABCCode.UDField<System.String>(" MyNewColumn _c")
This topic discusses available extensions you can use to load ExtendedData into various objects.
Note Extended data is loaded automatically into table entities when data is retrieved from the database.
You may only need to manually load extended data into IceTablesets, IceTables or IceRow. Examples are
below:
• IceRow:
Ice.Tablesets.TipRow iceRow = new TipRow();
…
iceRow.LoadExtendedData(Db);
• IceTable:
Ice.Tablesets.TipTable iceTable = new TipTable();
…
iceTable.LoadExtendedData(Db);
• List<IceRow>:
List<IceRow> list = new List<IceRow>();
…
list.LoadExtendedData(Db);
• IceTableset:
Ice.Tablesets.TipTableset ts = new TipTableset();
ts.LoadExtendedData(Db);
This topic explains actions you need to take when you migrate UD Fields from Epicor ERP 10 Beta code prior to
10.0.600 into Epicor ERP version 10.0.600 or later.
Note You only need to perform the following steps if you are migrating from Epicor ERP 10 Beta prior to
version 10.0.600.
1. As part of the installation process, Regeneration of the Data Model is performed. This ensures the UD fields
are included in the data model.
2. The next step involves running mandatory BPM conversion. The conversion process upgrades BPM directives
to follow the new extended data approach.
3. After you log into the application, Epicor recommends to review the following:
• BPM directives that have become Outdated (as it is usual when upgrading from older builds)
• BPM directives that are known to contain UD Field references in queries or custom codes. It is highly
recommended to review these directive to ensure their performance is optimized in the new environment.
Example
• Previously for database queries a join between the extended table and base table was used, for
example:
Ice.Tip join Ice.Tip_UD on t.SysRowID = tu.ForeignSysRowID
The migration process is likely to convert such code as follows:
Ice.Tip join Ice.Tip_UD on t.SysRowID = tu.SysRowID
If the above code compiles, it is sub-optimal. Because the data model now merges Extended Table
columns with the respective base table automatically, you should refer to the Tip entity object only
to eliminate references or joins to Tip_UD altogether.
• Custom code performing [loop on Tip from the DB] with inner [loop on Tip_UD from the DB]
This code will be converted to [loop on Tip from the DB] with inner [loop on Tip from the DB]. The
most optimal way is [loop on Tip from the DB], however the body of the loop will need to be
adjusted.
4. When importing BPM directives referencing UD fields created in the code prior to 10.0.600, these directives
are also automatically converted and should be reviewed for optimal performance.
Certain calls that existed in Epicor 9.05 became obsolete in Epicor ERP 10. They need to be removed from the
source code or the converted code.
For example, you may have an Epicor 9.05 BPM directive that uses an ABL action with code that calls
lib\UpdateTableBuffer.p.
To avoid compilation errors when converting such directive, remove the below call from either the original source
code snippet, or from the converted code:
lib\UpdateTableBuffer.p
The BPM Migration Tool is capable of migrating most of the valid Epicor 9.05 ABL expressions.
To ensure a successful migration of expressions, verify the following:
• ABL expressions are functional in your Epicor 9.05 application.
• All tables, arguments and functions used in expressions are known.
Please consider the following information when selecting the approach for migrating external .p routines from
Epicor 9.05 to Epicor ERP 10.
In certain cases when Epicor 9.05 customizations contained many calls to external .p progress code files, it may
be reasonable to combine these .p routines into a single .NET assembly (library) of external methods. These
methods can then be called from within a BPM flowchart using the Invoke External Method BPM element.
You can also consider creating an external library, when you called a method in the Epicor 9.05 external .p file,
which subsequently invoked other methods within the same or different .p code files.
However, if the external .p contained simple code in one or few methods, it is recommended to convert such
code into a snippet and incorporate it into the BPM Execute Custom Code element, rather than creating an
external library assembly. Please note that this approach may be preferred as:
• It does not require .NET Visual Studio
• It does not require maintaining and updating external assemblies
The following section describes how to create a new project using the Visual Studio.
In the example below, the project utilizes the Update Method Directive for Tip Service.
1. Create an empty C# Class Library Type Project. In this example, we create the project called "ExternalBpm".
Note that the Ice.Contracts.BO.Tip is added, as we are going to make a call from Tip Update BPM Method
Directive.
Important Make sure to set "Copy Local=False" for all added references.
3. The project adds the Class by default. You can rename it, if you want. In this example, MyTip.cs is used.
1. In your Epicor EPM 10 application, open Method Directives. To do this, navigate to System Management
> Business Process management > Method Directives Maintenance.
4. The Programming Interface Generator Form window displays the method signature.
5. Copy the whole code (or method, if you already have other methods there).
6. Add your logic into the method and compile the project.
7. Place the library assembly file to the folder for external assemblies. Usually, it is the folder located within
the Server\Customization\Externals folder, but this setting can be changed in the application's
web.config, within the CustomizationSettings property.
8. You can now use this library and call it using the Invoke External Method workflow element.
The external Update method from ExternalBpm assembly will now be called by the BPM.
Tip For more detailed example, review the Custom Business Process Management chapter found
within the Epicor ICE 3.0 Tools User Guide.
If you have Microsoft® Visual Studio™ 2010 or higher, you can debug execution of custom code directives.
Debugging can be particularly useful when you need to review execution of a complex custom code.
Important This section provides details on how you can set up a debugging project. The example that
follows demonstrates how to debug the Tip.Update directive sample delivered by Epicor. In your environment,
you can apply the following steps on another directive. For more info on custom project debugging, see
the How to Modify Sample Project topic at the end of this section.
In your Epicor ERP installation, locate the BPM Sources folder. By default, Sources are found in the BPM folder
of the Server directory.
4. Extract the project folder from zip archive into the BPM > Sources directory.
Important Relative paths in the project file assume that the BPM subfolder is located directly under
the Server deployment folder. If this is not the case, change the relative paths manually from the Visual
Studio to point to the location of Server\Bin or server\Assemblies folders.
For the next step, open the downloaded project in Visual Studio.
The below sample project is configured for Tip.Update directive. Notice the following settings specific to the
Tip.Update sample:
• The contract for Tip service displays within references.
Use Method Directives to create a custom code directive for the Tip.Update Pre-Processing method.
In this sample a simple code checks if Tip Title is "A" and then updates the TipText with a string "Tip Text from
BPM".
4. Drag and drop the Execute Custom Code workflow item in the design area.
Note The folder may contains multiple revisions - take files from the latest one and copy them into
the project's TipUpdate folder.
The next step is to compile the project in Visual Studio and attach the debugger to the ASP process.
2. Set the breakpoint in the custom code found in the Tip.Update.cs file.
3. Start the Epicor ERP client and attach the debugger to the ASP process.
Fire the BPM and view the code execution in the debugger.
4. At this point the debugger stops at the specified break point and you can the follow code execution, examine
variable values and so on.
5. Based on the custom code defined in Method Directives, the BPM populates the Tip text value.
You can modify the sample project to debug another directive from another service.
Follow these steps to perform custom debugging:
• Create your custom directive.
• Create a new folder in the project similar to TipUpdate; based on the selected directive.
• Locate the sources generated by BPM and copy to this folder.
• Locate the assembly generated by the BPM and name the project assembly the same.
The assemblies generated by BPM are found in Server\Customizations\BO folder.
To add or subtract days from a given date field, use the syntax as displayed below. Note that subtraction is done
by adding a negative number of days
In the following example, 6 days are substracted from NeedByDate:
ttOrderHedRow.NeedByDate.Value.AddDays(-6)
Use the following syntax to subtract one date from another and then compare the number of days difference to
an integer value.
Difference and Days are variable names and can be replaced with any variable name of your choice.
var difference = DateTime.Today - PartTran.TranDate;
var days = difference.Value.Days;
if ( days > 90)
This topic discusses manual code adjustments after the Conversion Utility processes an ABL Find Last statement.
Assume the below statement exists in a BPM.
Now specify an OrderBy clause to sort the data. In this example, the last record becomes the first record in the
returned rows:
Within the BPM logic, it may happen that a variable is not set. In that case, the compiler displays an error message,
reporting use of an unassigned local variable.
Review the following example:
In many BPMs a user wants to perform a certain action if the tt record is a new record or updated record. In
Epicor 9.05 the status of the RowMod = 'A' or 'U' was used in this case. The Epicor 10 equivalent is displayed
below:
Informational messages are useful when debugging BPMs and presenting non-exception type messages to the
users.
You can publish an informational message to the user from the execute custom code node in the BPM designer.
The syntax example is shown below:
The last two parameters are optional, you can leave the strings empty.
Note that the possible values for message type are: Information, Question, Warning, Error, UpdateConflict. The
possible values for the InfoMessageDisplayMode are: Individual & Grid.
Example message was placed in vMiscInfo variable. Note that you should not use all capitalized "BPM" in the
reference to the Display Mode parameter, it should be "Bpm".
You should also add the using reference below in the BPM Designer > Usings tab:
using System.Data.Objects.SqlClient;
The syntax shown below can be used for BPMs that write data out to a file. You can create a new file as in the
example below, or replace Create with Append to append to an existing file.
The Upgrade Conversion Programmer's Guide recommends removing redundant scoping for database updates.
This is usually done due to the fact that the scoping in the BPM from the conversion tool will be promoted up
to the Method the BPM is associated with. The reason we do this is because we do not want anyone to be able
to update the record in the table before we do since we use optimistic locking and could run into concurrency
issues without it. If we are in a BPM on an update method, this scope may be promoted to the Update method
scope, but it is still a good idea to include them as good programming practice.
The example below shows how to scope the transaction for updating the InvcDetail_UD table's Number 01 field.
The Using statement starts the transaction, the Db.Validate statement does the update, and the txscope statement
ends the transaction. Note that the select query adds a With(LockHint.UpdLock) phrase to the select statement
for the table we are going to update (the InvcDtl_UD table in this example).
2.25 Sample of BPM calling a .p file and the final Epicor 10 version
Epicor 9.05, ABL Code was calling a .p file that called the UD14 business object and added certain data to it. In
Epicor 10, the BPM was modified to call the business objects and the .p code moved into the BPM's Execute
Custom Code action.
• Epicor 9.05 ABL Code:
In Epicor 9.05, it was possible to send emails via ABL code without using any of the BPM wizards. The same
functionality equivalent for Epicor 10 is shown below: