Archive

Archive for March, 2010

Tweaking Oracle B2B CONTRL

Oracle B2B supports EDIFACT and can of course generate CONTRL messages out of the box. However, by default in some versions a generated CONTRL message will not contain routing address or reverse routing address. These fields are also known as sub-addresses and are part of the interchange sender and recipient, as shown in the figure.

Interchange header with routing address in SpecBuilder

Interchange Header in SpecBuilder

For example, if an inbound message has the interchange sender 9990022:ZZ:XYZ the generated CONTRL contains 9990022:ZZ, both in the UNB and UCI segments. That is clearly a problem. Luckily it is easy to fix.

First of all set oracle.tip.adapter.b2b.edi.FAInternalProperties=true in $ORACLE_HOME/ip/config/tip.properties. Second, edit $ORACLE_HOME/ip/oem/edifecs/XEngine/config/AckCode-CONTRL.xml. Backup the original file and add:


<CodeList Name="InternalPropertyList">
 <Code Key="InterchangeReceiverID" Value="InterchangeSenderID"/>
 <Code Key="InterchangeReceiverQual" Value="InterchangeSenderQual"/>
 <Code Key="InterchangeSenderID" Value="InterchangeReceiverID"/>
 <Code Key="InterchangeSenderQual" Value="InterchangeReceiverQual"/>
 <Code Key="InterchangeSenderInternalID" Value="InterchangeSenderInternalID"/>
 <Code Key="InterchangeReceiverInternalID" Value="InterchangeReceiverInternalID"/>
 <Code Key="GroupReceiverID" Value="GroupSenderID"/>
 <Code Key="GroupSenderID" Value="GroupReceiverID"/>
 <Code Key="InterchangeReceiverAddress" Value="InterchangeSenderAddress"/>
 <Code Key="InterchangeSenderAddress" Value="InterchangeReceiverAddress"/>
</CodeList>

The lines with InterchangeSenderInternalID and InterchangeReceiverInternalID will do the trick. Restart B2BServer and everything should work.

Categories: B2B

Thoughts on JSR-310

2010-03-07 1 comment

The JSR-310 API recently entered early draft review. Will Java get a decent date/time API at last? See for yourself at http://wiki.java.net/bin/view/Projects/DateTimeEDR1. My thoughts are summarized here.

Some parts look promising. The API uses immutable objects, which is good! It provides aptly named methods for all fields, for example getYear, and for arithmetic, for example plusDays and minusHours.

Some parts are a bit complex, though. So is the subject matter, but still. Simple parsing and formatting seem to be a bit involved unless you can use one of the pre-defined formats. Ideally there should be toString and valueOf methods with format strings, simple and easy to work with for the basic cases.

There should be a common interface and comparisons/operations that take mixed types. LocalDate should certainly be comparable with LocalDateTime (pick midnight) and preferably with ZonedDateTime as well (default time zone). Ideally the older types, at least java.util.Date, should be usable as well.

Clock is documented as throwing UnsupportedOperationException for withZone. Why? Assume the (not uncommon) use case where a web application has users from all over the world and matches the active user’s time zone. Naturally it will not use the system time zone. In general I don’t like methods to throw UnsupportedOperationException. If an operation is optional, push it down to a sub-class or use a different interface and make it clear what is available and what is not.

The TimeSource, which seems to be intended for low-level operations, uses milliseconds according to the documentation. It could use nanoseconds instead or as well. Instant itself has nano-second support, so the API in general is fine.

Last but not least, look into performance! Calendar is often a tight spot. Make the common operations, like construction and date arithmetic, run fast.

Categories: Java

Find and replace in clobs

It can often be a bit tricky to work with clobs. The normal replace string function doesn’t support them, so Today I spent some time writing my own version. Shortly afterwards I happened upon another built-in function that does the job: regexp_replace. For example, regexp_replace(a_clob, '[' || chr(10) || chr(13) || ']', '') removes all newlines (carriage returns and line feeds).

Only the first argument (the text) has full support for clobs, the expression and substitution string are both limited to 32k. I can’t really see where that would matter, though.

Categories: Database, Oracle