GXS AI: How to debug maps

I believe every GXS AI map developer knows how hard it might be to debug maps. I’m using SEND_SMSG function when I need to debug a piece of code

First of all, I’m using .bat files to run my maps

otrun -at %MAP_NAME%S.att -cs %OT_QUEUEID% -DLOCALE="English_UnitedStates.Latin1@Binary" -DINPUT_FILE=%BASE_PATH%__in.txt -DOUTPUT_FILE=%BASE_PATH%__out.txt -tl 1023 -lg _log.txt -I


this key “-lg _log.txt” tells the translator to use _log.txt for the translation session output. So, every time I’m using SEND_SMSG it writes it’s 1+ params into _log.txt. For example:

...
SEND_SMSG(1, STRCAT("GID_21_BALQTE_BSD_02_02_2002: ", VAR->GID_21_BALQTE_BSD_02_02_2002_T))
...

And in _log.txt:

Session [003407] Started: at: Sat Jul 25 09:03:04 2012
--GID_21_BALQTE_BSD_02_02_2002: AAA
--GID_21_BALQTE_BSD_02_02_2002: BBB
Session [003407] ended: err: 0 at: Sat Jul 25 09:03:04 2012

…As always, just an idea 🙂

As you probably know, often GXS AI developer use 3rd party editors when working with the models (instead of Workbench). My colleagues use Notepad++ with a “plugin” (User Defined Language) developed by Igor Nechaev:

it highlights used constructions, allows to to collapse/expand blocks of code, helps you to comment/uncomment blocks of code and so on.

Here is the code of this “plugin” (User Defined Language):

GXS AI: NUMTRIM from an emtpy string

We’ve just found that NUMTRIM function works in a different way on different environments.

On our local servers (4.1, 5.0 and 5.2 on Windows) NUMTRIM(“”, 0) returns 0, but on another machine (I believe on Unix) it returns garbage (and no error message)

GXS AI: models analyzer

As I wrote before, I’m often trying to use/create some tools/scripts which helps me to do different things – build the test data, compare outputs or check the models. For example when I was working a lot with GXS AI I created a tool which showed me the list of the variables and arrays used in the maps + some “assumptions” (for example, if a variable is not used). Also, it generated a code to check all the arrays (they all should be empty at the end of the translation). It helped us to keep the maps clean. There is no Print to File option in GXS AI Workbench (like Sterling’s MapEditor has) so often it was hard to see the whole picture, especially when the map contained hundreds or thousands lines.

Such tool would also help you to migrate maps from GXS AI to Sterling GIS/SI (or another EAI) and back.

Here are some screenshots just to give you an idea:

Variables (and Arrays)

In this lesson we’ll see how to use variables and the difference between variables and arrays.

It’s time to start working with more complex structures which are more similar to the “live” documents. We’ll be using our map “example02” we created on previous step as the base. Let’s change it.

First of all, we need to change the structures of both source and target documents. In the real life documents usually contain three main parts (blocks of data):

• Header. This block usually contains the document number/date, addresses and so on – the common information.
• Details. Usually there some kind of a repeatable data (Line Items and their IDs, names, quantity, price and so on)
• Summary section. This block contains all the total amounts, taxes/fees, total quantities and so forth. This section is very similar to the Header section, but often it is placed at the end of the document to emphasize its “summary” role (like you can see in the paper documents).

Arrays of data

In this lesson I’ll introduce you a concept of arrays in GXS AI.

Our first map we created on previous lesson is pretty simple. Both source and target have almost the same structure, only one type of records and a few fields. In real life such maps are very seldom. So, we need to gradually work on more and more complicated maps. Let’s get started!

• Create a folder example02 in D:\Trandev\models\
• Copy example01.att, example01S.mdl and example01T.mdl from our previous lesson into this new folder.
• Rename the files to example02.att, example02S.mdl and example02T.mdl respectively.
• Open the content of example02.att in any text editor (such as Notepad) and change it to:
;;                                   example02.att
;;                                    ver 4.0
;;                                --------------
S_ACCESS = "OTFixed.acc"
S_MODEL = "D:\Trandev\models\example02\example02S.mdl"
T_ACCESS = "OTFixed.acc"
T_MODEL = "D:\Trandev\models\example02\example02T.mdl"

Save and close.

GXS AI WorkBench/TradeGuide and Java compatibility

If GXS AI WB/TG (at least 4*) don’t work with your version of Java (you have 1.4 instead of 1.5), try to open
D:\Transdev\WBSystemConfig.properties
D:\Transdev\TGSystemConfig.properties
and change

[JVM PARA]
JVM_VERSION_MAJOR_REQUIRED = 1.5
JVM_VERSION_MINOR_REQUIRED = X_XX

to

[JVM PARA]
JVM_VERSION_MAJOR_REQUIRED = 1.4
JVM_VERSION_MINOR_REQUIRED = X_XX

Testing the map

1. Save the map.
2. Select Test->Translate in the top menu.

3. In the opened window enter the following values, clicking “Add” every time you add a new pair:
• Variable Name: S_MODEL, Variable Value: D:\Trandev\models\example01\example01S.mdl
• T_MODEL, D:\Trandev\models\example01\example01T.mdl
• INPUT_FILE D:\Trandev\models\example01\TestData\in.txt
• OUTPUT_FILE D:\Trandev\models\example01\TestData\out.txt