Reading Data from Presentation Server (no Dialog)
To read data from the presentation server into an internal table without a user dialog, use the function module WS_UPLOAD. The most important parameters are listed below. For more information, refer to the function module documentation in the Function Builder (Transaction SE37).
Important Export Parameters
Parameters |
Function |
CODEPAGE |
Only for upload under DOS: Value IBM |
FILENAME |
Filename |
FILETYPE |
File type |
Use the FILETYPE parameter to specify the transfer mode. Possible values:
Binary files
ASCII files: Text files with end of line markers.
Excel files, saved as text files with columns separated by tabs and lines separated by line breaks.
Excel and Lotus files saved as WK1 spreadsheets.
Export Parameters
Parameters |
Function |
FILELENGTH |
Number of bytes transferred |
Tables Parameters
Parameters |
Function |
DATA_TAB |
Internal table (target for the import) |
Exception Parameters
Parameters |
Function |
CONVERSION_ERROR |
Error converting data |
FILE_OPEN_ERROR |
Unable to open the file |
FILE_READ_ERROR |
Unable to read the file |
INVALID_TABLE_WIDTH |
Invalid table structure |
INVALID_TYPE |
Value of FILETYPE parameter is incorrect |
Suppose the presentation server is running under Windows NT, and contains the following text file:
The following program reads the text file:
PROGRAM SAPMZTST.
DATA: FLENGTH TYPE I.
DATA: TAB(80) OCCURS 5 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = 'IBM'
FILENAME = 'd:\temp\mytext.txt'
FILETYPE = 'ASC'
IMPORTING
FILELENGTH = FLENGTH
TABLES
DATA_TAB = TAB
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5.
WRITE: 'SY-SUBRC:', SY-SUBRC,
/ 'Length :', FLENGTH.
SKIP.
LOOP AT TAB.
WRITE: / TAB.
ENDLOOP.
The output appears as follows: