SM30中如何实现上载数据到TC控件的界面并保存.docx
《SM30中如何实现上载数据到TC控件的界面并保存.docx》由会员分享,可在线阅读,更多相关《SM30中如何实现上载数据到TC控件的界面并保存.docx(10页珍藏版)》请在冰豆网上搜索。
SM30中如何实现上载数据到TC控件的界面并保存
SM30中如何实现上载数据到TC控件的界面并保存
前言:
之前看过我的另一篇文章可能会认为在SM30中上载数据和其他自定义功能一样也直接写代码对内表extract进APPEND操作就好了,其实不是这样,下面把详细的步骤写在这里.
第一步:
为生成的SM30界面的GUI状态添加按钮
详见:
为SM30视图添加按钮
本例中是修改的EULG:
第二步:
为按钮对应的function编写代码
1、PBO\PAI编码:
调用自定义的MODULE处理相关按钮的事件相应(黄色是自定义代码)
PROCESS BEFORE OUTPUT.
MODULE liste_initialisieren.
LOOP AT extract WITH CONTROL
tctrl_ymbcvusr16 CURSOR nextline.
MODULE liste_show_liste.
ENDLOOP.
*
PROCESS AFTER INPUT.
MODULE liste_exit_command AT EXIT-COMMAND.
MODULE liste_before_loop.
LOOP AT extract.
MODULE liste_init_workarea.
CHAIN.
FIELD ymbcvusr16-bname .
FIELD ymbcvusr16-name_text .
FIELD ymbcvusr16-treever .
FIELD ymbcvusr16-node .
FIELD ymbcvusr16-nodename .
FIELD ymbcvusr16-cuser .
FIELD ymbcvusr16-cdate .
FIELD ymbcvusr16-ctime .
MODULE set_update_flag ON CHAIN-REQUEST.
MODULE complete_ymbcvusr16 ON CHAIN-REQUEST.
ENDCHAIN.
FIELD vim_marked MODULE liste_mark_checkbox.
CHAIN.
FIELD ymbcvusr16-bname .
FIELD ymbcvusr16-treever .
FIELD ymbcvusr16-node .
MODULE liste_update_liste.
ENDCHAIN.
ENDLOOP.
MODULE liste_after_loop.
MODULE customize_user_commond.
2、处理代码:
注意有上载数据的部分
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module CUSTOMIZE_USER_COMMOND INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE customize_user_commond INPUT.
CLEAR gt_return.
CASE function.
WHEN 'DOWNLOAD'.
PERFORM frm_download_temp USING gc_16tmp CHANGING gt_return.
WHEN 'UPLOAD'.
* BREAK-POINT.
PERFORM sub_upload_16tmp TABLES extract total CHANGING gt_return.
ENDCASE.
IF function = 'DOWNLOAD' OR function = 'UPLOAD'.
CALL FUNCTION 'YMBC_DISPLAY_RETURN'
EXPORTING
i_title = sy-title
i_textline1 = text-m01
* i_textline2 =
* IMPORTING
* E_ANSWER =
TABLES
it_return = gt_return.
ENDIF.
ENDMODULE. " CUSTOMIZE_USER_COMMOND INPUT
*&---------------------------------------------------------------------*
*& Form FRM_DOWNLOAD_TEMP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GC_16TMP text
* <--P_GT_RETURN text
*----------------------------------------------------------------------*
FORM frm_download_temp USING p_temp TYPE w3objid
CHANGING pt_return TYPE gtyt_return.
DATA:
l_path LIKE rlgrap-filename,
l_subrc LIKE sy-subrc.
PERFORM get_localfilepath
USING
'XLS'
'S'
'请选择模板保存到本地的地址'
'FILE'
CHANGING
l_path.
IF l_path IS INITIAL.
PERFORM add_bapi_return_v2
TABLES
pt_return
USING
'A'
gc_msgid
'013'
''
'下载模板'
''
''
''.
EXIT.
ENDIF.
PERFORM smw0_file_download
USING
p_temp
l_path
l_subrc.
IF l_subrc <> 0.
PERFORM add_bapi_return_v2
TABLES
pt_return
USING
'E'
gc_msgid
'001'
''
'下载模板'
''
''
''.
EXIT.
ELSE.
PERFORM add_bapi_return_v2
TABLES
pt_return
USING
'S'
gc_msgid
'002'
''
'下载模板'
''
''
''.
ENDIF.
ENDFORM. " FRM_DOWNLOAD_TEMP
*----------------------------------------------------------------------*
***INCLUDE LYMBCVUSR16F01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_16TMP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXTRACT text
*----------------------------------------------------------------------*
FORM sub_upload_16tmp TABLES pt_extract
pt_total
CHANGING pt_return TYPE gtyt_return.
TYPES:
BEGIN OF ltys_excel,
line(4096) TYPE c,
END OF ltys_excel.
DATA: