SAP 请求传输结果报表

48 篇文章 4 订阅

项目中请求比较多,对于批量查看请求传输结果没有一个直观的功能体现出来,所以做了个报表,结果如下图所示


报表代码:

*&---------------------------------------------------------------------*
*& Report  ZDEMO_TRLOG_REPORT
*&
*&---------------------------------------------------------------------*
*& Program Name         <程序名称>:
*& Purpose              <程序用途>: Function Desc.
*& Project Name         <项目名称>:
*& Created by           <创 建 人>: 
*& Created on           <创建日期>: 20170710
*& Functional Consultant<功能顾问>: biz consultant
*& Description          <功能描述>: Function Desc.
*&---------------------------------------------------------------------*
*              Modification Log<程序修改日志>
*<日期>        <开发者>     <功能顾问>            <修改描述>
* Date        Programmer     Corr. #              请求号+描述
*&
*&
*&---------------------------------------------------------------------*
report zdemo_trlog_report.
tables:e070.

types:begin of tys_outtab.
        include type e070.
types:as4text type as4text,"请求描述
      ecd type char4,
      ecq type char4,
      ecm type char4,
      ecp type char4,
      ed2 type char4,
    end of tys_outtab,
  tyt_outtab type table of tys_outtab.

data:gt_outtab type tyt_outtab.

*alv controller data declare
data:gr_alv_grid type ref to cl_gui_alv_grid,
     gr_con      type ref to cl_gui_custom_container.


*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVE DEFINITION
*----------------------------------------------------------------------*
class lcl_event_receive definition.
  public section.
    class-methods:
      handle_hotspot_click for event hotspot_click of cl_gui_alv_grid
      importing e_row_id  e_column_id es_row_no,
*工具栏
    handle_toolbar      for event toolbar of cl_gui_alv_grid
      importing e_object.
endclass.                    "lc_receive DEFINITION

*----------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVE IMPLEMENTATION
*----------------------------------------------------------------------*
class lcl_event_receive implementation.
  "HANDLE_HOTSPOT_CLICK
  method handle_toolbar.
    field-symbols:<fs_toolbar> type ttb_button.
    assign e_object->mt_toolbar to <fs_toolbar>.
    if sy-subrc eq 0.
      delete <fs_toolbar>  where function eq '&LOCAL&CUT'
                              or function eq '&LOCAL©'
                              or function eq '&LOCAL&PASTE'
                              or function eq '&LOCAL&UNDO'
                              or function eq '&&SEP02'
                              or function eq '&LOCAL&APPEND'
                              or function eq '&LOCAL&INSERT_ROW'
                              or function eq '&LOCAL&DELETE_ROW'
                              or function eq '&LOCAL©_ROW'
                              or function eq '&&SEP03'.
    endif.
  endmethod.                    "HANDLE_TOOLBAR

  method handle_hotspot_click.
    data:ls_outtab type tys_outtab.
    read table gt_outtab into ls_outtab index e_row_id-index.
    if sy-subrc eq 0.
      case e_column_id-fieldname.
        when 'TRKORR'.
          call function 'TR_LOG_OVERVIEW_REQUEST'
            exporting
              iv_trkorr                    = ls_outtab-trkorr
*             IV_DIR_TYPE                  = 'T'
*             IV_DETAILED_CHRONOLOGY       = 'X'
*             IV_TARGET_SYSTEM             = ' '
*             IS_POPUP                     = IS_POPUP
*           EXCEPTIONS
*             E_WRONG_CALL                 = 1
                    .

        when others.

      endcase.
    else."行号错误

    endif.
  endmethod.

endclass.                    "LCL_EVENT_RECEIVE IMPLEMENTATION

selection-screen begin of block b1 with frame title text-t01. "TR选择
select-options:
      s_date   for e070-as4date,
      s_user   for e070-as4user,
      s_trkorr for e070-trkorr.
selection-screen end of block b1.

start-of-selection.

  perform frm_get_data.

  call screen 9000.
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form frm_get_data .

  field-symbols:<fs_outtab> type tys_outtab,
                <fs_value> type any.
  data:ls_cofile   type ctslg_cofile,
       ls_system   type ctslg_system.
  select a~*,
         b~as4text
    into corresponding fields of table @gt_outtab
    from e070 as a inner join e07t as b
    on  a~trkorr eq b~trkorr
      where a~as4date in @s_date
        and a~as4user in @s_user
        and a~trstatus eq 'R'
        and a~trkorr  in @s_trkorr.
  if sy-subrc eq 0.

    loop at gt_outtab assigning <fs_outtab>.
      clear ls_cofile.
*读取TR传输反馈结果信息
      call function 'TR_READ_GLOBAL_INFO_OF_REQUEST'
        exporting
          iv_trkorr                       = <fs_outtab>-trkorr
        importing
          es_cofile                       = ls_cofile.

      loop at ls_cofile-systems into ls_system.
        assign component ls_system-systemid
                         of structure <fs_outtab> to <fs_value>.
        if sy-subrc eq 0.
          case ls_system-rc.
            when '0'. "成功
              <fs_value> = '@08@'.
            when '4'."警告
              <fs_value> = '@09@'.
            when others."错误
              <fs_value> = '@0A@'.
          endcase.
        endif.
      endloop.

    endloop.
  endif.
endform.
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_9000 output.
  set pf-status '9000'.
  set titlebar '9000'.
*显示ALV
  perform frm_display_alv.
