Trim spaces in IData record object

I am parsing a small positional flat file using template and EDI adapter. I use wm.b2b.edi:convertToValues service to build the records. The problem is positional files tend to have many blank fields and they transform into spaces in IData record fields. I try to set option on wm.b2b.edi:convertToValues to skip white spaces but aparently it only does this to front of record and not to every fields in a template. I was thinking of creating a java service that runs through any IData object and trim all fields. I want to know if somebody already had this problem and found some better solutions or have code to share?

we had the same problem and here is the service.

NOTE: The service name is initRecord, plz keep as it is
or modify the code as well

System.out.println(“Hello world In Init record”);
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();

Object tempObj = null;
String tempKey = null;

//System.out.println(“Size is :”+IDataUtil.size(pipelineCursor));

System.out.println(“MOVING NEXT RECORD >>>>>>>>>>>>>>>>>>>>>>>>>>”);;

tempObj = pipelineCursor.getValue();
tempKey = pipelineCursor.getKey();

System.out.println("Rec Key: "+tempKey);
System.out.println("Rec Value: "+tempObj);

System.out.println("IS STRING: "+(tempObj instanceof String));

if(tempObj instanceof IData)
System.out.println(“THIS IS A RECORD >>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>”);

if(tempObj instanceof IData)
System.out.println("Its a record array: “);
IData recs = (IData)tempObj;
for(int i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>”);
IDataUtil.put( pipelineCursor, tempKey, “” );
catch(Exception ex)





Could you explain what the inputs to this service are and what needs to be mapped to them?

Can we tokenize the output of convertTovalues on space and then append all the elements? This method should remove all the white spaces inside the document and we wont have to write any java code either.