I'm trying to save the content of a field(CLOB) into a file on the IFS (iSeries).
The file doen't exist before save the content and the file is created perfect, but I don't know why at the begining (always position 1 and 2) the file contains two odd characteres. This characteres aren't always the same.
I think it's a problem with the conversion between clob field an the file (ifs - smtf) Does anyone how to solve this problem?
Thanks in advance!!
PD.:Sorry, I coudn't attach an image because I need at least 10 reputation to post images.
Variable Definiton in RPGLE
D xmlEntrada s sqltype(CLOB:10000000)
fd = open('/folder/file/file.xml':
O_WRONLY+O_CREAT+O_TRUNC:
O_RDWR : 819);
callp write(fd: %addr(xmlEntrada)+2: %len(xmlEntrada));
The English RPG manual calls this the 'Length-Prefix'. This is 2 bytes for a variable between 1 and 63353 bytes, and 4 bytes for larger variables. Change the write() to:
write(fd: %addr(xmlEntrada: *DATA): %len(xmlEntrada));
and let the compiler determine the length-prefix size.
If on an earlier release, try
write(fd: %addr(xmlEntrada)+4: %len(xmlEntrada));