This section covers mapping binary data for data transformation to and from an application field.
The BIN segment, as mentioned earlier, can have a rather impressive length. A new segment BDS has been introduced to transmit binary data in X12V4R4, transaction 102 (Associated Data).
The binary data is identified with a BIN or BDS segment ID, which notifies the parser that data following the segment ID is binary. Although the parser must always treat the BIN and BDS segments as if it contained binary data, the segment can contain normal text.
The first data element of the BIN segment contains the length of the binary data so that the parser knows the amount of data to pass without interference.
The second data element of the BDS segment contains the length of the binary data so that the parser knows the amount of data to pass without interference.
The first character after the binary data should be BIN or BDS segment terminator. Any other value is a syntax error that ends parsing for the envelope.
The BIN and BDS segment IDs triggers the special binary processing.
Although using a file name is the primary way of providing data for a binary Segment, with data transformation maps you provide the data by simply passing it to WebSphere Partner Gateway in application fields, the way all other application data is passed. The binary data itself must be defined in the Data Format with a data type of BN. The application may provide the length of the binary data If the length of the binary data is not provided by the application the length will be the length of the application data field defining the binary data.
However, WebSphere Partner Gateway has a maximum length of 32767 bytes for application fields, which is significantly less than the 999,999,999,999,999 defined by the standard or the 2,147,483,547 that WebSphere Partner Gateway allows. WebSphere Partner Gateway knows that it is dealing with binary data, and that some special processing is needed to put it into a BIN or BDS segment. The easiest way to pass this binary data to WebSphere Partner Gateway is with a data format such as:
BINARY_LOOP1 999 Repeating loop
BINARY_STRUCTURE1 Record
LENGTH N0 15 15-byte length field
BINARY_DATA_LOOP 99 Repeating loop
BINARY_DATA1 Record
BINARY_FIELD BN 32767 Binary data field
Both BINARY_STRUCTURE1 and BINARY_DATA1 are passed separately records.
Now the application provides WebSphere Partner Gateway with a BINARY_STRUCTURE1 and as many BINARY_DATA1 records as necessary to satisfy the length specified in the LENGTH field. WebSphere Partner Gateway builds one BIN or BDS segment for each occurrence of BINARY_STRUCTURE1.
The BIN and BDS segment has a length value as specified by the LENGTH field and contains data from the BINARY_DATA1 records.