We regularly have to process xml input in batch processes. I’ve seen examples of more than 80 MB which we cannot process, and I’d like to avoid error situations due to such file sizes.
I have read the thread “How to check the external files?” in which it was recommended to check out SYSEXT for keyword WORKFILE, so I came across USR2011N which I’m presently using to get the workfile path and name as well as workfile type for a certain wf number.
However, so far I haven’t found any way to check the file size of a certain external file except to issue a shell command to find the file in question,
then to write the result of the shell command into another file, and later on reading this small file to extract the size in bytes.
The result, i.e. the content of this small file, is something like that:
29999 24829 -rw-r----- 1 uuuuu gggggg 25423890 Nov 5 08:34 /xxxx/yyyy/zzz/xml_input.xml
If the size (here 25423890) exceeds a certain level which in our experience cannot be processed, I reject that file and invoke an error that I can handle, instead of running into a ‘out of memory’ situation.
Below pls find the coding. It works, but I’m sure there is a better way!
I’d like to avoid having to write a work file just for the sake of getting the result of a shell command back into my Natural process.
Do any of you have a suggestion?
... 1 #DATEIINFO (A253) 1 REDEFINE #DATEIINFO 2 #DI_FILLER (A44) 2 #DI_SIZE_BYTES (A10) 1 #SIZE_BYTES (N10) .... RESET L-SHCMD-COMMAND COMPRESS #C-SONDER1 #FILENAME #C-SONDER1 INTO L-SHCMD-NAME LEAVING NO COMPRESS 'find' #PATH '-type f -name' #FILENAME '-ls' '>' #TARGET-DATEIINFO INTO L-SHCMD-COMMAND PRINT ' ' L-SHCMD-COMMAND CALL 'SHCMD' L-SHCMD-COMMAND ... * CLOSE WORK 32 CALLNAT 'AXWFTYPN' 32 'ASCII' #TARGET-DATEIINFO RESET #DATEIINFO READ WORK 32 #DATEIINFO write '#DATEIINFO:' '=' #DI_SIZE_BYTES IF #DI_SIZE_BYTES IS (N10) #SIZE_BYTES := VAL (#DI_SIZE_BYTES) END-IF END-WORK CLOSE WORK 32 * ... Deletion of info file IF #SIZE_BYTES > 100000 write 'Datei ist zu groß!' '=' #SIZE_BYTES * ... Error handling END-IF * ... processing of xml input file