Professional Documents
Culture Documents
Epicor10 C
Epicor10 C
Disclaimer
This document is for informational purposes only and is subject to change without notice. This document and its
contents, including the viewpoints, dates and functional content expressed herein are believed to be accurate as of its
date of publication. However, Epicor Software Corporation makes no guarantee, representations or warranties with
regard to the enclosed information and specifically disclaims any applicable implied warranties, such as fitness for a
particular purpose, merchantability, satisfactory quality or reasonable skill and care. As each user of Epicor software is
likely to be unique in their requirements in the use of such software and their business processes, users of this document
are always advised to discuss the content of this document with their Epicor account manager. All information contained
herein is subject to change without notice and changes to this document since printing and other important information
about the software product are made or published in release notes, and you are urged to obtain the current release
notes for the software product. We welcome user comments and reserve the right to revise this publication and/or
make improvements or changes to the products or programs described in this publication at any time, without notice.
The usage of any Epicor software shall be pursuant to an Epicor end user license agreement and the performance of
any consulting services by Epicor personnel shall be pursuant to Epicor's standard services terms and conditions. Usage
of the solution(s) described in this document with other Epicor software or third party products may require the purchase
of licenses for such other products. Where any software is expressed to be compliant with local laws or requirements
in this document, such compliance is not a warranty and is based solely on Epicor's current understanding of such laws
and requirements. All laws and requirements are subject to varying interpretations as well as to change and accordingly
Epicor cannot guarantee that the software will be compliant and up to date with such changes. All statements of
platform and product compatibility in this document shall be considered individually in relation to the products referred
to in the relevant statement, i.e., where any Epicor software is stated to be compatible with one product and also
stated to be compatible with another product, it should not be interpreted that such Epicor software is compatible
with both of the products running at the same time on the same platform or environment. Additionally platform or
product compatibility may require the application of Epicor or third-party updates, patches and/or service packs and
Epicor has no responsibility for compatibility issues which may be caused by updates, patches and/or service packs
released by third parties after the date of publication of this document. Epicor is a registered trademark and/or
trademark of Epicor Software Corporation in the United States, certain other countries and/or the EU. All other
trademarks mentioned are the property of their respective owners. Copyright Epicor Software Corporation 2014.
All rights reserved. No part of this publication may be reproduced in any form without the prior written consent of
Epicor Software Corporation.
Contents
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
Contents
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
Introduction
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.
This guide is available for download from the following locations:
Custom Code Conversion Utility > About section
ERP 10 Application Help under System Management > Business Process Management > Working With Business
Process Management section.
EPICweb Products > Epicor ERP version 10 > Documentation
Important This guide is not intended to be a C# tutorial, it only provides tips on how to make your custom
code work in the Epicor ERP 10 framework. It also provides recommendations on how to write code in
BPM custom actions.
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:
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.
3. You can now construct the code that calls a method from another assembly. For example:
C# Code:
10
Converted C# Code:
In this example, to fix the code above, remove the highlighted lines.
11
12
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.
13
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")
14
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);
15
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.
16
Note that the Ice.Contracts.BO.Tip is added, as we are going to make a call from Tip Update BPM Method
Directive.
17
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.
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.
18
8. You can now use this library and call it using the Invoke External Method workflow element.
19
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.
20
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.
21
22
23
Note The folder may contains multiple revisions - take files from the latest one and copy them into
the project's TipUpdate folder.
24
3. Start the Epicor ERP client and attach the debugger to the ASP process.
25
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.
26
5. Based on the custom code defined in Method Directives, the BPM populates the Tip text value.
27
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.
28
Now specify an OrderBy clause to sort the data. In this example, the last record becomes the first record in the
returned rows:
29
30
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".
31
You should also add the using reference below in the BPM Designer > Usings tab:
using System.Data.Objects.SqlClient;
32
33
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:
34
35
36
37