ABAP Control Framework(6): Calendar
6.Calendar
使用cl_gui_calendar类生成不同样式的日期选择器。
示例:
CLASS c5 DEFINITION. PUBLIC SECTION. DATA:lo_splitter_container TYPE REF TO cl_gui_splitter_container. DATA:lo_calendar1 TYPE REF TO cl_gui_calendar. DATA:lo_calendar2 TYPE REF TO cl_gui_calendar. DATA:lo_calendar3 TYPE REF TO cl_gui_calendar. DATA:lo_calendar4 TYPE REF TO cl_gui_calendar. DATA:lo_calendar5 TYPE REF TO cl_gui_calendar. DATA:lo_calendar6 TYPE REF TO cl_gui_calendar. METHODS:m_init_container. METHODS:m_init_calendar. ENDCLASS. CLASS c5 IMPLEMENTATION. METHOD:m_init_container. "生成一个6行1列的容器 CREATE OBJECT lo_splitter_container EXPORTING parent = cl_gui_splitter_container=>default_screen link_dynnr = '100' link_repid = sy-repid height = 500 "行,列格子 rows = 3 columns = 2. ENDMETHOD. METHOD:m_init_calendar. DATA:lv_view_style TYPE I. DATA:lv_sel_style TYPE I. DATA:lo_container TYPE REF TO cl_gui_container. "初始化calendar "日期时间选择样式 lv_view_style = cnca_style_dtpicker. "获取容器 lo_container = lo_splitter_container->get_container( row = 1 column = 1 ). CREATE OBJECT lo_calendar1 EXPORTING parent = lo_container view_style = lv_view_style. "弹出日期选择 lv_view_style = cnca_style_popup_navigator. lo_container = lo_splitter_container->get_container( row = 1 column = 2 ). CREATE OBJECT lo_calendar2 EXPORTING parent = lo_container view_style = lv_view_style. "竖直日期选择导航 lv_view_style = cnca_style_v_navigator. lo_container = lo_splitter_container->get_container( row = 2 column = 1 ). CREATE OBJECT lo_calendar3 EXPORTING parent = lo_container view_style = lv_view_style. "水平日期选择导航 lv_view_style = cnca_style_h_navigator. lv_sel_style = cnca_sel_day + cnca_sel_week + cnca_sel_month + cnca_sel_interval. lo_container = lo_splitter_container->get_container( row = 2 column = 2 ). CREATE OBJECT lo_calendar4 EXPORTING parent = lo_container view_style = lv_view_style selection_style = lv_sel_style. "竖直日期选择导航,及日期选择 lv_view_style = cnca_style_v_navigator + cnca_style_dtpicker. lo_container = lo_splitter_container->get_container( row = 3 column = 1 ). CREATE OBJECT lo_calendar5 EXPORTING parent = lo_container view_style = lv_view_style. "popup日期选择导航,及日期选择 lv_view_style = cnca_style_popup_navigator + cnca_style_dtpicker. lo_container = lo_splitter_container->get_container( row = 3 column = 2 ). CREATE OBJECT lo_calendar6 EXPORTING parent = lo_container view_style = lv_view_style dtpicker_format = 'dddd mmm dd.MM.yyy'. "dtpicker_format "'d' :One- or two-character date "'dd' :Two-character date "'ddd' :Three-character abbreviation of weekday "'dddd' :Name of weekday "'MM' :Two-digit month number "'MMM':Three-character abbreviation of month name "'MMMM' :Full month name "'y' :One-digit year display (for example, 9 for 1999) "'yy' :Two-digit year display "'yyy' :Full year display "focus_date:初始日期设置 "stand_alone:是否触发event:info_request,'X'不触发 ENDMETHOD. ENDCLASS.