选择屏幕 设定动态标题

*&---------------------------------------------------------------------*
*& Report ZTXYY_1167
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
Report ZTXYY_1167.
TYPE-POOLS:icon,slis,vrm. "声明图标 vrm用于保存列表对象
TABLES:sscrfields.",mara."引用屏幕字段属性结构
DATA GV_TITLE TYPE STRING."自定义程序标题.
SET TITLEBAR 'T001' WITH gv_title."这里仅可以使ALV或者输出语句屏幕改变标题
SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE GV_TEST. " 上传文件

  SELECTION-SCREEN: FUNCTION KEY 1. "菜单栏下载模板
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(8) GV_name FOR FIELD p_fname.
    SELECTION-SCREEN POSITION 10."距离屏幕左边界的距离
    PARAMETERS: p_fname LIKE rlgrap-filename.    " 输入文件路径

  SELECTION-SCREEN END OF LINE.


  SELECTION-SCREEN BEGIN OF LINE.
  SELECTION-SCREEN POSITION 1."距离屏幕左边界的距离
  PARAMETERS  p_rad  RADIOBUTTON GROUP g1  USER-COMMAND rad1."USER-COMMAND 要放在第一个
  SELECTION-SCREEN COMMENT 5(8) GV_rad FOR FIELD p_rad.
  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN BEGIN OF LINE.
  SELECTION-SCREEN POSITION 1."距离屏幕左边界的距离
  PARAMETERS  p_rad2 RADIOBUTTON GROUP g1 DEFAULT 'X'  .
  SELECTION-SCREEN COMMENT 5(8) GV_rad2 FOR FIELD p_rad2.
  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN COMMENT 01(54) C_NAME1  MODIF ID tex.
  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN COMMENT 01(54) C_NAME2  MODIF ID tex.
  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN COMMENT 01(54) C_NAME3  MODIF ID tex.
  SELECTION-SCREEN SKIP 1.
  SELECTION-SCREEN COMMENT 01(54) C_NAME4  MODIF ID tex.
SELECTION-SCREEN END OF BLOCK block0.



INITIALIZATION.
GV_TITLE = '文件和ALV'.
GV_TEST = '文件选取'.
GV_name = '文件路径'.
GV_rad  = '读取表头'.
GV_rad2 = '不读表头'.
C_NAME1 = '1.请下载模版'.
C_NAME2 = '2.请上传修改后的模版'.
C_NAME3 = '3.请不要修改模版格式、样式'.
C_NAME4 = '4.如果程序出错,请联系开发人员'.

*CASE sy-tcode."系统中记录tcode
*WHEN 'ZTXYY_1167'.
*  gv_title = text-t01.
*WHEN OTHERS.
*ENDCASE.
SET TITLEBAR 'T001' WITH gv_title. "这里仅可以使选择屏幕改变标题"'动态标题1'.
AT  SELECTION-SCREEN  ON  VALUE-REQUEST  FOR p_fname .
  PERFORM select_file  CHANGING p_fname .
FORM select_file  CHANGING t_selfile .
  DATA : l_rc        TYPE  I,
        l_filetable  TYPE filetable,
        lv_filter    type string
        .
lv_filter = 'EXCEL-Files (*.XLS)|*.XLS|EXCEL-Files (*.XLSX)|*.XLSX|All Files(*.*)|*.*|'.

*
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
  EXPORTING
    window_title            = '请选择本地文件'     "窗口标题
*    default_extension       =
*    default_filename        =
    file_filter             = lv_filter"'文本文件 (*.txt)|*.txt|全部文件 (*.*)|*.*|'
*    with_encoding           =
*    initial_directory       =
    multiselection          = space
  CHANGING
    file_table              = l_filetable
    rc                      = l_rc              "程序运行情况sy-ucomm
*    user_action             =
*    file_encoding           =
  EXCEPTIONS
    file_open_dialog_failed = 1
    cntl_error              = 2
    error_no_gui            = 3
    not_supported_by_gui    = 4
    others                  = 5
    .
  IF sy-subrc = 0 AND l_rc = 1.
    READ  TABLE l_filetable  INTO t_selfile  INDEX  1 .
* Implement suitable error handling here
  ENDIF.

ENDFORM .                     "SELECT_FILE


START-OF-SELECTION.

WRITE p_fname.

ABAP程序中,可以利用‘&’占位符实现动态指定标题栏(titlebar)的显示文本,占位符最多为9个

语法如下:

SET TITLEBAR title [WITH text1 ... text9].

例子代码:

REPORT ztest_titelbar.

SET TITLEBAR 'T001' WITH 'one' 'two' 'there' 'four'.

WRITE: 'hello world'.

标题栏(titlebar):

选择屏幕 设定动态标题_第1张图片

程序运行效果:

选择屏幕 设定动态标题_第2张图片 

你可能感兴趣的:(abap,前端,javascript,github)