Friday, May 17, 2013

Replace a schema in a map: the easy way

We had a little problem on the first day in production of an EDI project, when our partner says they have to send their orders in EFACT_D96A_ORDERS_EAN008, instead of the EFACT_D93A_ORDERS_EAN007 we tested for months. Not a big stress. Those schemas are similar, so the change was easy.

To redo a map like this one and properly test it in the same day, was impossible. But the task was simplified in the fastest way. No XSLT knowledge needed, just basic XML and logic.

Supposing the change is in the input

1. Add the new schema or reference to the project.

2. Open the btm as xml.

3. Find and replace all references
3.1. Source Tree Root Node and Location

<SrcTree RootNode_Name="EFACT_D93A_ORDERS_EAN007">
<Reference Location="*.EFACT_D93A_ORDERS_EAN007" />
3.2. Some on the Link elements (LinkFrom attribute).

<Link LinkID="9" LinkFrom="10" LinkTo="/*[local-name()='<Schema>']/*[local-name()='ORDERS01']/*[local-name()='E1EDK03']/*[local-name()='DATAHEADERREC']/*[local-name()='DOCNUM']" Label="" />
        <Link LinkID="10" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='EFACT_D93A_ORDERS_EAN007']/*[local-name()='DTM']/*[local-name()='C507']/*[local-name()='C50702']" LinkTo="9" Label="" />
        <Link LinkID="11" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='EFACT_D93A_ORDERS_EAN007']/*[local-name()='DTM']" LinkTo="11" Label="" />

4. Close the xml view and open the same .btm with the regular view.

4.1. If no Map Loading Errors popped up, it’s done.
4.2. Otherwise, keep following the procedure.

5. Copy all the errors (no Ctrl+A here, just the old mouse dragging).

(1) Link from Source Tree Node with XPath: '/*[local-name()='']/*[local-name()='EFACT_D96A_ORDERS_EAN008']/*[local-name()='LINLoop1']/*[local-name()='QTY_3']/*[local-name()='C186_3']/*[local-name()='C18601']' to Equal functoid (with FunctoidID: 30).

6. Close the errors screen but DO NOT save the map.

7. Locate the missing field and take note of the correct path
In this case there was no EFACT_D96A_ORDERS_EAN008/LINLoop1/QTY_3/C186_3/C18601 , but instead, EFACT_D96A_ORDERS_EAN008/LINLoop1/QTY_2/C186_2/C18601

8. Close the map (don’t save!) and open again with the xml view.

9. Replace those fields. [local -name()='QTY_3']/*[local-name()='C186_3'] to [local-name()='QTY_2']/*[local-name()='C186_2']. In case of doubt, use the FunctoidId or any additional info from the errors screen to locate the Link Id.

10. Repeat from step 4 until all the errors are gone.

Changes in Destination schema are in TrgTree instead of SrcTree, and LinkTo instead of LinkFrom.

Please note that this is only an advanced starting point. If the schema was replaced, probably it was because the previous one no longer supported the information needed. It’s very likely new fields are filled and some others have changed, including the ones used within the map. A new batch of tests will show it very quickly.

Extra: Two orchestrations sharing a receive port

If they enter by the same port, use the Message property to receive only one of them.
If they arrive by Direct Binding –independently of the port, from the MessageBox - use the Filter Expression.

Be careful with:

  • Typename
    Don’t give the same name to both. Not only it is unauthorized, but also is the name by which the orchestrations will be known after deployment and so should be different for whoever is managing.
  • Ports types
    The Orchestration 2 will try to create a port type that already exists. Delete the Operation on every port and configure to use the type from Orchestration 1. If the input message is different (source schema changed) the receive port will have a different type. The same goes for the output message (when the target schema changed) at the send port.
  • Tuesday, February 26, 2013

    Code. Just Code.

    Fabulous work of promotion to the programming science/art.