How to Import an XML report into Sage X3

By: | Category: ERP

When writing code for Sage X3, alphanumeric variables must be declared with a size, otherwise the number of characters will be defaulted to 30; causing unexpected behavior, specially when a bigger variable is required.

One of the many benefits of using Sage X3 is that it is extremely configurable. Users with the appropriate rights can manually change the length. No need to go in the lines of code to change some parameters like the size of a data type. You can successfully increase the number of the decimal places in the price screens for example without having to touch the logic.

For example, the supplier data type BPS is 15 characters in length

How to Import a XML report into Sage X3

When a variable is required for a supplier, the variable could be declared like this:

Local Char YBPSNUM(15) #Supplier


The product data type ITM is 20 characters in length:

How to Import a XML report into Sage X3

When a variable is required for a product, the variable could be declared like this:

Local Char YITMREF(20) #Product

In the examples above, the code will not work properly if any of those data types is changed to a bigger number of characters, a scenario that we have encountered with some of our clients.

Imagine wanting to increase the number of characters authorized for the length of the product code. A modification seemingly innocent, that would nonetheless require to review ALL the places in the code where the length of the product code was declared as above. Every single screen and reports would need to be reviewed and tested.


The solution to the problem described above is to use GLON variables. These variables have this format: GLONXYZ, where XYZ indicates the related data type (it will only work if the data type is the main key to the object).

GLON variables are available for any object defined in the system.

Below we can see the proper way of defining the variables in the code, so any change in the data type length is accounted for.


Replacing ITM with another data type abbreviation, this will work for all other alphanumeric data types as well.

The GLON variables are global variables maintained internally by X3. The name of each one starts with GLON and ends with the abbreviation of the corresponding alphanumeric data type. So for the ITM data type the corresponding GLON variable is GLONITM. The value of each GLON variable is the length of the corresponding data type. This value is updated on data type validation, so even if you customize your data type lengths or they change between versions, the GLON variable is guaranteed to hold the correct value.

For more information about importing XML reports into Sage X3, please contact us.