ALV排序统计功能

*&---------------------------------------------------------------------*
*& Program Name   Report  Z_ALV_2                                      *
*&---------------------------------------------------------------------*
*& Create Programmer   :林                                         *
*& Create Date         :2007-12-21                                     *
*& Create Author       :林                                         *
*& Program Type        :Function                                       *
*& Logical DB          :[未使用]                                       *
*& Text Elements                                                       *
*&   (Titles&Headers)  :[未使用]                                       *
*&   (Selection Texts) :[使用]                                         *
*&   (Text symbols)    :[使用]                                         *
*& GUI Status          :[标准]                                         *
*& Variants            :[未使用]                                       *
*& Message Class       :[未使用]                                       *
*& Description         :ALV排序统计功能                                *
*&---------------------------------------------------------------------*
*& Modifications       :无                                             *
*& Modifiy Author      :                                               *
*& Modify Programmer   :                                               *
*& Modify Version      :                                               *
*& Modify Date         :                                               *
*&---------------------------------------------------------------------*
REPORT  Z_ALV_2                                                     .
*&---------------------------------------------------------------------*
*& Tables Declarition                                                  *
*&---------------------------------------------------------------------*
tables: ekpo.
*&---------------------------------------------------------------------*
*& Type-pools Declarition                                              *
*&---------------------------------------------------------------------*
type-pools: slis.
*&---------------------------------------------------------------------*
*& Type Definition                                                     *
*&---------------------------------------------------------------------*
types: begin of typ_alv.
        include structure EKPO.
types: sel.
types: end of typ_alv.

*&---------------------------------------------------------------------*
*& Work Area Definition                                                *
*&---------------------------------------------------------------------*
**--ALV用到的工作区定义
data: wa_fieldcat type slis_fieldcat_alv.
*&---------------------------------------------------------------------*
*& Inner Table Definition                                              *
*&---------------------------------------------------------------------*
data: it_alv type table of typ_alv with header line.
**--ALV用到的内表定义
data: it_fieldcat type slis_t_fieldcat_alv with header line,
      it_sort type slis_t_sortinfo_alv with header line.
*&---------------------------------------------------------------------*
*& Data Definition                                                     *
*&---------------------------------------------------------------------*
data: g_count type i value 1.
**--ALV变量声明
data: g_repid like sy-repid value sy-repid,
      g_layout type slis_layout_alv.
*&---------------------------------------------------------------------*
*& Select-options/Parameters Definition                                *
*&---------------------------------------------------------------------*
selection-screen: begin of block blk01 with frame title text-010.
select-options: s_ebeln for EKPO-ebeln..
selection-screen: end of block blk01.
*&---------------------------------------------------------------------*
*& AT Selection-screen On Value-request for s_pspid-low                *
*&---------------------------------------------------------------------*
*at selection-screen on value-request for s_pspid-low.
*&---------------------------------------------------------------------*
*& Start-of-selection                                                  *
*&---------------------------------------------------------------------*
start-of-selection.
**--检查数据
  perform frm_check_data.
**--获取详细数据
  perform frm_get_data.
**--ALV显示字段设置
  perform frm_set_all_fieldcat.
**--ALV显示样式设置
  perform frm_set_layout.
**--ALV显示
  perform frm_display_alv.
end-of-selection.
*&---------------------------------------------------------------------*
*&      Form  FRM_CHECK_DATA
*&---------------------------------------------------------------------*
*       检查数据
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form frm_check_data .
endform.                    " FRM_CHECK_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       获取详细数据
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form frm_get_data .
  select *
    from ekpo
    into corresponding fields of table it_alv
    where ebeln in s_ebeln.
endform.                    " FRM_GET_DATA
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_ALL_FIELDCAT
*&---------------------------------------------------------------------*
*       ALV显示字段设置
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form frm_set_all_fieldcat .
  data: l_pos type i value 0.
  clear it_fieldcat.
  refresh it_fieldcat.
  define hout.
    l_pos = l_pos + 1.
    it_fieldcat-tabname = 'IT_ALV'. "内表
    it_fieldcat-fieldname = &1.
    it_fieldcat-seltext_m = &2.
    it_fieldcat-col_pos = l_pos.
    it_fieldcat-outputlen = &3.
    it_fieldcat-datatype = &4.
    it_fieldcat-do_sum = &5. "是否在进行编辑
    append it_fieldcat.
    clear it_fieldcat.
  end-of-definition.
  hout 'EBELN' '采购订单编号' '' '' ''.
  hout 'EBELP' '行项目号' '3' '' ''.
  hout 'MENGE' '数量' '3' '' 'X'.
  it_sort-fieldname = 'EBELN'.
  it_sort-spos = 1.
  it_sort-up = 'X'.
  it_sort-subtot = 'X'.
  append it_sort.
endform.                    " FRM_SET_ALL_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0290   text
*      -->P_0291   text
*      -->P_0292   text
*----------------------------------------------------------------------*
form frm_set_fieldcat  using    p_fieldname
                                p_tabname
                                p_coltext.

  clear wa_fieldcat.
  wa_fieldcat-fieldname = p_fieldname.
  wa_fieldcat-tabname = p_tabname.
  wa_fieldcat-seltext_m = p_coltext.
  g_count = g_count + 1.
  append wa_fieldcat to it_fieldcat.
endform.                    " FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_LAYOUT
*&---------------------------------------------------------------------*
*       ALV显示样式设置
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form frm_set_layout .
  g_layout-zebra = 'X'.
*  g_layout-detail_popup = 'X'.
  g_layout-f2code = '&ETA'. "是否有事件
  g_layout-no_vline = ''.
  g_layout-colwidth_optimize = 'X'.
  g_layout-totals_text = 'TOTALS'(201).
  g_layout-box_fieldname = 'SEL'.
*  g_layout-detail_initial_lines = 'X'.
*  g_layout-detail_titlebar = text-041.
endform.                    " FRM_SET_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*       ALV显示
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form frm_display_alv .
  call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = g_repid
*       i_callback_pf_status_set          = 'FRM_SET_STATUS'
*       i_callback_user_command           = 'FRM_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                         = g_layout
     it_fieldcat                       = it_fieldcat[]
*     IT_EXCLUDING                      =
*     IT_SPECIAL_GROUPS                 =
     IT_SORT                           = it_sort[]
*     IT_FILTER                         =
*     IS_SEL_HIDE                       =
*     i_default                         = 'X'
   i_save                            = 'X'
*     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                          = it_alv
   exceptions
     program_error                     = 1
     others                            = 2
            .
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.
endform.                    " FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_STATUS
*&---------------------------------------------------------------------*
*       显示状态栏图标设置
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
form frm_set_status using rt_extab type slis_t_extab.
*  set pf-status 'STATUS_01' excluding rt_extab.
endform.                    "FRM_SET_STATUS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值