How to ensure that all records in a file contain the required number of characters
Paul Barrie 270003JP87 Visits (5785)
Here is a real-world issue that crossed my desk recently: our client received inbound files from trading partners in which each file record needed be exactly 512 characters in length. If a record contained fewer than 512 characters, the record needed to be padded with spaces. One trading partner sometimes sent records shorter than the required length, so the customer needed a means of ensuring that all records were compliant. I thought about this issue and suggested the following code, which is deployed within a Java Task Service:
You have a choice of File or Inline for your code. If you choose File, you then specify the name of the file on the File System that contains the code. Choosing File will be necessary if there are many lines of code to be executed. This approach also comes in handy when you are first testing the code, as you can edit the file on the File System without having to go into the Service Configuration should you need to modify the code. In this particular case, though, I chose Inline, as the 31 lines of code were not too unwieldy:
After saving the Service, a simple Business Process allows us to test the service:
This scenario may not arise very often, but if it does, these steps may provide the means to work around the issue.