Epicor ERP C# Programming Guide (conversion from ABL) 10.2.100 Disclaimer This
Epicor ERP C# Programming Guide (conversion from ABL) 10.2.100 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 2017. All rights reserved. Not for distribution or republication. Information in this document is subject to Epicor license agreement(s). 10.2.100 Revision: December 04, 2017 12:32 a.m. Total pages: 57 sys.ditaval Contents Introduction............................................................................................................................5 ERP and ICE Tables..................................................................................................................6 Case Sensitivity.......................................................................................................................7 Case Sensitivity in String Comparisons.............................................................................................................7 Compilation Errors...........................................................................................................................................7 Calling Method From Business Object..................................................................................9 Calling BOs From Custom Code...........................................................................................10 Calling Method From Standard Assembly..........................................................................11 Accessing ERP Context From Within System Directive......................................................12 Displaying an Informational Message................................................................................13 Throwing Exceptions............................................................................................................14 Writing Messages to Log.....................................................................................................15 Compatibility Class...............................................................................................................16 Replacing Resulting Dataset................................................................................................17 Redundant Transaction Scope.............................................................................................18 BufferCopy Considerations..................................................................................................19 Working With Custom Data.................................................................................................20 Create User-Defined Fields.............................................................................................................................20 Access User-Defined Fields.............................................................................................................................22 Loading User-Defined Data Into Various Objects............................................................................................23 Transition Path...............................................................................................................................................23 Obsolete ABL Code...............................................................................................................25 Migrating ABL Expressions..................................................................................................26 Using External Libraries.......................................................................................................27 Create Project in Visual Studio.......................................................................................................................27 Call External Assembly Using BPM..................................................................................................................28 Debugging Using Visual Studio...........................................................................................31 Prerequisites..................................................................................................................................................31 Debug BPM Directive.....................................................................................................................................31 Debug Custom Project...................................................................................................................................34 Adding and Subtracting Date..............................................................................................37 Subtracting Two Dates and Comparing to an Integer Value............................................38 ABL Find Last Conversion.....................................................................................................39 Using Unassigned Local Variable Message.........................................................................40 Epicor 10 Equivalent to Row Mod = A or U........................................................................41 Converting a Number to a String in LINQ Expression........................................................42 Outputting Data to a File.....................................................................................................43 3 Epicor ERP | 10.2.100 Contents C# Programming Guide (conversion from ABL) Updating Database Tables...................................................................................................45 Sample of BPM calling a .p file and the final Epicor 10 version........................................46 Sample of a BPM That Sends an Email................................................................................50 Querying the Database........................................................................................................51 Setting a Value on the Payload...........................................................................................52 Calling Methods in the Same Service..................................................................................53 Calling Other Services..........................................................................................................54 Using RowMod.....................................................................................................................55 Naming Conventions in BPM Sources.................................................................................56 Epicor ERP | 10.2.100 4 C# Programming Guide (conversion from ABL) Contents Introduction This guide describes common C# code patterns used in typical Epicor ERP processes. The main perspective of the guide is aimed at ABL code users from previous Epicor ERP releases. The guide describes the Custom Code Conversion Utility that converts snippets of Progress ABL code to .NET C# language used by the Epicor ERP 10 framework. However, ERP users that have only ever used the ERP versions 10 and later can also benefit from seeing the C# examples in this guide. This code is used in BPMs and in customization. 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. 5 Epicor ERP | 10.2.100 Introduction C# Programming Guide (conversion from ABL) ERP and ICE Tables 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; Epicor ERP | 10.2.100 6 C# Programming Guide (conversion from ABL) ERP and ICE Tables Case Sensitivity This section deals with usage of case sensitivity in C# language. Case Sensitivity in String Comparisons 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 Compilation Errors 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. var CustomerRecs = (from r in Db.customer from r_UD in Db.Customer_UD where r.SysRowID == r_UD.ForeignSysRowID && r.Company == Session.CompanyID && r.CustNum == ttOrderHedRow.CustNum select r_UD).FirstOrDefault(); This query will cause the following error message when you try to compile the BPM: 7 Epicor ERP | 10.2.100 Case Sensitivity C# Programming Guide (conversion from ABL) 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: var CustomerRecs = (from r in Db.Customer from r_UD in Db.Customer_UD where r.SysRowID == r_UD.ForeignSysRowID && r.Company == Session.CompanyID && r.CustNum == ttOrderHedRow.CustNum select r_UD).FirstOrDefault(); Epicor ERP | 10.2.100 8 C# Programming Guide (conversion from ABL) Case Sensitivity Calling Method From Business Object In some cases, you need to call a method from a business object (BO). For this purpose, use the ServerRenderer and add a reference to the contract containing the particular business object. ServerRenderer is a helper class residing in Epicor.System.dll. You can use this class to make calls to any application service with the defined contract. This class returns an instance of the contract, which you can use to invoke any method available on the contract. The signature of the method is displayed below: /// <summary> /// Returns a class instance for the given contract /// </summary> /// <param name="ignoreFacade">if set to <c>true</c> method returns instance of service instead of service facade. </param> /// <typeparam name="TService">The contract type. The contract must have a Serv iceContract attribute and the service namespace must follow the Ice naming conv ention </typeparam> /// <returns>A class instance for the given contract </returns> public static TService GetService<TService>(bool ignoreFacade = false) 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. var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.TipSvcContrac t>(Db); svc.GetByID(…); If within one code scope uploads/s1/ convertedcode-programmingguide.pdf
Documents similaires
-
100
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Nov 22, 2022
- Catégorie Administration
- Langue French
- Taille du fichier 1.0916MB