GXS AI: Tutorial, lesson 5

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.

  • Open example02S.mdl and example02T.mdl in your text editor and change appropriate values (highlighted with yellow):
    ;;; (locale=English_United States.Cp1252@Binary)
    ;;; (example01T.mdl)
    ;;; (version = 4.1)
    ;;; (type = TARGET)
    ;;; (access = OTFixed.acc)
    ;;; Written: 30.03.2010
    ;;; Modified: Wed Mar 31 11:40:26 MSD 2010
    ;;;     by user: Gennady Kim
    ;;; OmniTrans(tm) Interchange Format.
    ;;; (c) Copyright 1996-2000
    ;;;    RMS Electronic Commerce Systems, Inc.
    ;;; WorkBench 4.0 checksum = 1874344704
    ;;; 
    Comments { 
    [ ]
    ;;--------------------------------------------
    ;;* Modelname   : example01T.mdl
    ;;* Author      : Gennady Kim
    ;;* Date        : 30-Mar-2010
    ;;* Description : Original Issue
    ;;--------------------------------------------
    }*0 .. 1 ;; |-- end Comments --|

    Save and close.

  • Open Workbench, open example02.att and remove all the simple links we created. Just right-click on the line and select “Delete Link”:
  • Save both models (I hope you remember about it – I won’t be mentioning it anymore :))
  • Now let’s open our example02S.mdl in your text editor and try to understand its content:
    ;;; (locale=English_United States.Cp1252@Binary)
    ;;; (example02S.mdl)
    ;;; (version = 4.1)
    ;;; (type = SOURCE)
    ;;; (access = OTFixed.acc)
    ;;; Written: 01.04.2010
    ;;; Modified: Thu Apr 01 09:58:17 MSD 2010
    ;;;     by user: Gennady Kim
    ;;; OmniTrans(tm) Interchange Format.
    ;;; (c) Copyright 1996-2000
    ;;;    RMS Electronic Commerce Systems, Inc.
    ;;; WorkBench 4.0 checksum = 2883204726
    ;;; 
    Comments { 
    [ ]
    ;;--------------------------------------------
    ;;* Modelname   : example02S.mdl
    ;;* Author      : Gennady Kim
    ;;* Date        : 30-Mar-2010
    ;;* Description : Original Issue
    ;;--------------------------------------------
    }*0 .. 1 ;; |-- end Comments --|
    Initialization { 
    }*1 .. 1 ;; |-- end Initialization --|
    Document { 
    LIN { LineFeedDelimRecord  "LIN"
    LineItemID { AlphaNumericFld @12 .. 12  none 
    }*1 .. 1 ;; |-- end LineItemID --|
    Quantity { AlphaNumericFld @3 .. 3  none 
    }*1 .. 1 ;; |-- end Quantity --|
    UnitPrice { AlphaNumericFld @10 .. 10  none 
    }*1 .. 1 ;; |-- end UnitPrice --|
    ExpirationDate { DateFld @8 .. 8 "YYYYMMDD" none 
    }*1 .. 1 ;; |-- end ExpirationDate --|
    }*1 .. 100 ;; |-- end LIN --|
    }*1 .. 1 ;; |-- end Document --|

    The format is simple enough. There is the model description in the beginning of the file. Every string there starts with a semicolon “;”. It’s the comment symbol, i.e. everything after “;” is commented out and won’t be executed.

  • So, ignore the commented part of the file and try to compare the rest with the source model opened in Workbench:
    Maybe you already have a guess how the structure is described. AI uses “{” and “}” to organize the hierarchical structure. Child elements are placed inside {…} of the parent element. Let’s me change the code a little to make it more obvious and clear:

    Comments { 
    }*0 .. 1 ;; |-- end Comments --|
    Initialization { 
    }*1 .. 1 ;; |-- end Initialization --|
    Document { 
    	LIN { LineFeedDelimRecord  "LIN"
    		LineItemID { AlphaNumericFld @12 .. 12  none 
    		}*1 .. 1 ;; |-- end LineItemID --|
    		Quantity { AlphaNumericFld @3 .. 3  none 
    		}*1 .. 1 ;; |-- end Quantity --|
    		UnitPrice { AlphaNumericFld @10 .. 10  none 
    		}*1 .. 1 ;; |-- end UnitPrice --|
    		ExpirationDate { DateFld @8 .. 8 "YYYYMMDD" none 
    		}*1 .. 1 ;; |-- end ExpirationDate --|
    	}*1 .. 100 ;; |-- end LIN --|
    }*1 .. 1 ;; |-- end Document --|

    Is it clear?
    As I wrote before, professional GXS AI developers usually don’t use Workbench – they use a texteditor for changing the models. So, I believe you’ll start using your text editor for working with your maps, sooner or later. But in my lessons we’ll be using Workbench.

  • Now let’s continue. In the source document open the LIN record, open the Rule Builder and put the following code there:
    [ ]
    ARRAY->LineItemID_LineItemID = STRTRIM(LineItemID, "B", " ")
    ARRAY->Quantity_Quantity = STRTRIM(Quantity, "B", " ")
    ARRAY->UnitPrice_UnitPrice = STRTRIM(UnitPrice, "B", " ")
    ARRAY->ExpirationDate_ExpirationDate = STRTRIM(ExpirationDate, "B", " ")


    What does this code mean?

    • ARRAY->LineItemID_LineItemID = … – we put some value into an array. The array’s name is “LineItemID_LineItemID”. We don’t need to initialize the arrays unlike variables. You can use your own array name, here LineItemID_LineItemID means that it will be used to translate data from LineItemID field of the source document into LineItemID field of the target.
    • STRTRIM(LineItemID, “B”, ” “) – we trim (remove extra spaces from the beginning and the end in this case) the data from the LineItemID field (as always, you can find the function’s description here D:\Trandev\WBHelp_en\FunctionCodes\FunctionCodes.htm)
    • LineItemID in STRTRIM(LineItemID, “B”, ” “) means that we use value, stored in this field.

    So, every time the translator reads the LIN record in the source document, it will take the data from the fields and put it into appropriate arrays.

    BTW, we can put this code into every field instead of the record, i.e.
    LineItemID:

    []
    ARRAY->LineItemID_LineItemID = STRTRIM(LineItemID, "B", " ")

    Quantity:

    []
    ARRAY->Quantity_Quantity = STRTRIM(Quantity, "B", " ")


    and it will work perfectly as well. But it’s better and more professional to put the code “as “high” as you can”, i.e. into the parent element.

  • In the target structure put the following code into every field (except the LineNumber – there is our code from previous lesson):
    LineItemID:

    []
    LineItemID  = ARRAY->LineItemID_LineItemID

    Quantity:

    []
    Quantity = ARRAY->Quantity_Quantity

    … and so on.

    As you can guess, we put values into the arrays in the source model and take them out in the target.

  • VERY IMPORTANT: every time we take value from array, the translator sets cursor to the next position.
  • Now, let’s try to test the “new” map. Run Test->Translate. Open our previous example01 and change it to example02. Click “Save” (it creates a new test, not overwrites previous one). Select the parameters one by one, change 01 to 02 and click “Add” every time:

    Save the test. Create TestData in our example02 and copy in.txt and sample_output.txt there. Translate:

    010010123456789120000125,9905004/12/10
    010020123456654370000025,0015008/31/10
    010036678456789140000012,0025004/16/10
    010049923456789150000005,7510005/19/10

    And it’s right!

