I'm trying to implement simple message flow, which reads text file (SWIFT message) and replaces one field value, then I need to put it back to file. Flow reads file as blob, then I cast message as CHARACTER and doing replacement. As result I get a CHARACTER variable, which I want write to file.
How to write CHARACTER variable to file in ESQL?
3.5k views Asked by CaptainFreedom At
2
There are 2 answers
0
On
To write a simple CHARACTER (for example, a XML tag like '< tag >') to a file in ESQL you just have to create a compute node and add something like:
DECLARE youCharacterToWrite CHARACTER '<a simple string>';
SET OutputRoot.BLOB.BLOB = CAST(youCharacterToWrite AS BLOB CCSID InputRoot.Properties.CodedCharSetId);
And connect your compute node from out terminal to in terminal of your FileOutput to write in the file. If you debug the variable in IIB, it will show some Base64 representation of your CHARACTER variable, but it will be correctly written to the file.
Cast the variable back to BLOB, make it the message root, then send it into a FileOutput node with default settings. Assuming that you are doing the character replacement with ESQL in a Compute node (with its Compute Mode set to change Message), then the subsequent ESQL would be:
SET OutputRoot.BLOB.BLOB = CAST(yourCharVar AS BLOB);