1. Dialog box for confirming processing step (CONFIRM, POPUP)
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = text-006
titel = text-005
IMPORTING
answer = t_code.
CHECK t_code = 'J'.
2. Dialog box for confirming processing step: With diagnosis text
CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
EXPORTING
titel = text-100
diagnosetext1 = text
diagnosetext2 = text-102
textline1 = text-103
defaultoption = 'Y'
IMPORTING
answer = answer.
IF answer = 'A' OR answer = 'N'.
ELSEIF answer = 'J'.
ENDIF.
3. Dialog box for choosing from a list without diagnosis(提供选择列表供用户选择)
*填充选项列表:
selectlist-varoption = 'A. Wal Mart'.
APPEND selectlist.
selectlist-varoption = 'B. COLE'.
APPEND selectlist.
selectlist-varoption = 'C. Private lable'.
APPEND selectlist.
*显示列表dialog供用户选择
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
mark_flag = 'X'
mark_max = 0
textline1 = '请选择执行标准'
titel = '请选择执行标准:'
TABLES
t_spopli = selectlist
EXCEPTIONS
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
OTHERS = 4.
IF sy-subrc = 0.
ENDIF.
4.上载文件(自带路径选择对话框的上载函数UPLOAD,下载DOWNLOAD)
PARAMETER: P_FILE LIKE RLGRAP-FILENAME.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = IN_PRO.
5.选择屏幕的值选择对话框(按F4出现)
DATA: BEGIN OF fields OCCURS 3.
INCLUDE STRUCTURE help_value.
DATA: END OF fields.
DATA: BEGIN OF valuetab OCCURS 3,
atwrt LIKE cawn-atwrt,
atwtb LIKE cawnt-atwtb,
END OF valuetab.
SELECT-OPTIONS: p_cost FOR cawn-atwrt.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cost-low.
PERFORM get_value .
CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
EXPORTING
title_in_values_list = '成本分类﹕'
titel = '请选择成本分类:'
IMPORTING
select_value = p_cost-low
TABLES
fields = fields
valuetab = valuetab.
FORM get_value .
CLEAR fields. REFRESH fields.
CLEAR valuetab. REFRESH valuetab.
fields-tabname = 'CAWN'.
fields-fieldname = 'ATWRT'.
fields-selectflag = 'X'.
APPEND fields. CLEAR fields.
SELECT b~atwrt c~atwtb
INTO CORRESPONDING FIELDS OF TABLE valuetab
FROM cabn AS a INNER JOIN cawn AS b ON
a~atinn = b~atinn INNER JOIN cawnt AS c
ON b~atinn = c~atinn AND b~atzhl = c~atzhl
WHERE a~atnam = 'ADDITIONAL_MATERIAL_CHAR'
AND c~spras = 'M'.
ENDFORM. " get_value
6.选择屏幕日期选择对话框(F4)
DATA: week_s LIKE sy-datum,
week_e LIKE sy-datum.
PARAMETER: s_week LIKE scal-week OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_week.
PERFORM get_week.
FORM get_week.
DATA: sel_week LIKE scal-week.
CLEAR: week_s,week_e.
CALL FUNCTION 'F4_DATE'
IMPORTING
select_week = sel_week
select_week_begin = week_s
select_week_end = week_e
EXCEPTIONS
calendar_buffer_not_loadable = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5
holiday_calendar_not_found = 6
parameter_conflict = 7
OTHERS = 8.
IF sy-subrc = 0.
s_week = sel_week.
ENDIF.
ENDFORM. " get_week
7.信息List提示框:
DATA w_display1(70) TYPE c.
DATA w_display2(70) TYPE c.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
titel = '还有尚未确认的单据:'
textline1 = w_display1
textline2 = w_display2
start_column = 10
start_row = 6.
8. Dialog Box for the Display of a Text List (Texts in a Table)显示文本List
DATA: t_line LIKE TABLE OF tline WITH HEADER LINE.
CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
EXPORTING
task = 'DISPLAY'
titel = text-004
TABLES
text_table = t_line.
9.文件路径选择对话框
DATA: t_path LIKE rlgrap-filename. "文件路径
**取文件路径
PARAMETERS: p_file LIKE rlgrap-filename .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_filename.
FORM get_filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = '*.XLS'
static = 'X'
CHANGING
file_name = P_FILE
EXCEPTIONS
mask_too_long = 1.
IF sy-subrc <> 0.
MESSAGE e999 WITH '路径不正确或选择文件错误'.
ENDIF.
ENDFORM.
10.调用方法产生文件路径对话框
DATA: p_file LIKE rlgrap-filename.
FIELD-SYMBOLS <fs> TYPE file_table.
FIELD-SYMBOLS <f>.
DATA: f_table TYPE filetable.
DATA: rc TYPE i.
DATA: user_action TYPE i.
DATA: l_index TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择要汇入的文件'
file_filter = 'Excel files (*.XLS)|*.XLS'
initial_directory = 'D:\'
CHANGING
file_table = f_table
rc = rc
user_action = user_action
EXCEPTIONS
cntl_error = 1
file_open_dialog_failed = 2
error_no_gui = 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <fs> INDEX 1.
IF sy-subrc = 0.
p_file = <fs>-filename.
ENDIF.
11.提示信息dialog
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = '汇入文件说明'
txt1 = text-004
txt2 = text-005
txt3 = text-006
txt4 = text-007.
12.程序运行时状态栏提示
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
percentage = 0
text = t_text. “t_text:数据处理中
13. Dialog box for displaying a text with parameters(例程:RGUREP01)
INITIALIZATION.
PERFORM README_FIRST.
FORM README_FIRST.
CLEAR SAVE_TCODE.
MOVE SY-TCODE TO SAVE_TCODE.
CLEAR SY-TCODE.
IF SY-BATCH EQ SPACE.
IF SAVE_TCODE EQ 'SE38'.
CALL FUNCTION 'POPUP_DISPLAY_TEXT_WITH_PARAMS'
EXPORTING
LANGUAGE = SY-LANGU
POPUP_TITLE = TEXT-400
* START_COLUMN = 10
* START_ROW = 3
TEXT_OBJECT = 'GLX_TABLE_REPAIR'
IMPORTING
CANCELLED = ANSWER
TABLES
PARAMETERS = TEXT_PARAMS
EXCEPTIONS
ERROR_IN_TEXT = 1
TEXT_NOT_FOUND = 2
OTHERS = 3.
IF ANSWER NE SPACE.
CLEAR ANSWER.
LEAVE TO TRANSACTION SAVE_TCODE.
ELSE.
* EXIT.
CLEAR SY-TCODE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
14.文件路径get
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = FILENAME
DEF_PATH = '\'
MASK = ',*.*,*.csv;*.txt.'
MODE = 'O'
TITLE = TEXTDAW
* 'Dateiauswahl'(flw)
IMPORTING
FILENAME = FILENAME
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC <> 0. ENDIF. " ok
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = text-006
titel = text-005
IMPORTING
answer = t_code.
CHECK t_code = 'J'.
2. Dialog box for confirming processing step: With diagnosis text
CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
EXPORTING
titel = text-100
diagnosetext1 = text
diagnosetext2 = text-102
textline1 = text-103
defaultoption = 'Y'
IMPORTING
answer = answer.
IF answer = 'A' OR answer = 'N'.
ELSEIF answer = 'J'.
ENDIF.
3. Dialog box for choosing from a list without diagnosis(提供选择列表供用户选择)
*填充选项列表:
selectlist-varoption = 'A. Wal Mart'.
APPEND selectlist.
selectlist-varoption = 'B. COLE'.
APPEND selectlist.
selectlist-varoption = 'C. Private lable'.
APPEND selectlist.
*显示列表dialog供用户选择
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
mark_flag = 'X'
mark_max = 0
textline1 = '请选择执行标准'
titel = '请选择执行标准:'
TABLES
t_spopli = selectlist
EXCEPTIONS
not_enough_answers = 1
too_much_answers = 2
too_much_marks = 3
OTHERS = 4.
IF sy-subrc = 0.
ENDIF.
4.上载文件(自带路径选择对话框的上载函数UPLOAD,下载DOWNLOAD)
PARAMETER: P_FILE LIKE RLGRAP-FILENAME.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = IN_PRO.
5.选择屏幕的值选择对话框(按F4出现)
DATA: BEGIN OF fields OCCURS 3.
INCLUDE STRUCTURE help_value.
DATA: END OF fields.
DATA: BEGIN OF valuetab OCCURS 3,
atwrt LIKE cawn-atwrt,
atwtb LIKE cawnt-atwtb,
END OF valuetab.
SELECT-OPTIONS: p_cost FOR cawn-atwrt.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_cost-low.
PERFORM get_value .
CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
EXPORTING
title_in_values_list = '成本分类﹕'
titel = '请选择成本分类:'
IMPORTING
select_value = p_cost-low
TABLES
fields = fields
valuetab = valuetab.
FORM get_value .
CLEAR fields. REFRESH fields.
CLEAR valuetab. REFRESH valuetab.
fields-tabname = 'CAWN'.
fields-fieldname = 'ATWRT'.
fields-selectflag = 'X'.
APPEND fields. CLEAR fields.
SELECT b~atwrt c~atwtb
INTO CORRESPONDING FIELDS OF TABLE valuetab
FROM cabn AS a INNER JOIN cawn AS b ON
a~atinn = b~atinn INNER JOIN cawnt AS c
ON b~atinn = c~atinn AND b~atzhl = c~atzhl
WHERE a~atnam = 'ADDITIONAL_MATERIAL_CHAR'
AND c~spras = 'M'.
ENDFORM. " get_value
6.选择屏幕日期选择对话框(F4)
DATA: week_s LIKE sy-datum,
week_e LIKE sy-datum.
PARAMETER: s_week LIKE scal-week OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_week.
PERFORM get_week.
FORM get_week.
DATA: sel_week LIKE scal-week.
CLEAR: week_s,week_e.
CALL FUNCTION 'F4_DATE'
IMPORTING
select_week = sel_week
select_week_begin = week_s
select_week_end = week_e
EXCEPTIONS
calendar_buffer_not_loadable = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5
holiday_calendar_not_found = 6
parameter_conflict = 7
OTHERS = 8.
IF sy-subrc = 0.
s_week = sel_week.
ENDIF.
ENDFORM. " get_week
7.信息List提示框:
DATA w_display1(70) TYPE c.
DATA w_display2(70) TYPE c.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
titel = '还有尚未确认的单据:'
textline1 = w_display1
textline2 = w_display2
start_column = 10
start_row = 6.
8. Dialog Box for the Display of a Text List (Texts in a Table)显示文本List
DATA: t_line LIKE TABLE OF tline WITH HEADER LINE.
CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
EXPORTING
task = 'DISPLAY'
titel = text-004
TABLES
text_table = t_line.
9.文件路径选择对话框
DATA: t_path LIKE rlgrap-filename. "文件路径
**取文件路径
PARAMETERS: p_file LIKE rlgrap-filename .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_filename.
FORM get_filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = '*.XLS'
static = 'X'
CHANGING
file_name = P_FILE
EXCEPTIONS
mask_too_long = 1.
IF sy-subrc <> 0.
MESSAGE e999 WITH '路径不正确或选择文件错误'.
ENDIF.
ENDFORM.
10.调用方法产生文件路径对话框
DATA: p_file LIKE rlgrap-filename.
FIELD-SYMBOLS <fs> TYPE file_table.
FIELD-SYMBOLS <f>.
DATA: f_table TYPE filetable.
DATA: rc TYPE i.
DATA: user_action TYPE i.
DATA: l_index TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择要汇入的文件'
file_filter = 'Excel files (*.XLS)|*.XLS'
initial_directory = 'D:\'
CHANGING
file_table = f_table
rc = rc
user_action = user_action
EXCEPTIONS
cntl_error = 1
file_open_dialog_failed = 2
error_no_gui = 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <fs> INDEX 1.
IF sy-subrc = 0.
p_file = <fs>-filename.
ENDIF.
11.提示信息dialog
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = '汇入文件说明'
txt1 = text-004
txt2 = text-005
txt3 = text-006
txt4 = text-007.
12.程序运行时状态栏提示
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
percentage = 0
text = t_text. “t_text:数据处理中
13. Dialog box for displaying a text with parameters(例程:RGUREP01)
INITIALIZATION.
PERFORM README_FIRST.
FORM README_FIRST.
CLEAR SAVE_TCODE.
MOVE SY-TCODE TO SAVE_TCODE.
CLEAR SY-TCODE.
IF SY-BATCH EQ SPACE.
IF SAVE_TCODE EQ 'SE38'.
CALL FUNCTION 'POPUP_DISPLAY_TEXT_WITH_PARAMS'
EXPORTING
LANGUAGE = SY-LANGU
POPUP_TITLE = TEXT-400
* START_COLUMN = 10
* START_ROW = 3
TEXT_OBJECT = 'GLX_TABLE_REPAIR'
IMPORTING
CANCELLED = ANSWER
TABLES
PARAMETERS = TEXT_PARAMS
EXCEPTIONS
ERROR_IN_TEXT = 1
TEXT_NOT_FOUND = 2
OTHERS = 3.
IF ANSWER NE SPACE.
CLEAR ANSWER.
LEAVE TO TRANSACTION SAVE_TCODE.
ELSE.
* EXIT.
CLEAR SY-TCODE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
14.文件路径get
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = FILENAME
DEF_PATH = '\'
MASK = ',*.*,*.csv;*.txt.'
MODE = 'O'
TITLE = TEXTDAW
* 'Dateiauswahl'(flw)
IMPORTING
FILENAME = FILENAME
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC <> 0. ENDIF. " ok