ABAP Uoload or Download file from files on application server



You can read and write files from the application server using the OPEN DATASET command.
You cannot use the internal table as you would with a local one, you have to write or read one line at a time.
Also, when linking with an external system, it is necessary to confirm whether it is fixed length or variable length, and when it is variable length, whether it is tab delimited or comma delimited.

Sample Code:Read


First, open the file with the OPEN DATASET command. An error will occur if the file is opened by another program.
This time, it is described as WINDOWS LINE FEED, but this is because the line feed code is CRLF. If the line feed code is LF, you need to use UNIX LINE FEED.
If the file cannot be read, check the ENCODING specification and the character code of the file.
If the file can be read, one line is read by the READ DATASET command and writing to the internal table is repeated.
Please note that the value acquired at this time is flat data. After that, you have to remove or delimit the header according to the definition.

Sample code:Write


Similarly, open the file with the OPEN DATA SET command. It doesn’t matter if it doesn’t exist.
Next, you can write it to a file by processing the values in the internal table into flat data (tab delimited this time) and using the TRANSFER command.