新知一下
海量新知
6 6 1 0 5 6 8

搜索帮助demo(1)上载文件

SAP干货铺 | 好好学习,天天向上! 2022/09/20 16:05

新知达人, 搜索帮助demo(1)上载文件

最简单的使用:F4_FILENAME

demo:

PARAMETERS:

P_FILE TYPE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

FILE_NAME = P_FILE.

或者:

PARAMETERS:

P_FILE TYPE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

TITLE = '选择文件'

IMPORTING

FILENAME = P_FILE

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

IF SY-SUBRC <> 0 AND SY-SUBRC <> 3.

MESSAGE E100(ZDEV) WITH '选择文件出错!'(007).

ENDIF.

再或者

PARAMETERS:

P_FILE TYPE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

DATA: V_RC TYPE I,

V_FILETABLE TYPE FILETABLE.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

WINDOW_TITLE = '选择源文件'

FILE_FILTER = '全部文件 (*.*)'

MULTISELECTION = SPACE

CHANGING

FILE_TABLE = V_FILETABLE

RC = V_RC

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 4

OTHERS = 5.

IF SY-SUBRC = 0 AND V_RC = 1.

READ TABLE V_FILETABLE INTO P_FILE INDEX 1.

ENDIF.

还有个下载路径:

PARAMETERS:

P_FILE TYPE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

DATA : LC_FILENAME TYPE STRING VALUE '请选择文件路径',

LC_FULLPATH TYPE STRING,

LC_PATH TYPE STRING.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

EXPORTING

DEFAULT_EXTENSION = 'XLS' "默认保存文件格式

DEFAULT_FILE_NAME = LC_FILENAME "默认文件名称

CHANGING

FILENAME = LC_FILENAME "默认文件名称

PATH = LC_PATH "文件路径

FULLPATH = LC_FULLPATH "文件路径

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

NOT_SUPPORTED_BY_GUI = 3

OTHERS = 4.

IF SY-SUBRC = 0 .

P_FILE = LC_FULLPATH .

ELSEIF SY-SUBRC <> 0 .

MESSAGE '保存文件出错!' TYPE 'E' .

ENDIF .

更多“demo”相关内容

更多“demo”相关内容

新知精选

更多新知精选