Extend the methods of Hibersap converters to pass field meta data (extracted from JCoField) as additional parameters.
Thus, the Converter could do conversions according to the SAP field's characteristics, e.g. the length of a field:
public Object convertToSap( FieldMetaData metaData, Object javaValue )
{
int fieldLength = metaData.getLength();
String value = (String) sapValue;
return addLeadingZeroes(value, fieldLength);
}
This would convert a number from a representation without leading 0's to the SAP representation with
leading 0's when passing the value Java to SAP: 40000345 -> 00040000345
To keep the interface clean, it would be better to inject a meta data object into the converter. Injection point could be a field with a special annotation.
move to github tracker