A format service, as defined by pub.flatFile:FormatService, is applicable in relatively narrow scenarios. It takes just one field as input. And is invoked only in convertToString and convertToValues. So you won’t be able to implement anything like the logic you mentioned in your first post.
Define a flat file schema that represents the structure of the source file as is. Then define 1 or more schemas that represent the various output document types that you need. Then, when you’re processing the source file, determine (by whatever means) what output document type you need to create. Then call the services that translate the source type to the target type. These translation services can be as sophisticated (field manipulation as described in your first post) or as simple as needed.
If you separate the definitions and logic by document types, things will be easier to understand and maintain.
#Integration-Server-and-ESB#Flow-and-Java-services#webMethods