Code: Alles auswählen.
* Ermittlung des Transportverzeichnisses
DATA DIRNAME TYPE text255.
CALL FUNCTION 'RSPO_R_SAPGPARAM'
EXPORTING
name = 'DIR_TRANS'
IMPORTING
value = DIRNAME
EXCEPTIONS
error = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Code: Alles auswählen.
* Ermittle den Pfad Trenner
IF sy-opsys CS 'WINDOWS'.
* Windows NT/2000
sep = '\'.
ELSE.
* UNIX
sep = '/'.
ENDIF.
Code: Alles auswählen.
* Lesen eines Binärfiles auf dem App Server
TYPES: BEGIN OF IT_TYPE,
ZEICHEN TYPE X,
END OF IT_TYPE.
DATA ITAB TYPE TABLE OF IT_TYPE.
DATA dsn(75) TYPE C.
OPEN DATASET dsn FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
DO.
READ DATASET dsn INTO wa .
IF sy-subrc = 4 . EXIT . ENDIF.
APPEND wa TO itab.
ENDDO.
CLOSE DATASET dsn.
Code: Alles auswählen.
*** Schreiben eines Binärfiles
*Write File to /Data
* OPEN DATASET BINFILE1 FOR OUTPUT IN BINARY MODE.
* LOOP AT ITAB INTO WA.
* TRANSFER WA TO BINFILE1.
* ENDLOOP.
* CLOSE DATASET BINFILE1.
Code: Alles auswählen.
* Upload von Binärdaten
CALL FUNCTION 'UPLOAD'
EXPORTING
* CODEPAGE = ' '
FILENAME = 'c:\_DATFILE.DAT'
FILETYPE = 'BIN'
ITEM = 'Name der Transportdatei'
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = ' '
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* LINE_EXIT = ' '
* USER_FORM = ' '
* USER_PROG = ' '
SILENT = 'S'
* IMPORTING
* FILESIZE =
* CANCEL =
* ACT_FILENAME =
* ACT_FILETYPE =
TABLES
DATA_TAB = itab
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Code: Alles auswählen.
* Download von Binärdaten
CALL FUNCTION 'DOWNLOAD'
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
FILENAME = 'C:\_DATA.DAT'
FILETYPE = 'bin'
ITEM = 'File from DATA-DIR'
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = 'File from DATA-DIR'
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* SILENT = 'S'
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* ACT_FILENAME =
* ACT_FILETYPE =
* FILESIZE =
* CANCEL =
TABLES
DATA_TAB = ITAB
* FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
WRITE: / 'Datei', BINFILE1, 'konnte nicht geöffnet werden'.
ENDIF ." Open dataset
Code: Alles auswählen.
* Lade alle Datei Namen in aus App Serververzeichnis
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = lv_path
file_mask = file_mask
* IMPORTING
* DIR_NAME =
* FILE_COUNTER =
* ERROR_COUNTER =
TABLES
dir_list = lt_dir_list
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.