文章目录
前言
1.POPUP_TO_DISPLAY_TEXT
2.POPUP_TO_CONFIRM
3.G_DISPLAY_SELECTION_DYNPRO
4.REUSE_ALV_POPUP_TO_SELECT
5.POPUP_TO_DECIDE_LIST
6.POPUP_WITH_TABLE_DISPLAY_OK
7.BKK_POPUP_DISPLAY_LIST
8. POPUP_TO_CONFIRM_WITH_MESSAGE
9.POPUP_TO_CONFIRM
10.POPUP_TO_DECIDE
11.POPUP_GET_VALUES_USER_HELP 提示框可输入
总结
前言
ABAP有各种各样的提示框类型,在不通的需求中可以用到不同展示、功能的提示框,持续更新。。。
1.POPUP_TO_DISPLAY_TEXT
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2024/04/19
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.*如果没有数据,提示还没有审核数据,请点击提取数据按钮
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'EXPORTINGtitel = '温馨提示:'textline1 = '没有检索到数据!'textline2 = ' 'start_column = 25start_row = 6.
2.POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2024/04/19
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_answer.CALL FUNCTION 'POPUP_TO_CONFIRM'EXPORTINGtitlebar = '温馨提示: '
* DIAGNOSE_OBJECT =text_question = '数是否保存数据? 'text_button_1 = 'YES'
* ICON_BUTTON_1 =text_button_2 = 'NO'
* ICON_BUTTON_2 = ' 'default_button = '1'display_cancel_button = ' '
* USERDEFINED_F1_HELP = ' 'start_column = 35start_row = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' 'IMPORTINGanswer = lv_answer
* TABLES
* PARAMETER =EXCEPTIONStext_not_found = 1OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.CHECK lv_answer = 1.WRITE:'保存成功!'.
3.G_DISPLAY_SELECTION_DYNPRO
4.REUSE_ALV_POPUP_TO_SELECT
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2024/04/19
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.*&---------------------------------------------------------------------*
* TYPES
*&---------------------------------------------------------------------*
TABLES:sflight.
TYPES:BEGIN OF ty_alv,sel TYPE sel,carrid TYPE sflight-carrid, " 航线代码fldate TYPE sflight-fldate, " 航班日期price TYPE sflight-price, " 航空运费planetype TYPE sflight-planetype, " 飞机类型paymentsum TYPE sflight-paymentsum, " 当前预定总数END OF ty_alv,tt_alv TYPE STANDARD TABLE OF ty_alv.*&---------------------------------------------------------------------*
* CONSTANTS
*&---------------------------------------------------------------------*
CONSTANTS:BEGIN OF c_fcat,name01 TYPE fieldname VALUE 'CARRID ',text01 TYPE fieldtext VALUE '航线代码',name02 TYPE fieldname VALUE 'FLDATE ',text02 TYPE fieldtext VALUE '航班日期',name03 TYPE fieldname VALUE 'PRICE ',text03 TYPE fieldtext VALUE '航空运费',name04 TYPE fieldname VALUE 'PLANETYPE ',text04 TYPE fieldtext VALUE '飞机类型',name05 TYPE fieldname VALUE 'PAYMENTSUM ',text05 TYPE fieldtext VALUE '当前预定总数',END OF c_fcat.*&---------------------------------------------------------------------*
* DEFIEN ALV
*&---------------------------------------------------------------------*
DATA:gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA:lv_message TYPE string.*&---------------------------------------------------------------------*
* GLOBAL INTERNAL TABLES
*&---------------------------------------------------------------------*
DATA:gt_alv TYPE tt_alv.*&---------------------------------------------------------------------*
* GLOBAL MACROS
*&---------------------------------------------------------------------*
DEFINE macro_fcat.ls_fieldcat-fieldname = &1.ls_fieldcat-seltext_l = &2.ls_fieldcat-outputlen = &3.APPEND ls_fieldcat TO gt_fieldcat.CLEAR ls_fieldcat.
END-OF-DEFINITION.*&----------------------------------------------------------------------
*& START-OF-SELECTION
*&----------------------------------------------------------------------
START-OF-SELECTION.
* 获取数据SELECTcarrid,fldate,price,planetype,paymentsumFROM sflightINTO CORRESPONDING FIELDS OF TABLE @gt_alvUP TO 20 ROWS.DATA:ls_fieldcat TYPE slis_fieldcat_alv.macro_fcat:c_fcat-name01 c_fcat-text01 10,c_fcat-name03 c_fcat-text03 10,c_fcat-name05 c_fcat-text05 10,c_fcat-name04 c_fcat-text04 10,c_fcat-name02 c_fcat-text02 10.* 展示CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'EXPORTINGi_title = '(JYH)航班信息表:'
* I_SELECTION = ‘X‘
* I_ALLOW_NO_SELECTION =i_zebra = 'X'
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0i_checkbox_fieldname = 'SEL'
* I_LINEMARK_FIELDNAME =
* I_SCROLL_TO_SEL_LINE = ‘X‘i_tabname = 'GT_ALV'
* I_STRUCTURE_NAME =it_fieldcat = gt_fieldcat
* IT_EXCLUDING =
* I_CALLBACK_PROGRAM =
* I_CALLBACK_USER_COMMAND =
* IS_PRIVATE =
* IMPORTING
* ES_SELFIELD =
* E_EXIT =TABLESt_outtab = gt_alvEXCEPTIONSprogram_error = 1OTHERS = 2.IF sy-subrc <> 0 .CALL FUNCTION 'MESSAGE_TEXT_BUILD'EXPORTINGmsgid = sy-msgidmsgnr = sy-msgnomsgv1 = sy-msgv1msgv2 = sy-msgv2msgv3 = sy-msgv3msgv4 = sy-msgv4IMPORTINGmessage_text_output = lv_message.MESSAGE lv_message TYPE 'E'.ELSE .LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<fs_alv>) WHERE sel = 'X' .DATA(lv_bix) = CONV char100( sy-tabix ).CONCATENATE lv_message '您选中的有第' lv_bix '行...' INTO lv_message.ENDLOOP.IF sy-subrc NE 0.lv_message = '用户已经取消操作!'.ENDIF.MESSAGE lv_message TYPE 'I' .ENDIF .
5.POPUP_TO_DECIDE_LIST
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2024/04/19
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lt_spopli TYPE TABLE OF spopli,ls_spopli TYPE spopli.
DATA:lv_antwort TYPE c,lv_message TYPE string.* 添加选择参数
ls_spopli-varoption = 'SD'.
APPEND ls_spopli TO lt_spopli.
ls_spopli-varoption = 'MM'.
APPEND ls_spopli TO lt_spopli.
ls_spopli-varoption = 'ABAP'.
APPEND ls_spopli TO lt_spopli.
ls_spopli-varoption = 'PP'.
APPEND ls_spopli TO lt_spopli.
ls_spopli-varoption = 'FI'.
APPEND ls_spopli TO lt_spopli.CALL FUNCTION 'POPUP_TO_DECIDE_LIST'EXPORTING
* CURSORLINE = 1mark_flag = 'X' "选择框标志:X = 复选框,空 = 单选框mark_max = 4 "最大选择数start_col = 35start_row = 6textline1 = 'SAP你最熟悉的模块有哪些?'
* TEXTLINE2 = ' '
* TEXTLINE3 = ' 'titel = 'SAP调查问卷:'
* DISPLAY_ONLY = ' 'IMPORTINGanswer = lv_antwortTABLESt_spopli = lt_spopliEXCEPTIONSnot_enough_answers = 1too_much_answers = 2too_much_marks = 3OTHERS = 4.
IF sy-subrc NE 0.
* 系统返回消息CALL FUNCTION 'MESSAGE_TEXT_BUILD'EXPORTINGmsgid = sy-msgidmsgnr = sy-msgnomsgv1 = sy-msgv1msgv2 = sy-msgv2msgv3 = sy-msgv3msgv4 = sy-msgv4IMPORTINGmessage_text_output = lv_message.MESSAGE lv_message TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.LOOP AT lt_spopli ASSIGNING FIELD-SYMBOL(<fs_spopli>).ENDLOOP.
缺点:弹出窗口的大小不能设置;弹出供选择窗口,最多为25个选项选择可以是单选或是多选。
6.POPUP_WITH_TABLE_DISPLAY_OK
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2024/04/19
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.SELECTconcat( carrid , '这个是个长文本' ) AS aFROM sflightINTO TABLE @DATA(gt_alv)UP TO 20 ROWS.CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY_OK'EXPORTINGendpos_col = 90endpos_row = 10startpos_col = 1startpos_row = 1titletext = '长文本展示:'
* IMPORTING
* CHOISE =TABLESvaluetab = gt_alvEXCEPTIONSbreak_off = 1OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
7.BKK_POPUP_DISPLAY_LIST
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2023/11/22
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_answer TYPE rsnewleng-fcode,lt_user_buttons TYPE TABLE OF smp_dyntxt.lt_user_buttons = VALUE #( ( icon_id = icon_transporttext = '下发'icon_text = '下发'quickinfo = '下发按钮' ) ).CALL FUNCTION 'BKK_POPUP_DISPLAY_LIST'EXPORTINGi_callback_program = sy-repid "程序名i_callback_write_form = 'FRM_WRITE_CONTENTS' "输出表内容的form名i_title = '温馨提示:'i_start_column = 25i_start_row = 15i_end_column = 60i_end_row = 20i_display_ok_button = 'X'i_display_cancel_button = 'X'IMPORTINGanswer = lv_answerTABLESuser_buttons = lt_user_buttons.
IF sy-subrc = 0.ENDIF.*&---------------------------------------------------------------------*
*& Form frm_write_contents
*&---------------------------------------------------------------------*
FORM frm_write_contents.WRITE :'FRM_WRITE_CONTENTS 里的输出数据'.WRITE : lv_answer.ENDFORM. "l_server_info_contents
8. POPUP_TO_CONFIRM_WITH_MESSAGE
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2023/11/22
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_answer TYPE rsnewleng-fcode.CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'EXPORTINGdefaultoption = 'Y' " 定位光标,以应答“是”或“否”diagnosetext1 = '数据下发失败!' " 诊断文本的第一行diagnosetext2 = '数据库表更新失败!' " 诊断文本的第二行diagnosetext3 = '销售订单取消操作!' " 诊断文本的第三行textline1 = '请联系IT人员:Jiangyh'textline2 = |联系电话:176XXXXXXXX 日期:{ sy-datum }|titel = '错误提示:'start_column = 25start_row = 6cancel_display = 'X' " X = 显示取消 空 = 不显示IMPORTINGanswer = lv_answer.IF sy-subrc = 0.ENDIF.
9.POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2023/11/22
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_answer TYPE rsnewleng-fcode.CALL FUNCTION 'POPUP_TO_CONFIRM'EXPORTINGtext_question = '确定要删除吗'icon_button_1 = '1.确定'icon_button_2 = '2.不确定'default_button = '2'display_cancel_button = 'X'start_column = 25start_row = 6IMPORTINGanswer = lv_answerEXCEPTIONStext_not_found = 1OTHERS = 2.IF sy-subrc = 0.ENDIF.
10.POPUP_TO_DECIDE
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2023/11/22
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_answer TYPE rsnewleng-fcode.CALL FUNCTION 'POPUP_TO_DECIDE'EXPORTINGdefaultoption = '1'textline1 = '操作说明:'textline2 = '1.下发系统为:MES WMS OA'textline3 = '2.删除错误数据'text_option1 = '删除数据'text_option2 = '下发数据'icon_text_option1 = '@11@'icon_text_option2 = '@4A@'titel = '错误提示:'start_column = 25start_row = 6cancel_display = 'X'IMPORTINGanswer = lv_answer.IF sy-subrc = 0.ENDIF.
11.POPUP_GET_VALUES_USER_HELP 提示框可输入
*&---------------------------------------------------------------------*
*& 程 序 名:YTEST_001
*& 程序描述:ABAP 提示框
*& 创 建 者:JIANGYH
*& 创建日期:2023/11/22
*&---------------------------------------------------------------------*
*& 版本 修改者(公司) 日期 修改描述
*& 1.0.0 XXXX YYYYMMDD 创建程序
*&---------------------------------------------------------------------*
REPORT ytest_001.DATA:lv_flg TYPE c,gt_tab TYPE TABLE OF sval.gt_tab = VALUE #( ( tabname = 'AFKO'fieldname = 'AUFNR'fieldtext = '生产订单号'field_attr = '02'"字段是否能输入,是通过函数输入table参数fields中的字段field_attr来控制value = '0100000001' )( tabname = 'AFKO'fieldname = 'GAMNG'fieldtext = '订单数量'field_attr = ''field_obl = 'X' ) ). "必输项CALL FUNCTION 'POPUP_GET_VALUES_USER_HELP'EXPORTING
* F1_FORMNAME = ' '
* F1_PROGRAMNAME = ' '
* F4_FORMNAME = ' '
* F4_PROGRAMNAME = ' '
* FORMNAME = ' 'popup_title = '请填写数据!'
* PROGRAMNAME = ' '
* START_COLUMN = '5'
* START_ROW = '5'
* NO_CHECK_FOR_FIXED_VALUES = ' 'IMPORTINGreturncode = lv_flg "√是空 x是aTABLESfields = gt_tabEXCEPTIONSerror_in_fields = 1OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.READ TABLE gt_tab INDEX 2 INTO DATA(ls_tab).IF sy-subrc = 0.CONDENSE ls_tab-value.WRITE:ls_tab-value LEFT-JUSTIFIED.ENDIF.
ENDIF.
总结
持续更新。。。