*&---------------------------------------------------------------------*
*& Report ZSEACH_HS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZSEACH_HS.
DATA: GT_FIELD TYPE SLIS_T_FIELDCAT_ALV.
DATA: GS_FIELD TYPE SLIS_FIELDCAT_ALV.
DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
TYPES:BEGIN OF TY_ALV,
UTIME TYPE CDHDR-UTIME , "时间
TCODE TYPE CDHDR-TCODE , "事务代码
TABNAME TYPE CDPOS-TABNAME , "表名
TABKEY TYPE CDPOS-TABKEY , "表键
FNAME TYPE CDPOS-FNAME , "字段名
CHNGIND TYPE CDPOS-CHNGIND , "更改标识符
VALUE_NEW TYPE CDPOS-VALUE_NEW , "新值
VALUE_OLD TYPE CDPOS-VALUE_OLD , "旧值
END OF TY_ALV .
DATA : GT_ALV TYPE STANDARD TABLE OF TY_ALV,
GS_ALV TYPE TY_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
P_NAME TYPE CDHDR-USERNAME OBLIGATORY DEFAULT SY-UNAME, "用户
P_UDATE TYPE CDHDR-UDATE OBLIGATORY DEFAULT SY-DATUM. "日期
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION .
* *获取取数
PERFORM FRM_GET_DATA.
*设置字段属性
PERFORM FRM_SET_FIELDCAT.
**设置输出格式
PERFORM FRM_SET_LAYOUT.
**显示ALV
PERFORM FRM_DISPLAY_ALV.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
SELECT
CDHDR~UTIME
CDHDR~TCODE "事务代码
CDPOS~TABNAME "表名
CDPOS~TABKEY "表键
CDPOS~FNAME "字段名
CDPOS~CHNGIND "更改标识符
CDPOS~VALUE_NEW "新值
CDPOS~VALUE_OLD "旧值
INTO TABLE GT_ALV
FROM CDHDR JOIN CDPOS ON
CDHDR~OBJECTCLAS = CDPOS~OBJECTCLAS AND
CDHDR~OBJECTID = CDPOS~OBJECTID AND
CDHDR~CHANGENR = CDPOS~CHANGENR
WHERE
CDHDR~USERNAME = P_NAME AND
CDHDR~UDATE = P_UDATE .
SORT GT_ALV BY UTIME .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_FIELDCAT .
REFRESH GT_FIELD .
DEFINE MAC_ABAP_INIT.
CLEAR:gS_field.
gs_field-fieldname = &1.
gs_field-reptext_ddic = &2.
* gs_field-just = &3.
*IF gs_field-fieldname = 'FNAME' .
*
* gs_field-EDIT = 'X' .
*
*ENDIF.
APPEND gS_field TO gt_field.
END-OF-DEFINITION.
MAC_ABAP_INIT 'UTIME' '时间' .
MAC_ABAP_INIT 'TCODE' '事务代码' .
MAC_ABAP_INIT 'TABNAME' '表名' .
MAC_ABAP_INIT 'TABKEY' '表键' .
MAC_ABAP_INIT 'FNAME' '字段名' .
MAC_ABAP_INIT 'CHNGIND' '更改标识符' .
MAC_ABAP_INIT 'VALUE_NEW' '新值' .
MAC_ABAP_INIT 'VALUE_OLD' '旧值' .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_LAYOUT .
CLEAR GS_LAYOUT.
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-ZEBRA = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DISPLAY_ALV .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* i_callback_pf_status_set = 'SUB_STATUS_SET'
* i_callback_user_command = 'SUB_USER_COMMAND'
"i_callback_top_of_page = 'SUB_TOP_OF_PAGE'
IT_FIELDCAT = GT_FIELD
" i_save = 'A'
* i_default = 'X'
I_SAVE = 'U'
IS_LAYOUT = GS_LAYOUT
TABLES
T_OUTTAB = GT_ALV
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
* EXPORTING
* i_callback_program = sy-repid "当前程序
** i_callback_pf_status_set = 'SET_PF_STATUS'
** i_callback_user_command = 'ALV_USER_COMMAND'
* is_layout_lvc = gs_layout "界面格式"
* it_fieldcat_lvc = gt_fieldcat "字段属性"、
** it_events = gt_event[]
* i_save = 'A'
* TABLES
* t_outtab = gt_alv.
* 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.
相关文章
- 03-24SQL 查询两个字段相同表的不同记录
- 03-24在购买记录表中查询每个用户在最新一条购买记录
- 03-24一个6亿的表a,一个3亿的表b,通过外间tid关联,你如何最快的查询出满足条件的第50000到第50200中的这200条数据记录
- 03-24**SQL某一表中重复某一字段重复记录查询与处理
- 03-24数据库系统实训——实验二——单表查询
- 03-24day04 Django:ORM: 修改表字段 对数据(表记录)的sql语句操作:查询api,模糊查询 图书管理系统
- 03-24SQL查询记录是否在另一个表中存在
- 03-24SQL语句技巧:查询存在一个表而不在另一个表中的数据记录
- 03-24查询所有表的记录数SQLServer
- 03-24SqlServer 查询系统数据库列表、表和表字段等对象