1

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));
mike
  • 1,233
  • 1
  • 15
  • 36
sigsag
  • 37
  • 8

1 Answers1

2

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));
Buck Calabro
  • 7,558
  • 22
  • 25
  • I tried but now, I have an Error: "*RNF0229 20 1 *DATA sólo es válido para %ADDR cuando la definición es un elemento de longitud variable; *DATA se ignora. " --> * DATA RNF0229 is only valid for% ADDR when the definition is an element of variable length; * DATA is ignored. – sigsag Nov 29 '14 at 21:25
  • 1
    OK so you're on an earlier release. Make it %addr(xmlEntrada)+4 – Buck Calabro Nov 29 '14 at 21:26
  • I spend many hours to find a solution. Finally I did an alternative thank you for help me. I use this solution. Thanks again!! – sigsag Nov 29 '14 at 21:33
  • @BuckCalabro Upvoted and suggest editing to include your "%addr()" comment in the answer. – user2338816 Dec 18 '14 at 04:49