ALV开发框架

REPORT ZABAP1903_11_LIANXI06.
&---------------------------------------------------------------------
*& Report ZABAP1903_11_BASIC011
*&
&---------------------------------------------------------------------
*&
*&
&---------------------------------------------------------------------
///引入类型池
type-pools:slis.
data:gt_fieldcat type slis_t_fieldcat_alv, 存放表头的内表
wa_fieldcat type slis_fieldcat_alv, 存放列标题的工作区
wa_layout type slis_layout_alv. 报表样式工作区

image.png

TYPES:BEGIN OF zty_sflight,
CARRID type sflight-carrid, 航班代码
FLDATE TYPE sflight-fldate, 航班日期
PRICE TYPE sflight-price,
PLANETYPE TYPE sflight-PLANETYPE,
CITYFROM TYPE spfli-CITYFROM,
CITYTO type spfli-CITYTO,
FLTIME type spfli-FLTIME,
end of zty_sflight.

data: gt_itab TYPE TABLE OF zty_sflight,
wa_itab TYPE zty_sflight.

PERFORM f_layout.
PERFORM f_fieldcat.
PERFORM get_data. "获取数据
PERFORM f_alvprint.
&---------------------------------------------------------------------
*& Form F_LAYOUT
&---------------------------------------------------------------------

  •   text
    

----------------------------------------------------------------------

  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM F_LAYOUT .
    wa_layout-zebra = 'X'.
    wa_layout-colwidth_optimize = 'X'.
    ENDFORM. " F_LAYOUT
    &---------------------------------------------------------------------
    *& Form F_FIELDCAT
    &---------------------------------------------------------------------
  •   text
    

----------------------------------------------------------------------

  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM F_FIELDCAT .
    wa_fieldcat-fieldname = 'CARRID'.
    wa_fieldcat-seltext_s = '航线代码'.
    APPEND wa_fieldcat to gt_fieldcat.
    CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'FLDATE'.
wa_fieldcat-seltext_s = '航班日期'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PRICE'.
wa_fieldcat-seltext_s = '航空运费'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PLANETYPE'.
wa_fieldcat-seltext_s = '飞机类型'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CITYFROM'.
wa_fieldcat-seltext_s = '起飞城市'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'CITYTO'.
wa_fieldcat-seltext_s = '目标城市'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'FLTIME'.
wa_fieldcat-seltext_s = '航班时间'.
APPEND wa_fieldcat to gt_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " F_FIELDCAT
&---------------------------------------------------------------------
*& Form GET_DATA
&---------------------------------------------------------------------

  •   text
    

----------------------------------------------------------------------

  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM GET_DATA .
    SELECT
    sflight~CARRID
    sflight~FLDATE
    sflight~PRICE
    sflight~PLANETYPE
    spfli~CITYFROM
    spfli~CITYTO
    spfli~FLTIME
    from sflight INNER JOIN SPFLI ON SFLIGHT~CONNID = SPFLI~CONNID
    into CORRESPONDING FIELDS OF TABLE gt_itab
    WHERE SFLIGHT~PLANETYPE = 'DC-10-10' AND sflight~FLDATE BETWEEN '20190101' AND '20190801'.
    ENDFORM. " GET_DATA
    &---------------------------------------------------------------------
    *& Form F_ALVPRINT
    &---------------------------------------------------------------------
  •   text
    

----------------------------------------------------------------------

  • --> p1 text
  • <-- p2 text
    ----------------------------------------------------------------------
    FORM F_ALVPRINT .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
  • I_INTERFACE_CHECK = ' '
  • I_BYPASSING_BUFFER = ' '
  • I_BUFFER_ACTIVE = ' '
  • I_CALLBACK_PROGRAM = ' '
  • I_CALLBACK_PF_STATUS_SET = ' '
  • I_CALLBACK_USER_COMMAND = ' '
  • I_CALLBACK_TOP_OF_PAGE = ' '
  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '
  • I_CALLBACK_HTML_END_OF_LIST = ' '
  • I_STRUCTURE_NAME =
  • I_BACKGROUND_ID = ' '
  • I_GRID_TITLE =
  • I_GRID_SETTINGS =
    IS_LAYOUT = wa_layout
    IT_FIELDCAT = gt_fieldcat
  • IT_EXCLUDING =
  • IT_SPECIAL_GROUPS =
  • IT_SORT =
  • IT_FILTER =
  • IS_SEL_HIDE =
  • I_DEFAULT = 'X'
  • I_SAVE = ' '
  • IS_VARIANT =
  • IT_EVENTS =
  • IT_EVENT_EXIT =
  • IS_PRINT =
  • IS_REPREP_ID =
  • I_SCREEN_START_COLUMN = 0
  • I_SCREEN_START_LINE = 0
  • I_SCREEN_END_COLUMN = 0
  • I_SCREEN_END_LINE = 0
  • I_HTML_HEIGHT_TOP = 0
  • I_HTML_HEIGHT_END = 0
  • IT_ALV_GRAPHICS =
  • IT_HYPERLINK =
  • IT_ADD_FIELDCAT =
  • IT_EXCEPT_QINFO =
  • IR_SALV_FULLSCREEN_ADAPTER =
  • IMPORTING
  • E_EXIT_CAUSED_BY_CALLER =
  • ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = gt_itab.
  • EXCEPTIONS
  • PROGRAM_ERROR = 1
  • OTHERS = 2
    .
    IF SY-SUBRC <> 0.
  • Implement suitable error handling here
    ENDIF.

ENDFORM. " F_ALVPRINT
结果


image.png

你可能感兴趣的:(ALV开发框架)