Rejecting Records (Java Integration stage)

You might want to reject the records coming from an input link since the input record does not meet the requirements of your Java™ code. In this case, you might consider using a reject link in the job design and write the rejected data to this link.

When your Java code needs to write the record to a reject link, your Java code must call the getAssociatedRejectLink() method of the InputLink interface to get an instance of the OutputLink associated with the input link in the job design.
OutputLink m_rejectLink = m_inputLink.getAssociatedRejectLink();
Following is a list of methods provided by a RejectRecord interface:
  • setErrorText()
  • setErrorCode()
  • getOfLink()
Similar to the case of writing records to an output link, your Java code must instantiate a RejectRecord object by using the getRejectRecord() method of the OutputLink interface. Your Java code must specify the InputRecord object to be rejected.
RejectRecord rejectRecord = m_rejectLink.getRejectRecord(inputRecord);
A reject link in your job design might have the additional columns "ERRORTEXT" and "ERRORCODE". Your Java code can set the values for these additional columns by using the setErrorText() and the setErrorCode() methods of the RejectRecord interface.
rejectRecord.setErrorText("Name field contains *");
rejectRecord.setErrorCode(123);
Finally, you can write this reject record to the corresponding reject link by using the writeRecord(RejectRecord) method of the OutputLink interface.
m_rejectLink.writeRecord(rejectRecord);
.