Best Practices - Developing Processes
The purpose of this document is to provide best practices when developing processes.
When you add a process to a data class or to a representation class, Sage X3 displays the default code, which starts with the class code. It is recommended to use the default code and follow the same convention for any other process files. This makes it easier to find all processes for a particular data class or representation class.
Make sure you use meaningful names for the subroutine and function names. Prefix them with the name of the child class they are related to.
Make sure you add comments (in English) to explain your code.
Make sure you define all variables in your functions and subroutines as local. Do not define any global variable.
Error handling must be carried out using the ASTATUS variable and the ASETERROR method.
Example:
[L]ASTATUS=Fmet ASETERROR("AMOUNT","the amount has been successfully updated", [V]CST_AINFO)[L]ASTATUS=Fmet ASETERROR("MYPROP","The value of MYPROP is exceeding a usual value", [V]CST_AWARNING)[L]ASTATUS=Fmet ASETERROR("","Global inconsistency for the class xxx", [V]CST_AERROR)[L]ASTATUS=Fmet ASETERROR("","A fatal error occured", [V]CST_AFATAL)
Use standard constants to make the code easier to read. Refer to the Constants Developer Guide.
Goto
" in your code.Make sure you indent your code to make it easier to read.