Question
· Mar 13

Change Stream Property in Ens.StreamContainer with DTL

I'm trying to change the Stream property inside a DTL with a Source Class of Ens.StreamContainer. The code, below, will change it within the DTL testing tool, but running an actual message through the Production's Process doesn't change the Stream property. I can change other properties of Ens.StreamContainer by using the normal Set action and it is reflected when running it through the Process. For context, this uses a FTP service to grab a file. Any thoughts on why I can't just write modified stream data to the Stream property?

I use target here because I'm using the DTL copy function to preserve the OriginalFileName property.

1 set   streamData  target.Stream.Read(target.Stream.Size)  ""   
2 set   streamData  $REPLACE(streamData,"header1,header2"...  ""   
3 code     do target.Stream.Write(streamData)     
Product version: IRIS 2023.1
Discussion (7)2
Log in or sign up to continue

According to the doc, that doesn't seem to be the case, see reference below. Since I'm not reading the stream, it should start at byte 0 then overwrite the existing data. But, since the new data is smaller than the original, I would assume I should have duplicate data at the end. For w/e reason, I don't.

But this is kind of off topic as this isn't really my issue; the data looks correct. I'm trying to figure out why it works on the DTL testing tool, but doesn't while running in the actual Process.

Commonly Used Stream Methods and Properties

"Write() — Append data to the stream, starting at the current position. Overwrites existing data if the position is not set to the end of the stream."

The solution wound up being to create a new %Stream.GlobalCharacter Stream, read from the source object stream and write the replaced string to this stream, and finally set it to the Ens.StreamContainer target object.

I still have no idea why creating a new stream works while re-writing the existing stream doesn't. The docs seem to imply it should work and even saving the stream after writing didn't do anything different. In Message Viewer, I can see its creating a new body object, as well. Creating a new Stream object works, so I guess that's fine.