Hi Bjarne,
Appeon didn’t modify the FileWrite function in PB 2017 / 2019. It is the same as SAP PB 12.6.
For the FileWrite function, you can refer to the link below for more details:
https://docs.appeon.com/appeon_online_help/pb2019r2/powerscript_reference/ch10s177.html
FileWrite is maintained for backward compatibility. Use the FileWriteEx function for new development.
If the file was opened in text mode, FileWrite returns -1. Use FileWriteEx to write to files in text mode.
https://docs.appeon.com/appeon_online_help/pb2019r2/powerscript_reference/ch10s172.html
The mode in which you open a file determines the behavior of the functions used to read and write to a file. There are two functions that read data from a file: FileRead and FileReadEx, and two functions that write data to a file: FileWrite and FileWriteEx. FileRead and FileWrite have limitations on the amount of data that can be read or written and are maintained for backward compatibility. They do not support text mode.
So,We recommend you to use FileWriteEx function.
Regards,
Ken
Apperantly, FileWrite returns -1 in these cases.
It has been like this for a long time, so a bit surprised that it fails now.
But as mentioned, the app has been PB2017 for long time and was recently migrated to 2019 R2.
Perhaps that's the issue here.
I've changed to FileWriteEx, and it works fine now.
Indeed FileWrite returns -1, which seems to make sense. This is from the pb help:
If the file is opened in stream mode, no conversion is done. If the file was opened in text mode, FileWrite returns -1. Use FileWriteEx to write to files in text mode.