OTM CSV and UTF8 Encoding

I am dabbling in more Chinese character (中文) for OTM (Oracle Transportation Management). I hit an unusual issue when I try to upload Chinese Characters with csv file. The csv is generated from Excel macro VBA. Thanks to the various forums (OTMFAQ and stackoverflow), I managed to find the root cause on UTF encoding with BOM (Byte Order Mark).

Source: OTMFAQ

BOM is a 3 bytes in the beginning of the file when you save UTF-8 on Windows. If you generate the UTF-8, you can view the csv output encoding with TextPad++. OTM does not allow the upload of UTF-8 BOM file. It will just throw out an error, which is not friendly at all.

The solution to solve this is to convert the csv to UTF-8 without BOM. This will remove the first 3 Bytes from the beginning of the file. This can also be automated in macro with the following codes. Thanks to the solution codes from stackoverflow.


Public Sub PutTextFileUtf8(ByVal PathFileName As String, ByVal FileBody As String)

‘ Outputs FileBody as a text file (UTF-8 encoding without leading BOM)
‘ named PathFileName

‘ Needs reference to “Microsoft ActiveX Data Objects n.n Library”
‘ Addition to original code says version 2.5. Tested with version 6.1.

‘ 1Nov16 Copied from http://stackoverflow.com/a/4461250/973283
‘ but replaced literals with parameters.
‘ 15Aug17 Discovered routine was adding an LF to the end of the file.
‘ Added code to discard that LF.

‘ References: http://stackoverflow.com/a/4461250/973283
https://www.w3schools.com/asp/ado_ref_stream.asp

Dim BinaryStream As Object
Dim UTFStream As Object

Set UTFStream = CreateObject(“adodb.stream”)

UTFStream.Type = adTypeText
UTFStream.Mode = adModeReadWrite
UTFStream.Charset = “UTF-8”
‘ The LineSeparator will be added to the end of FileBody. It is possible
‘ to select a different value for LineSeparator but I can find nothing to
‘ suggest it is possible to not add anything to the end of FileBody
UTFStream.LineSeparator = adLF
UTFStream.Open
UTFStream.WriteText FileBody, adWriteLine

UTFStream.Position = 3 ‘skip BOM

Set BinaryStream = CreateObject(“adodb.stream”)
BinaryStream.Type = adTypeBinary
BinaryStream.Mode = adModeReadWrite
BinaryStream.Open

UTFStream.CopyTo BinaryStream

‘ Oriinally I planned to use “CopyTo Dest, NumChars” to not copy the last
‘ byte. However, NumChars is described as an integer whereas Position is
‘ described as Long. I was concerned by “integer” they mean 16 bits.
‘Debug.Print BinaryStream.Position
BinaryStream.Position = BinaryStream.Position – 1
BinaryStream.SetEOS
‘Debug.Print BinaryStream.Position

UTFStream.Flush
UTFStream.Close
Set UTFStream = Nothing

BinaryStream.SaveToFile PathFileName, adSaveCreateOverWrite
BinaryStream.Flush
BinaryStream.Close
Set BinaryStream = Nothing

End Sub


PS: Remember to include “Microsoft ActiveX Data Objects 2.5 Object Library” under Tools->References.

OTM Debugging

Today, I had spend 4 hours troubleshooting OTM (Oracle Transport Management) only to realise that the mistake was due to a change of Service Provider ID. This change was not updated in the Rate Offering. As such, the shipment planning was not able to pick up the rates. It was a very silly mistake and also shows the challenge of debugging in OTM. Anyone doing OTM will know the power of OTM debugging. Here are some debugging tips which could help anyone still doing OTM!

OTM Debugging Tips
  • Test often with each change of configuration. Use Agile to configure and test each change within a day.
  • Prepare a standard checklist for checking. This is important for Shipment Planning and rates setup.
  • Turn on your diagnostic log. It is more friendly than the log file.
  • Ask your OTM buddy for second opinion in your debugging approach. You may find new perspective.
  • Turn on your log files as last resort. The log file can either help you or discourage you. Go to the last page for the clues.

If you still unable to find the issue, rollback the change and configure your change again. This time, configure and test more aggressively. The key to debugging OTM is patience and practice. The only way is to get your hands dirty.

Agile TMS with DevOps

Unknowingly, I have spend more than 5 years with TMS (Transportation Management System) using OTM (Oracle Transportation Management) system. Overall, I enjoy the ease of configuration to deploy Agile solution using technique of DevOps. The control of global TMS solution also create high degree of adaptability for the team.

How to Agile your TMS
  • TMS have short transit window. It is favorable to adopt Agile.
  • Do design for change rather than design on sign-off requirements.
  • Configuration solution with custom plugins can cater for all TMS scenarios.
  • Determine your Agile components.
When to DevOps
  • DevOps complement Agile approach. This suits TMS because TMS contains many exceptions in the real world.
  • Use DevOps to close your loop in Agile implementation.
  • Consider to include monitoring tools or reports and analyse your data to determine your solution effectiveness.
  • TMS is usually 20% localisation. You may choose to DevOps on these localisation.

In summary, TMS needs a good product platform. You will also need to train your your TMS team to be Agile and DevOps ready.

OTM Object Locks

OTM (Oracle Transportation Management) Object locks have been my nemesis lately. You can see my past battles with refactoring and code quality. In migration or upgrades, direct copy of old packages from old to new domain often do not work as expected. Of course, you will only realise it when you hit object locks.

Signs of Object Locks
  • If you see very long PLSQL packages, it will mean the codes will take a while to travel from end to end. Any delay will lock object or tables giving the user a non responsive feel in the UI.
  • Many UPDATE SQL are seen in the agent or PLSQL.
  • Locks in Agent are used in Modified agent.
  • Copying of data from different objects like Shipment to OR (Order Release).
Tips
  • Removal of PLSQL packages in Agent and DSU (Direct SQL Update) to bare minimal, especially Modified Agents.
  • Reduction of codes in PLSQL. Delete or comment out old codes.
  • Reduce your UPDATE to a single point.
  • Add exception handling in your PLSQL to allow graceful exit of your PLSQL.
  • Conduct unit testing to each Agent or procedures before enabling them. If in doubt, remove them.

It is a painful process and huge amount of mandays are spend. Of course, lots of practice and hair tearing are done before you realise these tips. Hopefully, they are of help to those doing migration or upgrades of OTM.