endmodule.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_9000 input.

  case sy-ucomm.

    when 'BACK' or 'EXIT' or 'CANCEL'.
      set screen 0.

  endcase.

endmodule.
*&---------------------------------------------------------------------*
*&      Form  FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*       显示ALV
*----------------------------------------------------------------------*
form frm_display_alv .
  data:lt_fieldcat     type lvc_t_fcat,  "字段目录列表
        ls_layout       type lvc_s_layo,  "布局结构
        ls_variant      type disvariant,  "变式
        ls_print        type lvc_s_prnt,  "打印控制
        lt_sort         type lvc_t_sort,  "排序表\\
        lt_filter       type lvc_t_filt,  "过滤表
        lt_funs_excl    type ui_functions, "隐藏标准按钮内表
        lt_hyperlink    type lvc_t_hype,  "超级链接内表
        ls_refresh_stbl type lvc_s_stbl.  "刷新行列固定结构



  if gr_alv_grid is initial.
*create container controller
    create object gr_con
      exporting
        container_name = 'CONTAINER'.
*create alv controller
    create object gr_alv_grid
      exporting
        i_appl_events = abap_true
        i_parent      = gr_con.

    ls_layout-zebra = 'X' .
    ls_layout-sel_mode   = 'D'.
*    ls_layout-grid_title = sy-title.    "标题
*    ls_layout-smalltitle = abap_true.   "标体大小
    ls_layout-cwidth_opt = abap_true.   "列宽优化

    ls_variant-report = sy-repid .
*    ls_variant-username = sy-uname.

*-----ALV 事件设置
    perform frm_set_alv_event.

*-----准备获取字段目录
    perform frm_prepare_field_catalog changing lt_fieldcat .

    call method gr_alv_grid->set_table_for_first_display
      exporting
        is_variant                    = ls_variant "显示变式
        i_save                        = 'X' "决定是否保存变式''/A/U/X
*       I_DEFAULT                     = 'X' "是否可以定义默认布局
        is_layout                     = ls_layout
      changing
        it_outtab                     = gt_outtab[]
        it_fieldcatalog               = lt_fieldcat
        it_sort                       = lt_sort
        it_filter                     = lt_filter
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4.
  else.
*----刷新alv
    ls_refresh_stbl-row = abap_true.       "行滚动条不滑动
    ls_refresh_stbl-col = abap_true.       "列滚动条不滑动
    call method gr_alv_grid->refresh_table_display
      exporting
        is_stable = ls_refresh_stbl
*       I_SOFT_REFRESH = GC_TRUE         "过滤、合计、排序等设置不变
      exceptions
        finished  = 1
        others    = 2.
    if sy-subrc <> 0.
*--异常处理
    endif.
  endif.
endform.
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_ALV_EVENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form frm_set_alv_event .
*事件
  set handler lcl_event_receive=>handle_toolbar for gr_alv_grid.
  set handler lcl_event_receive=>handle_hotspot_click for gr_alv_grid.
endform.
*&---------------------------------------------------------------------*
*&      Form  FRM_PREPARE_FIELD_CATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form frm_prepare_field_catalog  changing pt_fieldcat type lvc_t_fcat.
  field-symbols:<fs_fieldcat> type lvc_s_fcat.
  data:lv_sname         type tabname,
       lv_index         type i.
  data:ls_fieldcat      type lvc_s_fcat.

  define change_text.
    ls_fieldcat-REPTEXT   =
    ls_fieldcat-SCRTEXT_L =
    ls_fieldcat-SCRTEXT_M =
    ls_fieldcat-SCRTEXT_S = &1.
  end-of-definition.

  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name       = 'E070'
    changing
      ct_fieldcat            = pt_fieldcat[]
    exceptions
      inconsistent_interface = 1
      program_error          = 2.
  if sy-subrc <> 0.
*--Exception handling

  else.

    loop at pt_fieldcat assigning <fs_fieldcat> .
      lv_index = sy-tabix.
      case <fs_fieldcat>-fieldname.
        when 'TRKORR' or 'TARSYSTEM' or 'AS4USER' or 'AS4DATE'.
          if <fs_fieldcat>-fieldname eq 'TRKORR'.
            <fs_fieldcat>-hotspot = 'X'.
          endif.
        when others.
          delete pt_fieldcat index lv_index.
      endcase.
    endloop .

    clear:ls_fieldcat.

    ls_fieldcat-col_pos = '10'.
    ls_fieldcat-fieldname = 'AS4TEXT'.
    change_text '请求描述'.
    append ls_fieldcat to pt_fieldcat.

    ls_fieldcat-fieldname = 'ECD'.
    change_text 'ECD'.
    ls_fieldcat-icon      = abap_true.
    append ls_fieldcat to pt_fieldcat.

    ls_fieldcat-fieldname = 'ECQ'.
    change_text 'ECQ'.
    ls_fieldcat-icon      = abap_true.
    append ls_fieldcat to pt_fieldcat.

    ls_fieldcat-fieldname = 'ECM'.
    change_text 'ECM'.
    ls_fieldcat-icon      = abap_true.
    append ls_fieldcat to pt_fieldcat.

    ls_fieldcat-fieldname = 'ECP'.
    change_text 'ECP'.
    ls_fieldcat-icon      = abap_true.
    append ls_fieldcat to pt_fieldcat.

    ls_fieldcat-fieldname = 'ED2'.
    change_text 'ED2'.
    ls_fieldcat-icon      = abap_true.
    append ls_fieldcat to pt_fieldcat.
  endif.

endform.



  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值