1个回答
展开全部
.ORM F_FILE_UPLOAD.
DATA: L_FILENAME TYPE STRING.
L_FILENAME = P_FILE.
CLEAR G_ERR.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILENAME "上载文件路径(C:\Documents and Settings\test.txt)
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X' ”这两个参数要求上载的文本文件内各字段值(列)之间以Tab键分割
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = 'X'
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = I_DATA “上传到程序中的目标内表
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17 .
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " F_FILE_UPLOAD
另外你说的另一种方法,是以EXCEL文件上载到SAP程序的吗,给你几个参考函数:
ALSM_EXCEL_TO_INTERNAL_TABLE
TEXT_CONVERT_XLS_TO_SAP
KCD_EXCEL_OLE_TO_INT_CONVERT
PS:其实GUI_UPLOAD对文本文件和EXCEL文件都是能够实现上载到SAP内表中的,
你把FILENAME = L_FILENAME 上载文件路径换成(C:\Documents and Settings\test.xls)就行啦!!
DATA: L_FILENAME TYPE STRING.
L_FILENAME = P_FILE.
CLEAR G_ERR.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILENAME "上载文件路径(C:\Documents and Settings\test.txt)
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X' ”这两个参数要求上载的文本文件内各字段值(列)之间以Tab键分割
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = 'X'
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = I_DATA “上传到程序中的目标内表
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17 .
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " F_FILE_UPLOAD
另外你说的另一种方法,是以EXCEL文件上载到SAP程序的吗,给你几个参考函数:
ALSM_EXCEL_TO_INTERNAL_TABLE
TEXT_CONVERT_XLS_TO_SAP
KCD_EXCEL_OLE_TO_INT_CONVERT
PS:其实GUI_UPLOAD对文本文件和EXCEL文件都是能够实现上载到SAP内表中的,
你把FILENAME = L_FILENAME 上载文件路径换成(C:\Documents and Settings\test.xls)就行啦!!
追问
谢谢你的详细回答,是不是还可以通过屏幕来动态的制定要上载的文件,上面的代码好像是在程序中把文件和路径都写固定了!谢谢
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询