sm35创建
在输入框中依次输入1234保存变式
点击保存后返回
选中计律点程序
点击源代码进入代码界面
执行后界面
shdb事务码界面
/OCG3Y
本地数据的bdc
保留BDC_TRANSACTION,BDC_DYNPRO,BDC_FIELD三个from
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE."执行的参数传递表
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE."返回执行结果
* error session opened (' ' or 'X')
DATA: E_GROUP_OPENED.
* message texts
TABLES: T100."信息类型的存放表
FORM BDC_TRANSACTION USING TCODE .
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE TCODE
UPDATE 'A'
MESSAGES INTO MESSTAB.
*-----消息提示-------*
L_SUBRC = SY-SUBRC.
WRITE:/ 'CALL TRANSACTION',
TCODE,
'RETURNCODE:'(I05),
L_SUBRC,
'RECORD',
SY-INDEX.
LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
WRITE:/ MESSTAB-MSGNR,L_MSTRING(250).
ELSE.
WRITE:/ MESSTAB.
ENDIF.
ENDLOOP.
*---------------------------------------*
REFRESH BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM.
主程序ztxyy_1151
report ZTXYY_1150"因为从50中拷贝出来的
no standard page heading line-size 255.
INCLUDE ZBDCRECX1.
*include bdcrecx1.
DATA:IT_RAW TYPE truxs_t_text_data."TRUXS_T_TEXT_DATA.
PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.
data: begin of record OCCURS 0,
* data element:
LOW_001(004),
* data element:
HIGH_002(004),
* data element:
LOW_003(004),
* data element:
HIGH_004(004),
* data element: RALDB_VARI
VARIANT_005(014),
* data element: RALDB_VTXT
VTEXT_006(030),
end of record.
*** End generated data section ***
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
.
start-of-selection.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'"代码失效
EXPORTING
I_LINE_HEADER = 'X'
i_tab_raw_data = IT_RAW
i_filename = P_FILE
TABLES
i_tab_converted_data = record[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
record-LOW_001 = 12.
record-HIGH_002 = 13.
record-LOW_003 = 12.
record-HIGH_004 = 13.
record-VARIANT_005 = 'ZTXYY_1142_4'.
record-VTEXT_006 = 4.
append record.
CHECK NOT record[] IS INITIAL.
LOOP AT RECORD.
perform bdc_dynpro using 'ZTXYY_1142' '1000'.
perform bdc_field using 'BDC_CURSOR'
'S_MATNR2-HIGH'.
perform bdc_field using 'BDC_OKCODE'
'=SPOS'.
perform bdc_field using 'S_MATNR-LOW'
record-LOW_001.
perform bdc_field using 'S_MATNR-HIGH'
record-HIGH_002.
perform bdc_field using 'S_MATNR2-LOW'
record-LOW_003.
perform bdc_field using 'S_MATNR2-HIGH'
record-HIGH_004.
perform bdc_dynpro using 'SAPLSVAR' '0281'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'BDC_CURSOR'
'RSVAR-VTEXT'.
perform bdc_field using 'RSVAR-VARIANT'
record-VARIANT_005.
perform bdc_field using 'RSVAR-VTEXT'
record-VTEXT_006.
perform bdc_dynpro using 'ZTXYY_1142' '1000'.
perform bdc_field using 'BDC_OKCODE'
'/EE'.
perform bdc_field using 'BDC_CURSOR'
'S_MATNR2-HIGH'.
perform bdc_transaction using 'ZTXYY_1142'.
ENDLOOP.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'"代码失效
原因参考开发ABAP程序中的错误-CSDN博客
shdb中记录展是的列名与bdcdata数据元素一一对应.
例如
CLEAR BDCDATA.
BDCDATA-PROGRAM = 'ZTXYY_1142'.
BDCDATA-DYNPRO = '1000'.
BDCDATA-DYNBEGIN = 'X'.
BDCDATA-FNAM = ''.
BDCDATA-FVAL = ''.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'BDC_CURSOR'.
BDCDATA-FVAL = 'S_MATNR2-HIGH'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '=SPOS'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'S_MATNR-LOW'.
BDCDATA-FVAL = '1'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'S_MATNR-HIGH'.
BDCDATA-FVAL = '2'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'S_MATNR2-LOW'.
BDCDATA-FVAL = '3'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = ''.
BDCDATA-DYNPRO = ''.
BDCDATA-DYNBEGIN = ''.
BDCDATA-FNAM = 'S_MATNR2-HIGH'.
BDCDATA-FVAL = '4'.
APPEND BDCDATA.
因为记录的形式为三 二式 代码重复性高 分成两个form
记录中的field name 即(bdcdata-fnam)为BDC_SUBSCR时可以省略
跟着记录一起输入
REPORT ZTXYY_1153.
*INCLUDE ZTXYY_1153_TOP.
*INCLUDE ZTXYY_1153_FORM.
*在录屏阶段需要传值的字段汇总成结构
TYPES:BEGIN OF TY_STU,
S_MATNR_LOW(18),
S_MATNR_HIGH(18),
S_MATNR2_LOW(18),
S_MATNR2_HIGH(18),
RSVAR_VARIANT(18),
RSVAR_VTEXT(18),
END OF TY_STU.
DATA: GS_STU TYPE TY_STU,
GT_STU TYPE TABLE OF TY_STU.
DATA BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.
START-OF-SELECTION.
*取数
*手工插入
gs_stu-S_MATNR_LOW = 1.
gs_stu-S_MATNR_HIGH = 2.
gs_stu-S_MATNR2_LOW = 3.
gs_stu-S_MATNR2_HIGH = 4.
gs_stu-RSVAR_VARIANT = 'ZTXYY_1142_5'.
gs_stu-RSVAR_VTEXT = 5.
APPEND GS_STU TO GT_STU.
END-OF-SELECTION.
*转换
PERFORM APPEND_BDCDATA.
FORM APPEND_BDCDATA.
LOOP AT GT_STU INTO GS_STU.
CLEAR: BDCDATA,BDCDATA[].
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SPOS'.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-LOW' GS_STU-S_MATNR_LOW.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-HIGH' GS_STU-S_MATNR_HIGH.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-LOW' GS_STU-S_MATNR2_LOW.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-HIGH' GS_STU-S_MATNR2_HIGH.
PERFORM append_screen(ztxyy_1153) USING 'SAPLSVAR' '0281'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SAVE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' GS_STU-RSVAR_VTEXT.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VARIANT' GS_STU-RSVAR_VARIANT.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VTEXT' GS_STU-RSVAR_VTEXT.
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '/EE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
CALL TRANSACTION 'ZTXYY_1142' USING BDCDATA "使用的内表
MODE 'A'."显示模式:A 前台;N后台;E只显示错误
ENDLOOP.
ENDFORM.
FORM APPEND_SCREEN USING VALUE(P_PROGRAM)
VALUE(P_DYNPO).
CLEAR BDCDATA.
BDCDATA-PROGRAM = P_PROGRAM.
BDCDATA-DYNPRO = P_DYNPO.
BDCDATA-DYNBEGIN = 'X'."因为上面有值时一定为X故无需传值
BDCDATA-FNAM = ''.
BDCDATA-FVAL = ''.
APPEND BDCDATA.
ENDFORM.
FORM APPEND_FIELDS USING VALUE(P_FIELD)
VALUE(P_VALUE).
CLEAR BDCDATA.
* BDCDATA-PROGRAM = ''.
* BDCDATA-DYNPRO = ''.
* BDCDATA-DYNBEGIN = ''."可以注释调或者删除
BDCDATA-FNAM = P_FIELD.
BDCDATA-FVAL = P_VALUE.
APPEND BDCDATA.
ENDFORM.
上传txt文件
*&---------------------------------------------------------------------*
*& Report ZTXYY_1153
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztxyy_1153.
*INCLUDE ZTXYY_1153_TOP.
*INCLUDE ZTXYY_1153_FORM.
*在录屏阶段需要传值的字段汇总成结构
TYPES:BEGIN OF ty_stu,
s_matnr_low(18),
s_matnr_high(18),
s_matnr2_low(18),
s_matnr2_high(18),
rsvar_variant(18),
rsvar_vtext(18),
END OF ty_stu.
DATA: gs_stu TYPE ty_stu,
gt_stu TYPE TABLE OF ty_stu.
DATA bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE.
PARAMETERS: p_files TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_files.
PERFORM get_help.
START-OF-SELECTION.
*取数
PERFORM get_data.
*手工插入
gs_stu-s_matnr_low = 1.
gs_stu-s_matnr_high = 2.
gs_stu-s_matnr2_low = 3.
gs_stu-s_matnr2_high = 4.
gs_stu-rsvar_variant = 'ZTXYY_1142_5'.
gs_stu-rsvar_vtext = 5.
APPEND gs_stu TO gt_stu.
END-OF-SELECTION.
*转换
PERFORM append_bdcdata.
FORM append_bdcdata.
LOOP AT gt_stu INTO gs_stu.
CLEAR: bdcdata,bdcdata[].
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SPOS'.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-LOW' gs_stu-s_matnr_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-HIGH' gs_stu-s_matnr_high.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-LOW' gs_stu-s_matnr2_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-HIGH' gs_stu-s_matnr2_high.
PERFORM append_screen(ztxyy_1153) USING 'SAPLSVAR' '0281'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SAVE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' gs_stu-rsvar_vtext.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VARIANT' gs_stu-rsvar_variant.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VTEXT' gs_stu-rsvar_vtext.
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '/EE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
CALL TRANSACTION 'ZTXYY_1142' USING bdcdata "使用的内表
MODE 'A'."显示模式:A 前台;N后台;E只显示错误
ENDLOOP.
ENDFORM.
FORM append_screen USING VALUE(p_program)
VALUE(p_dynpo).
CLEAR bdcdata.
bdcdata-program = p_program.
bdcdata-dynpro = p_dynpo.
bdcdata-dynbegin = 'X'."因为上面有值时一定为X故无需传值
bdcdata-fnam = ''.
bdcdata-fval = ''.
APPEND bdcdata.
ENDFORM.
FORM append_fields USING VALUE(p_field)
VALUE(p_value).
CLEAR bdcdata.
* BDCDATA-PROGRAM = ''.
* BDCDATA-DYNPRO = ''.
* BDCDATA-DYNBEGIN = ''."可以注释调或者删除
bdcdata-fnam = p_field.
bdcdata-fval = p_value.
APPEND bdcdata.
ENDFORM.
FORM get_data.
"数据类型转换
DATA: L_FILES TYPE STRING.
check P_FILES is not INITIAL.
L_FILES = P_FILES.
*从文件中获取数据
*if L_FILES is not INITIAL.
CALL FUNCTION 'GUI_UPLOAD'"txt文件的读取上传
EXPORTING
filename = L_FILES"TXT文件要用tab分格符分开数据.
* FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = gt_stu
* CHANGING
* ISSCANPERFORMED = ' '
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.
* Implement suitable error handling here
ENDIF.
*endif.
ENDFORM.
FORM get_help.
"获取本地文件路径
CALL FUNCTION 'WS_FILENAME_GET'"已过时
EXPORTING
* DEF_FILENAME = ' '"默认文件路径
* DEF_PATH = ' '"默认文件名称
MASK = ',excel.xls,*.xls,text.txt,*.txt. '
"支持的文件类型,两个逗号为一组,开头的逗号为默认的.不计入两个中excel.xls,*.xls,这样才算一组
MODE = 'O'"S保存到FILENAME这个路径,O打开FILENAME这个路径上的文件
TITLE = '打开文件'"窗口显示名称.
IMPORTING
FILENAME = P_FILES
* RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
上传xls文件
*&---------------------------------------------------------------------*
*& Report ZTXYY_1153
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztxyy_1153.
*INCLUDE ZTXYY_1153_TOP.
TYPE-POOLS:icon."用于屏幕按钮图标.
TABLES sscrfields."用于屏幕按钮.
SELECTION-SCREEN FUNCTION KEY 1.
*INCLUDE ZTXYY_1153_FORM.
*在录屏阶段需要传值的字段汇总成结构
TYPES:BEGIN OF ty_stu,
s_matnr_low(18),
s_matnr_high(18),
s_matnr2_low(18),
s_matnr2_high(18),
rsvar_variant(18),
rsvar_vtext(18),
END OF ty_stu.
DATA: gs_stu TYPE ty_stu,
gt_stu TYPE TABLE OF ty_stu.
DATA:BEGIN OF gt_stu2 OCCURS 0,
col1 TYPE c LENGTH 18 VALUE 'A',
col2 TYPE c LENGTH 18 VALUE 'B',
col3 TYPE c LENGTH 18 VALUE 'C',
col4 TYPE c LENGTH 18 VALUE 'D',
col5 TYPE c LENGTH 18 VALUE 'E',
col6 TYPE c LENGTH 18 VALUE 'F',
END OF gt_stu2.
DATA bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE.
DATA messtab TYPE TABLE OF bdcmsgcoll WITH HEADER LINE.
PARAMETERS: p_files TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_files.
PERFORM get_help.
INITIALIZATION.
WRITE icon_change_text AS ICON TO sscrfields-functxt_01+0(4).
sscrfields-functxt_01+4(*) = '下载模版'.
*SSCRFIELDS-FUNCTXT_01 = '@0Q@下载模版'
AT SELECTION-SCREEN."PAI事件
PERFORM frm_pai.
START-OF-SELECTION.
*取数
PERFORM get_data.
*手工插入
gs_stu-s_matnr_low = 1.
gs_stu-s_matnr_high = 2.
gs_stu-s_matnr2_low = 3.
gs_stu-s_matnr2_high = 4.
gs_stu-rsvar_variant = 'ZTXYY_1142_5'.
gs_stu-rsvar_vtext = 5.
APPEND gs_stu TO gt_stu.
END-OF-SELECTION.
*转换
PERFORM append_bdcdata.
FORM append_bdcdata.
DATA: LV_MESSAGE TYPE C LENGTH 200."用于消息
LOOP AT gt_stu INTO gs_stu.
CLEAR: bdcdata,bdcdata[],
MESSTAB,MESSTAB[].
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SPOS'.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-LOW' gs_stu-s_matnr_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-HIGH' gs_stu-s_matnr_high.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-LOW' gs_stu-s_matnr2_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-HIGH' gs_stu-s_matnr2_high.
PERFORM append_screen(ztxyy_1153) USING 'SAPLSVAR' '0281'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SAVE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' gs_stu-rsvar_vtext.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VARIANT' gs_stu-rsvar_variant.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VTEXT' gs_stu-rsvar_vtext.
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '/EE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
CALL TRANSACTION 'ZTXYY_1142' USING bdcdata "使用的内表
" OPTIONS FROM <内表> 参照CTU_PARAMS.
"UPDATE 'S' "更新模式 S 同步 A 异步
MODE 'A'"显示模式:A 前台;N后台;E只显示错误
MESSAGES INTO messtab."用于消息提示 那个录屏阶段错误不成功
IF SY-subrc = 0.
"READ TABLE MESSTAB WITH KEY MSGID = ''"某值需要自己测
"MSGNR = ''. "某值需要自己测 由此判断成功与否
ELSE.
WRITE:/ '失败'.
*_________________新方法可以---------*
LOOP AT MESSTAB WHERE MSGTYP = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'" 用于消息提示
EXPORTING
msgid = MESSTAB-MSGID
msgnr = MESSTAB-MSGNR
MSGV1 = MESSTAB-MSGV1
MSGV2 = MESSTAB-MSGV2
MSGV3 = MESSTAB-MSGV3
MSGV4 = MESSTAB-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSAGE
.
WRITE:/ LV_MESSAGE.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM.
FORM append_screen USING VALUE(p_program)
VALUE(p_dynpo).
CLEAR bdcdata.
bdcdata-program = p_program.
bdcdata-dynpro = p_dynpo.
bdcdata-dynbegin = 'X'."因为上面有值时一定为X故无需传值
bdcdata-fnam = ''.
bdcdata-fval = ''.
APPEND bdcdata.
ENDFORM.
FORM append_fields USING VALUE(p_field)
VALUE(p_value).
CLEAR bdcdata.
* BDCDATA-PROGRAM = ''.
* BDCDATA-DYNPRO = ''.
* BDCDATA-DYNBEGIN = ''."可以注释调或者删除
bdcdata-fnam = p_field.
bdcdata-fval = p_value.
APPEND bdcdata.
ENDFORM.
FORM get_data.
"数据类型转换
DATA: l_files TYPE string.
CHECK p_files IS NOT INITIAL.
FIND 'txt' IN p_files."注意这里用小写的.
IF sy-subrc = 0.
l_files = p_files.
*从文件中获取数据
*if L_FILES is not INITIAL.
CALL FUNCTION 'GUI_UPLOAD' "txt文件的读取上传
EXPORTING
filename = l_files "TXT文件要用tab分格符分开数据.
* FILETYPE = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = gt_stu
* CHANGING
* ISSCANPERFORMED = ' '
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.
* Implement suitable error handling here
ENDIF.
*endif.
ENDIF.
FIND '.xls' IN p_files.
IF sy-subrc = 0.
DATA: lt_raw TYPE truxs_t_text_data.
*excel文件的读取上传.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X' "有表头
i_tab_raw_data = lt_raw
i_filename = p_files
TABLES
i_tab_converted_data = gt_stu
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDFORM.
FORM get_help.
"获取本地文件路径
CALL FUNCTION 'WS_FILENAME_GET' "已过时
EXPORTING
* DEF_FILENAME = ' '"默认文件路径
* DEF_PATH = ' '"默认文件名称
mask = ',excel.xls,*.xlsx,text.txt,*.txt. '
"支持的文件类型,两个逗号为一组,开头的逗号为默认的.不计入两个中excel.xls,*.xls,这样才算一组
mode = 'O' "S保存到FILENAME这个路径,O打开FILENAME这个路径上的文件
title = '打开文件' "窗口显示名称.
IMPORTING
filename = p_files
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM frm_pai.
CASE sscrfields-ucomm.
WHEN 'FC01'.
PERFORM dowload_template.
ENDCASE.
ENDFORM.
FORM dowload_template.
REFRESH gt_stu2.
APPEND gt_stu2.
DATA lv_file TYPE string.
*1.获取文件路径
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
* DEF_PATH = ' '
mask = ',EXCEL,*,XLS.' "',EXCEL,*,XLSX.'效果一样
"注意英文系统中汉字可能乱码
mode = 'S'
* TITLE = ' '
IMPORTING
filename = lv_file
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CHECK lv_file IS NOT INITIAL.
*2将内表数据下载到指定文件路径的文件中
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = lv_file
* FILETYPE = 'ASC'
append = 'X' "X表示追加 ''空表示覆盖原路径的文件
write_field_separator = 'X'
* 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
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = gt_stu2[]
* FIELDNAMES =
"一个记录这gt_stu2[]数据描述的内表会在下载文件中做为表头行
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.
* Implement suitable error handling here
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Report ZTXYY_1155
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTXYY_1155.
*INCLUDE ZTXYY_1153_TOP.
TYPE-POOLS:ICON."用于屏幕按钮图标.
TABLES sscrfields."用于屏幕按钮.
SELECTION-SCREEN FUNCTION KEY 1.
*INCLUDE ZTXYY_1153_FORM.
*在录屏阶段需要传值的字段汇总成结构
TYPES:BEGIN OF ty_stu,
s_matnr_low(18),
s_matnr_high(18),
s_matnr2_low(18),
s_matnr2_high(18),
rsvar_variant(18),
rsvar_vtext(18),
END OF ty_stu.
DATA: gs_stu TYPE ty_stu,
gt_stu TYPE TABLE OF ty_stu.
DATA:BEGIN OF gt_stu2 OCCURS 0,
col1 TYPE C LENGTH 18 VALUE 'A',
col2 TYPE C LENGTH 18 VALUE 'B',
col3 TYPE C LENGTH 18 VALUE 'C',
col4 TYPE C LENGTH 18 VALUE 'D',
col5 TYPE C LENGTH 18 VALUE 'E',
col6 TYPE C LENGTH 18 VALUE 'F',
END OF gt_stu2.
DATA bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE.
DATA messtab TYPE TABLE OF bdcmsgcoll WITH HEADER LINE.
PARAMETERS: p_files TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_files.
PERFORM get_help.
INITIALIZATION.
WRITE icon_change_text AS ICON TO sscrfields-functxt_01+0(4).
sscrfields-functxt_01+4(*) = '下载模版'.
*SSCRFIELDS-FUNCTXT_01 = '@0Q@下载模版'
AT SELECTION-SCREEN."PAI事件
PERFORM frm_pai.
START-OF-SELECTION.
*取数
PERFORM get_data.
*手工插入
gs_stu-s_matnr_low = 1.
gs_stu-s_matnr_high = 2.
gs_stu-s_matnr2_low = 3.
gs_stu-s_matnr2_high = 4.
gs_stu-rsvar_variant = 'ZTXYY_1142_5'.
gs_stu-rsvar_vtext = 5.
APPEND gs_stu TO gt_stu.
END-OF-SELECTION.
*转换
*PERFORM append_bdcdata.
PERFORM append_bdcdata2.
FORM append_bdcdata2.
DATA: LV_MESSAGE TYPE C LENGTH 200."用于消息
DATA:GV_SESSION TYPE apqi-groupid value 'zaita'."用于session,在sm35中来看
*开启session
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
* CLIENT = SY-MANDT
* DEST = FILLER8
GROUP = GV_SESSION
* HOLDDATE = FILLER8
KEEP = 'X'" 是否进行保存
USER = sy-uname"当前用户名
* RECORD =
* PROG = SY-CPROG
* DCPFM = '%'
* DATFM = '%'
* IMPORTING
* QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
.
IF sy-subrc <> 0.
* Implement suitable error handling here
exit.
ENDIF.
LOOP AT gt_stu INTO gs_stu.
CLEAR: bdcdata,bdcdata[],
MESSTAB,MESSTAB[].
PERFORM append_screen(ztxyy_1155) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_OKCODE' '=SPOS'.
PERFORM append_fields(ztxyy_1155) USING 'S_MATNR-LOW' gs_stu-s_matnr_low.
PERFORM append_fields(ztxyy_1155) USING 'S_MATNR-HIGH' gs_stu-s_matnr_high.
PERFORM append_fields(ztxyy_1155) USING 'S_MATNR2-LOW' gs_stu-s_matnr2_low.
PERFORM append_fields(ztxyy_1155) USING 'S_MATNR2-HIGH' gs_stu-s_matnr2_high.
PERFORM append_screen(ztxyy_1155) USING 'SAPLSVAR' '0281'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_OKCODE' '=SAVE'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_CURSOR' gs_stu-rsvar_vtext.
PERFORM append_fields(ztxyy_1155) USING 'RSVAR-VARIANT' gs_stu-rsvar_variant.
PERFORM append_fields(ztxyy_1155) USING 'RSVAR-VTEXT' gs_stu-rsvar_vtext.
PERFORM append_screen(ztxyy_1155) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_OKCODE' '/EE'.
PERFORM append_fields(ztxyy_1155) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
* CALL TRANSACTION 'ZTXYY_1142' USING bdcdata "使用的内表
* " OPTIONS FROM <内表> 参照CTU_PARAMS.
* "UPDATE 'S' "更新模式 S 同步 A 异步
* MODE 'A'"显示模式:A 前台;N后台;E只显示错误
* MESSAGES INTO messtab."用于消息提示 那个录屏阶段错误不成功
"向session中插入事务
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ZTXYY_1142'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
dynprotab = bdcdata
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDLOOP.
"关闭session
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
endform.
FORM append_bdcdata.
DATA: LV_MESSAGE TYPE C LENGTH 200."用于消息
LOOP AT gt_stu INTO gs_stu.
CLEAR: bdcdata,bdcdata[],
MESSTAB,MESSTAB[].
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SPOS'.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-LOW' gs_stu-s_matnr_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR-HIGH' gs_stu-s_matnr_high.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-LOW' gs_stu-s_matnr2_low.
PERFORM append_fields(ztxyy_1153) USING 'S_MATNR2-HIGH' gs_stu-s_matnr2_high.
PERFORM append_screen(ztxyy_1153) USING 'SAPLSVAR' '0281'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '=SAVE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' gs_stu-rsvar_vtext.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VARIANT' gs_stu-rsvar_variant.
PERFORM append_fields(ztxyy_1153) USING 'RSVAR-VTEXT' gs_stu-rsvar_vtext.
PERFORM append_screen(ztxyy_1153) USING 'ZTXYY_1142' '1000'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_OKCODE' '/EE'.
PERFORM append_fields(ztxyy_1153) USING 'BDC_CURSOR' 'S_MATNR2-HIGH'.
CALL TRANSACTION 'ZTXYY_1142' USING bdcdata "使用的内表
" OPTIONS FROM <内表> 参照CTU_PARAMS.
"UPDATE 'S' "更新模式 S 同步 A 异步
MODE 'A'"显示模式:A 前台;N后台;E只显示错误
MESSAGES INTO messtab."用于消息提示 那个录屏阶段错误不成功
IF SY-subrc = 0.
"READ TABLE MESSTAB WITH KEY MSGID = ''"某值需要自己测
"MSGNR = ''. "某值需要自己测 由此判断成功与否
ELSE.
WRITE:/ '失败'.
*_________________新方法可以---------*
LOOP AT MESSTAB WHERE MSGTYP = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'" 用于消息提示
EXPORTING
msgid = MESSTAB-MSGID
msgnr = MESSTAB-MSGNR
MSGV1 = MESSTAB-MSGV1
MSGV2 = MESSTAB-MSGV2
MSGV3 = MESSTAB-MSGV3
MSGV4 = MESSTAB-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSAGE
.
WRITE:/ LV_MESSAGE.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM.
FORM append_screen USING VALUE(p_program)
VALUE(p_dynpo).
CLEAR bdcdata.
bdcdata-PROGRAM = p_program.
bdcdata-DYNPRO = p_dynpo.
bdcdata-dynbegin = 'X'."因为上面有值时一定为X故无需传值
bdcdata-fnam = ''.
bdcdata-fval = ''.
APPEND bdcdata.
ENDFORM.
FORM append_fields USING VALUE(p_field)
VALUE(p_value).
CLEAR bdcdata.
* BDCDATA-PROGRAM = ''.
* BDCDATA-DYNPRO = ''.
* BDCDATA-DYNBEGIN = ''."可以注释调或者删除
bdcdata-fnam = p_field.
bdcdata-fval = p_value.
APPEND bdcdata.
ENDFORM.
FORM get_data.
"数据类型转换
DATA: l_files TYPE string.
CHECK p_files IS NOT INITIAL.
FIND 'txt' IN p_files."注意这里用小写的.
IF sy-subrc = 0.
l_files = p_files.
*从文件中获取数据
*if L_FILES is not INITIAL.
CALL FUNCTION 'GUI_UPLOAD' "txt文件的读取上传
EXPORTING
filename = l_files "TXT文件要用tab分格符分开数据.
* FILETYPE = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = gt_stu
* CHANGING
* ISSCANPERFORMED = ' '
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.
* Implement suitable error handling here
ENDIF.
*endif.
ENDIF.
FIND '.xls' IN p_files.
IF sy-subrc = 0.
DATA: lt_raw TYPE truxs_t_text_data.
*excel文件的读取上传.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X' "有表头
i_tab_raw_data = lt_raw
i_filename = p_files
TABLES
i_tab_converted_data = gt_stu
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDFORM.
FORM get_help.
"获取本地文件路径
CALL FUNCTION 'WS_FILENAME_GET' "已过时
EXPORTING
* DEF_FILENAME = ' '"默认文件路径
* DEF_PATH = ' '"默认文件名称
MASK = ',excel.xls,*.xlsx,text.txt,*.txt. '
"支持的文件类型,两个逗号为一组,开头的逗号为默认的.不计入两个中excel.xls,*.xls,这样才算一组
MODE = 'O' "S保存到FILENAME这个路径,O打开FILENAME这个路径上的文件
TITLE = '打开文件' "窗口显示名称.
IMPORTING
filename = p_files
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
FORM frm_pai.
CASE sscrfields-ucomm.
WHEN 'FC01'.
PERFORM dowload_template.
ENDCASE.
ENDFORM.
FORM dowload_template.
REFRESH gt_stu2.
APPEND gt_stu2.
DATA lv_file TYPE string.
*1.获取文件路径
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
* DEF_PATH = ' '
MASK = ',EXCEL,*,XLS.' "',EXCEL,*,XLSX.'效果一样
"注意英文系统中汉字可能乱码
MODE = 'S'
* TITLE = ' '
IMPORTING
filename = lv_file
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CHECK lv_file IS NOT INITIAL.
*2将内表数据下载到指定文件路径的文件中
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = lv_file
* FILETYPE = 'ASC'
APPEND = 'X' "X表示追加 ''空表示覆盖原路径的文件
write_field_separator = 'X'
* 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
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = gt_stu2[]
* FIELDNAMES =
"一个记录这gt_stu2[]数据描述的内表会在下载文件中做为表头行
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.
* Implement suitable error handling here
ENDIF.
ENDFORM.
执行后在sm35中查看
选中执行
1.设置后台执行
2.前台执行时
/n可以跳过当前这次录屏(例如跳过第20次执行第21次及之后的)
/o后选择正确的会话点删除---就彻底离开了