Gennady Kim

Advertisements

19 thoughts on “GXS AI: Tutorial, lesson 5

  1. Our TP said that he will send EDI documents over FTP or HTTPS to our system. I have GXS AI 5.3 but I can\’t find any connectivty settings in it. Can it not be used alone for communication?

      • Does it mean that we have to purchase some other software to enable this communication and route them to AI 5.3?

      • architecture depends on different parameters. If your TP supports FTP, you can use something like WinSCP + cmd + windows job for example for sending/receiving files

      • I think I was not clear earlier. I mean to ask what is there to do after we receive EDI file from a TP. Assume we have fetched the file using any automated FTP client. My real question is how does control server of GXS 5.3 recieve incoming documents?

      • you’re asking about “how to make GXS translate files on the FileSystem from one format into another”, right ? I don’t remember details now, but we setup TP first and then used inittrans executable with different keys to process files. Depending on the keys it did enveloping/deenveloping and translation, and put output files into appropriate folders. But I don’t remember details – I was working on maps and didn’t work with communications/jobs and so on. I knew how to create maps/setup TPs/create bat file for command-line translations – that’s all.

  2. Kim,

    I have just seen your blog and I see it pretty interesting. Thanks for all your efforts in putting these documentation which is used a ready reckoner for any person who works on AI.

    Nab,

    Whats the architecture of GXS AI in your company. You have GXS Enterprise ? what exactly you are using along with GXS AI.

    Thanks
    Nandu

    • Nandu, I have bee developing solution with Sterling Integrator, no prior GXS experience. Now I am trying to get my hands on GXS SI. I am using LexiCom to get data from partner’s FTP and to send them. But I am not sure how GXS can pick/save EDI messages from file system. That is my main concern now?

      Also, there is no business process modeling/orchestraion designing interface available in GXS AI. How the workflows are modelled in it?

      • Nab,

        So you are using Lexicom FTP to connect to your Trading Partners and pull the data from their server that is fine , so now after pulling the file you want to automate the files to send to specific map and translate it right?

        If the above scenario what I am assuming is true then I want to know are you using the GXS Enterprise system which can be used to automate.

        Let me know exact architecture you have then I can guide you more.

    • Nab,

      So if you dont have GXS Enterprise , I guess you can automate by using the Scheduler option in Trade Guide under Administration tab. I have never used it but I am sure we can use it. my email id : nanduedi@gmail.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s