STM_FILE BIFS
Posted: Fri Oct 23, 2020 11:19 am
Hi
On out Webevent websites we often allow end users to upload csv files to our system to bulk upload data. Once the file is on the IFS (iSeries) we use
Change Field(#OPTIONS) To('''Read Text LineTerminator=ALL''')
Use Builtin(STM_FILE_OPEN) With_Args(#IFSLNM #OPTIONS) To_Get(#FILENO #WRK2A)
Use Builtin(STM_FILE_READ) With_Args(#FILENO) To_Get(#WRK256 #WRK2A)
Occasionally these files contain an invalid character, commonly a user's name has a single quote in it (') but because it has been imported from another system this has been converted to a right handed quote (comma with tail pointing down on the right). When STM_FILE_READ encounters such a character it immediately returns end of file. We may received some lines but the end effect is that we can't read the file to the end.
If I look at the file using wrklnk 5(Display) then I can see all the data fine - the invalid character appears as a blank and a message on the bottom line says something like error on line 12 will be saved as blank.
We can't stop the users from doing this but it should be possible to read the file, identify bad characters, replace them if we can and set them to blank if we can't. But how?
Has anyone got any ideas about how to access and IFS file which may contain dodgy characters in LANSA and allow us to fix them up?
On out Webevent websites we often allow end users to upload csv files to our system to bulk upload data. Once the file is on the IFS (iSeries) we use
Change Field(#OPTIONS) To('''Read Text LineTerminator=ALL''')
Use Builtin(STM_FILE_OPEN) With_Args(#IFSLNM #OPTIONS) To_Get(#FILENO #WRK2A)
Use Builtin(STM_FILE_READ) With_Args(#FILENO) To_Get(#WRK256 #WRK2A)
Occasionally these files contain an invalid character, commonly a user's name has a single quote in it (') but because it has been imported from another system this has been converted to a right handed quote (comma with tail pointing down on the right). When STM_FILE_READ encounters such a character it immediately returns end of file. We may received some lines but the end effect is that we can't read the file to the end.
If I look at the file using wrklnk 5(Display) then I can see all the data fine - the invalid character appears as a blank and a message on the bottom line says something like error on line 12 will be saved as blank.
We can't stop the users from doing this but it should be possible to read the file, identify bad characters, replace them if we can and set them to blank if we can't. But how?
Has anyone got any ideas about how to access and IFS file which may contain dodgy characters in LANSA and allow us to fix them up?