Friday, July 12, 2013

Creating a SPEXXX File in Sage ERP X3


If the SPEXXX program was not found, you can create it in editor.    However, after you compile the program, you must exit out of the X3 client before your changes will be recognized.    If you do not exit the program, then your SPE code will be ignored.   This only applies to the first time you create the SPE program.  After the SPE program has been created, you can make changes to the program without exiting again.

Deleting A SPEXXX File

Use caution if you need to delete a SPE program that you have created.  The reason is that if there are others are in the system, deleting the SPE file can create errors for the users.  You may think that deleting a program that you created would put the system back in its original state and therefore your bugs would be eliminated.   However, this is not the case because the users sessions running on the server will keep the last copy of the SPE file buffered in memory.  Therefore if you delete a SPE file, all users in a folder that accessed the SPE file must exit Sage ERP X3 to ensure the bug is eliminated.

David Padgett
President
Golden Lab Software, Inc.
http://www.goldenlabsoftware.com

Sage ERP X3 Phone Extensions

The following are instructions for formatting phone numbers in Sage ERP X3 to allow phone extensions:

  1. In the Country task under Common Data>Common Tables, select the country code.  In my case, this would be the US.
  2. Edit the default telephone format.  This can be found on the details tab.  By default, the US format is 10 digits represented by the "#" sign.   The "[-]" formatting symbols indicate that a dash will be added to the phone numbers when displayed.
In the US, there is no standard on which extension prefix to use.   Below are 3 common formats:

555-555-5555 ext 555      format:   ###[-]###[-]####[ ext ]###
555-555-5555 x55555      format:   ###[-]###[-]####[ x]###
555-555-5555  55555       format:   ###[-]###[-]####[ ]###

The problem with the first 2 formats above are that the extension prefix character (ie. "ext","x") will always show regardless of whether the number you have entered has an extension.  

Example:    555-555-5555 ext

That is why the format show below is preferable:


Once you save you change above, the phone extension will be immediately available throughout the system.





David Padgett
President
Golden Lab Software, Inc.
http://www.goldenlabsoftware.com

Conditional Break Point in Sage ERP X3

Note: The following advice is for the basic debugger in X3, not the Eclipse debugger.

Often in Sage ERP X3 customizations, you will find yourself debugging trying to determine which action or subprogram is setting or changing a screen value.  In most programming languages, this would be a simple task.   You would simply set a watch and place a breakpoint on it.   Unfortunately, the default debugger in X3 does not allow you to set breakpoints on watches.   The code below shows a way to quickly pause execution in your SPEXXX program only when the screen value changes.   This code has saved us hours of tracing through the X3 code.

$ACTION

#Set Error Trap in case the global variables are not defined
Onerrgo ERROR_GLOBAL_DEF

#If the field value is different from last time, then suspend
If clalev([M:MSK]) and [M:MSK]SOMEFIELD <> GLASTVALUE
    Dbgaff
   #While suspended, in Debugger check the value for the following variables:
   #GLASTACTION - This will contain the action that caused the field value to change
   #GLASTVALUE   - This will contain the value before it was changed
   #[M:MSK]SOMEFIELD - This will contain the new value for the field
Endif

#Save the current action and field value.  The will be used the next time $ACTION is called
GLASTACTION = ACTION
GLASTVALUE   = [M:MSK]SOMEFIELD
Onerrgo

#Run the default code in SPEXXX and SUBXXX
Case ACTION
 When Default
Endcase
Return

#########################################################################
$ERROR_GLOBAL_DEF
#########################################################################
#If we are hitting this error, then it is assumed that these global variables are not defined
Global Char GLASTACTION
Global Char GLASTVALUE
GLASTACTION = ""
GLASTVALUE   = ""
Resume
Some quick notes:
  • Change [M:MSK] and SOMEFIELD to be the screen mask and field that you wish to track
  • Clalev() is the only function that we have in X3 for checking for a field's existence.  However, Clalev() does not work correctly on global variables.  That is why the Error Trap was used in the code above to declare the variables.   If you declare these variables before this program is called, then the error trapping is not required. 
  • Of course, you would not keep this code in the production system.   Just in case you forget to remove it, I recommend placing an "IF guser = "MYID"" condition around this code. 
  • If you have a better way of handling these breakpoints, please share here.