Code: Alles auswählen.
...add_attachment(
i_attachment_type = 'BIN'
...
Code: Alles auswählen.
STOR_CAT = DMS_C1_CON
CREP_ID
DOC_ID = 005056A2761A1ED69DB28737F0C3309D
PHIO_ID
SIGNATURE = X
SECURITY = r
NO_CACHE
RAW_MODE
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZTEST_SCMS_DOC_READ *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ztest_scms_doc_read.
DATA lt TYPE TABLE OF sdokcntbin.
DATA t_info TYPE TABLE OF scms_acinf.
DATA s_info TYPE scms_acinf.
DATA l_scat TYPE sdokstca-stor_cat VALUE 'DMS_H1_ST'.
DATA doc_id TYPE saeardoid VALUE '36525E1F45052040BA0C11A1A12F882F'.
CALL FUNCTION 'SCMS_DOC_READ'
EXPORTING
* MANDT = SY-MANDT
stor_cat = l_scat
* CREP_ID = ' '
doc_id = doc_id
* PHIO_ID =
SIGNATURE = 'X '
* SECURITY = ' '
* NO_CACHE = ' '
raw_mode = 'X'
* IMPORTING
* FROM_CACHE =
* CREA_TIME =
* CREA_DATE =
* CHNG_TIME =
* CHNG_DATE =
* STATUS =
* DOC_PROT =
TABLES
access_info = t_info
content_bin = lt
EXCEPTIONS
bad_storage_type = 1
bad_request = 2
unauthorized = 3
comp_not_found = 4
not_found = 5
forbidden = 6
conflict = 7
internal_server_error = 8
error_http = 9
error_signature = 10
error_config = 11
error_format = 12
error_parameter = 13
error = 14
OTHERS = 15
.
IF sy-subrc <> 0.
ENDIF.
DATA lbuffer TYPE xstring.
DATA contents_hex TYPE solix_tab.
DATA numbytes TYPE i.
*DATA: BEGIN OF lt_pdf OCCURS 0,
*t(134),
*END OF lt_pdf.
READ TABLE t_info INTO s_info INDEX 1.
numbytes = s_info-comp_size.
* I_tab nach Xstring
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = numbytes
IMPORTING
buffer = lbuffer
TABLES
binary_tab = lt
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
* Xstring nach Itab
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lbuffer
TABLES
binary_tab = contents_hex[].
data fn type string value 'c:\temp\scms_file.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = numbytes
filename = fn
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* IMPORTING
* FILELENGTH =
tables
data_tab = contents_hex[]
* FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF sy-subrc <> 0.
ENDIF.
Das ist nicht nur ein Tipp, sondern essentiell. Sonst werden am Dateiende NULL-Byte Zeichen angehängt die eventuell zu Fehlern in der weiteren Verarbeitung durch andere Programme führen. Das gilt übrigens auch für Textdateien, die bei Fehlen der Längenangabe dann Leerzeichen am Dateiende dazubekommen.Tron hat geschrieben:Tip: wenn man binäre Daten anhängt, muss man auch die Datenmenge übergeben.