No one will be surprised that SAP itself runs in a Unix environment. To read and write files originating from Unix, the statements READ DATASET
and TRANSFER
can be used. The ABAP data is placed in a certain structure or even in an internal table that can be written to the sequential file as a whole.
A second TRANSFER itab TO '/usr/tst/filename'
, appends data to the file. TRANSFER
as well as READ
read (or write) exactly the amount of bytes as the size of the dataset passed along. Which can be used of course: an example: a mix of two structures (of different lengths) are stored in a sequential file. The first 4 characters of each structure can be used to determine which structure the "record" is about. Using READ DATASET '/usr/tst/filename' INTO codefield
, the structure that is about to be read is identified. Then the structure is read with : READ DATASET '/usr/tst/filename' INTO structure+4
.
When using READ DATASET
and TRANSFER
you have to pay attention to the BINARY MODE
or TEXT MODE
, respectively fixed lengths and a LF (Line Feed) after every record.
To remove a file from Unix: DELETE DATASET name
.
When using files that can be read and written independent of the user or workstation, you have to take the file name into consideration. When you do not enter a complete path with the command TRANSFER
, the file will be created in the SAP work-directory /usr/sap/username/workstation/work
, that cannot be accessed by other workstations. Selecting a file name accessible for everyone, can be done as follows: find out a path name with the function building block FILE_GET_NAME
. This path name will (can) be the same to every user. Note: when you allow the end user to supply the file name, use the parameters option LOWER CASE
as these filenames are CaSe SeNsItIvE!