I am Parsing a IS document to flat file by using convertToString service from flat file. But i have to truncate the length of the field as well.SO I want to use the flatfile.formatService.I read that i have to create the custom format services and assign the input/output specification flatfile.formatService. after set this cuistom format service in format service property of schema.Til this I understood…
But My question is How i will set the input for format services while setting this into format service proprty…???
Please corrrect me if i am wrong anywhere…???
Plaese help me…Thanks in advance
The input values of the “format services” are automatically “mapped”.
Means do I need to create the variable with same name(for direction,validate,minLength,maxLength etc) where we are using convertToString service.and set the values for these vailables…???
If you have choose “pub.flatFile:FormatService” as Specification Reference in the Input/Output tab, the input and output values should be already presents.
At runtime, when convertToString or convertToValues is called,
- “value” is filled with the data that has to be checked
- “direction” is filled with “convertToString” or “convertToValues” (depending of the calling service), in case you wants to perform other controls in each case.
You have to set the output values “formattedValue, meetsFormat,…”
- “formattedValue”: the new value that will be set
- “meetsFormat”: true or false depending of your rules/if you validate the data or not
- “errorMessage”: a readeable message of the error/rules not respected
You can also check the “Flat File Schema Developers Guide” for details.
“pub.flatFile:FormatService” can be used to format length of fields…
Thanks for your response
But @ arnaudW
If I have 10 fields in my schema and I have to impose different length restriction for each field…I dont wnat to write the 10 custom format services. I want to write one custom format service in which as you said that value will be automatically set …But i want to pass the length of restriction also so that only single custom format services will be working for each field…
Tell me if i am confusing to you.
Thanks a lot…
I’ve found that trying to implement length limitations via the format services is more trouble than it is worth. I would suggest trimming the fields to the desired max length before calling convertToString.
You won’t be passing anything to your format service. The pub.flatFile service you call will. And it will use the settings in the flat file schema. In this case, you need to specify a length validator to indicate the min and max length and a format service for each field you want to trim in the FF schema.
Again, I’ve found this to be a bit more troublesome to work with than is trimming fields within one or more FLOW steps (use of a transformer can be good here).