Need better x9.100-181 TIFF validation? Our products offer more value than the competition, and are trusted by more than 75% of the top-20 financial institutions in North America. Connect with us at sales@x9ware.com and start a free evaluation today.

SDK X9 Record Fields

Retrieving fields from x9 records using X9Ware SDK Records / Fields:

There are several ways to retrieve specific fields within x9 record types. You can choose from these alternatives based on your specific application requirements.

1) Create an x9 type specific object from an sdkObject or another source of x9 data. SdkObjects are typically created by X9SdkObjectFactory using X9SdkIO. Field values can then be retrieved directly from the x9 type specific object on a logical name basis.

X9Type01 t01 = new X9Type01(sdkBase, sdkObject.getX9AsciiRecord());
String destinationRouting = t01.immediateDestinationRoutingNumber;
String originationRouting = t01.immedateOriginRoutingNumber;
String createDate = t01.fileCreationDate;
String createTime = t01.fileCreationTime;
String fileIdModifier = t01.fileIdModifier;

2) Create an x9 type specific object from a previously created x9object and then retrieve the data fields on a logical name basis.

X9Type25 t25 = new X9Type25(x9o);
String routing = t25.payorBankRouting + t25.payorBankRoutingCheckDigit;
String micrOnUs = t25.micrOnUs;
String isn = t25.itemSequenceNumber;
BigDecimal amount = X9Decimal.getAsAmount(t25.amount);

3) Create an x9object which can then be used to retrieve commonly defined fields on a generic basis regardless of record type.

itemRecordNumber = x9o.x9ObjIdx;
itemAmount = x9o.getAmount();
itemRouting = x9o.getRouting();
itemOnUs = x9o.getMicrOnUs();
itemAuxOnUs = x9o.getAuxOnUs();
itemSequenceNumber = x9o.getItemSequenceNumber();

4) Create an X9Item object which can then be used to retrieve a wide variety of commonly required x9 fields. X9Item fields can be populated in one of several manners. The easiest is to provide an x9object which contains the target item. The setItemFields method has other alternatives including the ability to parse a scanned MICR line to obtain individual fields. An example of setting fields from an x9object instance and then retrieving fields is as follows:

X9Item x9item = new X9Item();
x9item.setItemFields(x9o);
String micrAuxOnUs = x9item.getAuxOnus();
String micrRouting = x9item.getRouting();
String micrOnUs = x9item.getOnus();

5) Extract a specific field from an x9 record using the x9object and field number. This approach can be used to extract any field directly from the x9 byte array as a string and is most efficient when only one or two fields are to be referenced.

String bundleId = x9o.getFieldValue(sdkBase.r20BundleIdentifier);

6) Use the x9object to access any defined field within that x9 record type by field number. This approach has the benefit that it easily extracts the data from the x9 record itself (eg, from the 80 byte data record), and can thus be equally well for x9objects, sdkobjects, or x9 data that comes from any other input source.

/*
* Get the x9field object for the bundle identifier.
*/
X9Field x9field = sdkBase.getFieldObject(X9.BUNDLE_HEADER, X9.R20BundleIdentifier);

/*
* Get the field value and field length.
*/
String bundleIdentifier = x9field.getStringValue(x9recordData).trim();
int fieldLength = x9field.getLength(x9recordData);

7) Sequentially walk all of the fields within an x9 record using the field walker.

/*
* Walk all of the x9 records within the current x9 file.
*/
X9Object x9o = X9GuiAnchor.getFirstObject();
while (x9o != null) {

/*
* Walk all of the fields within the current x9 record.
*/
final X9Field[] fieldArray = x9walk.getFieldArray(x9o);
for (X9Field x9field : fieldArray) {
/*
* Get the field value.
*/
String value = x9field.getFieldValueTrimmed(x9o);
}
}

Modifying fields within x9 records using the SDK:

There are several ways to modify specific fields within x9 record types. You can choose from these alternatives based on your specific application requirements. Some of these modification examples assume that you have loaded an x9 file to the heap using the facilities provided by X9ObjectManager. This is normally required since changing one x9 record can have impacts on other record types, so having access to all of the data is generally helpful. However, this is not an absolute requirement, and you can instead simply modify records during x9 read and write processing. For example, you can use an X9sdkObject to create an x9object that is not stored but only used for data read and write operations. You can choose from these alternatives based on your specific requirements.

1) Create an x9 type specific object from an sdkObject or another source of x9 data. SdkObjects are typically created by X9SdkObjectFactory using X9SdkIO. All field level modifications will be applied directly to the byte array used to allocate the x9 type specific object:

X9Type01 t01 = new X9Type01(sdkBase, sdkObject.getX9AsciiRecord());
t01.fileIdModifier = “B”;
t01.modify();

2) Create an x9 type specific object from from an x9object and then modify fields. X9objects are typically created by X9Reader. All field level modifications are applied to the x9ObjData byte array within the supplied x9object.

X9Type25 t25 = new X9Type25(x9o);
t25.itemSequenceNumber = Long.toString(++itemSequenceNumber);
t25.modify();

3) Create an x9object and then modify individual fields. X9Objects are typically created by X9Reader. All field level modifications are applied to the x9ObjData byte array within the referenced x9object.

String text = Integer.toString(bundleCount);
x9oCashLetterTrailer.setFieldValue(sdkBase.r90BundleCount, text);
x9oFileTrailer.setFieldValue(sdkBase.r99CashLetterCount, “1”);
text = Integer.toString(fileRecordCount);
x9oFileTrailer.setFieldValue(sdkBase.r99TotalRecordCount, text);

4) Update all trailer records after a data value has been modified which impacts the counts and amounts that are present in the bundle trailers, cash letter trailers, and the file control trailer. You can optionally enable field level logging within X9TrailerManager as part of that constructor (the default is for that facility to be disabled). When field level logging is enabled, all updated fields (with before and after values) will be logged through X9ModifyManager, which can be subsequently used to retrieve all of the modifications that have been applied. Note that this code assumes that that x9 file has been loaded as x9objects to the heap. X9TrailerManager can also be used to accumulate and optionally populate trailer record totals as individual x9 records are processed on a stream basis (see the next example).

X9TrailerManager x9trailerManager = new X9TrailerManager(sdkBase);
x9trailerManager.updateAllTrailerRecords();

5) X9TrailerManager also has methods that allow you to update the trailers when the x9 records are being directly read and written but have not be loaded to the heap.

/*
* Accumulate and populate totals within the trailer records.
*/
x9trailerManager.accumulateAndPopulate(recordType, recordFormat, x9data);

/*
* Build the 9 record from the current x9data and image.
*/
sdkObject.buildX9FromData(x9data);

/*
* Write the current sdkObject to the x9 output file.
*/
currentByteCount += sdkIO.writeX9(sdkObject);

6) Replace an image and then update the image lengths in associated record types: The replacement image is stored within the x9object and will be subsequently used when this x9object is formatted and written to an output x9 file.

/*
* Store the replacement image from a provided byte array.
*/
X9Type52Worker x9type52Worker = new X9Type52Worker(sdkBase);
x9o.setReplacementImage(tiffImage);

/*
* Update the image length in the type 50 and 52 records.
*/
x9type52Worker.updateImageRecordLengths(x9o, tiffImage.length);

Scroll to Top