参照ST22日志查询格式,看见好的东西就要利用起来,使用别怕麻烦或者说什么没必要之类的话,OK?
勿无脑考,重点是提醒思考和学习
代码如下
REPORT zsd200.
- 事务代码:
- 程序名称:
- 程序目的:
- 开发人员:
*(修改日志)-------------------------------------------------------- - 日志号 修改人 修改时间 修改说明 传输号码
-
- 001
*======================================================================*
- INCLUDE
*======================================================================*
INCLUDE zsd200_top.
INCLUDE zsd200_f01.
*======================================================================*
- INITIALIZATION
*======================================================================*
INITIALIZATION.
*======================================================================*
- AT SELECTION-SCREEN.
*======================================================================*
AT SELECTION-SCREEN OUTPUT.
PERFORM frm_screen_text."文本显示
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN ‘NEW’.
PERFORM frm_get_data_new."获取今天自建表数据
WHEN ‘OLD’.
PERFORM frm_get_data_old."获取昨天自建表数据
WHEN OTHERS.
PERFORM frm_get_data."获取自建表数据
ENDCASE.
IF gt_ztprice_log[] IS INITIAL.
MESSAGE ‘无数据’ TYPE ‘E’.
ENDIF.
PERFORM frm_alv_fieldcat."修改设置字段属性
PERFORM frm_alv_layout."设置输出格式
PERFORM frm_alv_display."LV显示
*======================================================================*
- START-OF-SELECTION.
*======================================================================*
START-OF-SELECTION.
*======================================================================*
- END-OF-SELECTION.
*======================================================================*
END-OF-SELECTION.
&---------------------------------------------------------------------
*& 包含 ZSD200_TOP
&---------------------------------------------------------------------
TABLES:ztprice_log.
TABLES sscrfields.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 15(20) new_text USER-COMMAND new. "
SELECTION-SCREEN COMMENT 45(15) new_txts .
SELECTION-SCREEN COMMENT 60(10) new_txte .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON 15(20) old_text USER-COMMAND old . "
SELECTION-SCREEN COMMENT 45(15) old_txts .
SELECTION-SCREEN COMMENT 60(10) old_txte .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_zcjrq FOR ztprice_log-zcjrq , " 创建日期
s_zcjsj FOR ztprice_log-zcjsj , " 创建时间
s_ztcode FOR ztprice_log-ztcode , " ABAP 系统字段:当前事务代码
s_name FOR ztprice_log-zname,"账号
s_ptype FOR ztprice_log-pricetype , " 条件类型
s_type FOR ztprice_log-type , " 价格表类型
s_dateto FOR ztprice_log-dateto , " 有效截至日期
s_datef FOR ztprice_log-datefrom , " 开始生效日期
s_code FOR ztprice_log-code , " 条件记录号
s_price FOR ztprice_log-price , " 价格
s_zgroup FOR ztprice_log-zgroup , " 销售组织
s_unit FOR ztprice_log-unit , " 客户编号
s_prot FOR ztprice_log-product , " 物料号
s_cate FOR ztprice_log-category , " 产品层次
s_region FOR ztprice_log-region , " 地区(省/自治区/直辖市、市、县)
s_pgroup FOR ztprice_log-pricegroup , " 价格组(客户)
s_pack FOR ztprice_log-pack , " 客户组
s_custd FOR ztprice_log-customkind , " 客户类型
s_gcode FOR ztprice_log-groupcode , " 物料组
s_cgroup FOR ztprice_log-productgroup , " 产品组
s_zdel FOR ztprice_log-zdelete , " 删除(删除=1)
s_ztslx FOR ztprice_log-ztslx , " 推送类型(I正常发送D删除T补推)
s_ztszt FOR ztprice_log-ztszt . "推送状态(X失败 空成功)
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF BLOCK b3.
DATA:gt_ztprice_log TYPE STANDARD TABLE OF ztprice_log.
DATA:gt_fieldcat TYPE lvc_t_fcat, "字段目录内表
gs_fieldcat TYPE lvc_s_fcat, "字段目录工作区
gs_layout TYPE lvc_s_layo. "用于定义ALV表单的相关格式、属性
&---------------------------------------------------------------------
*& 包含 ZSD200_F01
&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form frm_fieldcat_alv
&---------------------------------------------------------------------
-
查询设置字段属性
----------------------------------------------------------------------
FORM frm_alv_fieldcat .
REFRESH gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZCJRQ’. gs_fieldcat-scrtext_l = ‘创建日期’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZCJSJ’. gs_fieldcat-scrtext_l = ‘创建时间’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZTCODE’. gs_fieldcat-scrtext_l = '事务代码 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZNAME’. gs_fieldcat-scrtext_l = '账号名称 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PRICETYPE’. gs_fieldcat-scrtext_l = ‘条件类型’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘TYPE’. gs_fieldcat-scrtext_l = '价格表类型 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘DATETO’. gs_fieldcat-scrtext_l = ‘有效截至日期’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘DATEFROM’. gs_fieldcat-scrtext_l = '开始生效日期 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘CODE’. gs_fieldcat-scrtext_l = '条件记录号 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PRICE’. gs_fieldcat-scrtext_l = ‘价格’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZGROUP’. gs_fieldcat-scrtext_l = '销售组织 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘UNIT’. gs_fieldcat-scrtext_l = ‘客户编号’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PRODUCT’. gs_fieldcat-scrtext_l = '物料号 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘CATEGORY’. gs_fieldcat-scrtext_l = ‘产品层次’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘REGION’. gs_fieldcat-scrtext_l = '地区(省/自治区/直辖市、市、县) '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PRICEGROUP’. gs_fieldcat-scrtext_l = ‘价格组(客户)’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PACK’. gs_fieldcat-scrtext_l = '客户组 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘CUSTOMKIND’. gs_fieldcat-scrtext_l = ‘客户类型’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘GROUPCODE’. gs_fieldcat-scrtext_l = '物料组 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘PRODUCTGROUP’. gs_fieldcat-scrtext_l = '产品组 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZDELETE’. gs_fieldcat-scrtext_l = ‘删除(删除=1)’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZTSLX’. gs_fieldcat-scrtext_l = ‘推送类型(I正常发送D删除T补推)’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZTSZT’. gs_fieldcat-scrtext_l = ‘推送状态(X失败 空成功)’. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘ZTSXX’. gs_fieldcat-scrtext_l = '推送消息 '. APPEND gs_fieldcat TO gt_fieldcat.
CLEAR:gs_fieldcat. gs_fieldcat-fieldname = ‘UUID’. gs_fieldcat-scrtext_l = ‘UUDI’. APPEND gs_fieldcat TO gt_fieldcat.
ENDFORM.
&---------------------------------------------------------------------
*& Form frm_layout_alv
&---------------------------------------------------------------------
*& 查询设置输出格式
&---------------------------------------------------------------------
FORM frm_alv_layout .
CLEAR gs_layout.
gs_layout-zebra = ‘X’ . " 使ALV界面呈现颜色交替
gs_layout-sel_mode = ‘D’ . " 选择模式,"A"在最左端有选择按钮
gs_layout-cwidth_opt = ‘X’ . " 自动优化列宽
ENDFORM.
&---------------------------------------------------------------------
*& Form frm_alv_display
&---------------------------------------------------------------------
*& 修改自建表ALV显示
&---------------------------------------------------------------------
FORM frm_alv_display .
-
DATA: i_grid_settings TYPE lvc_s_glay.
DATA ls_title TYPE lvc_title.
DESCRIBE TABLE gt_ztprice_log LINES DATA(li_lines).
ls_title = ‘条目数:’ && li_lines. -
i_grid_settings-edt_cll_cb = ‘X’."ALV 控制: 退出可编辑单元格时回调
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program = sy-repid "当前程序
is_layout_lvc = gs_layout “界面格式”
it_fieldcat_lvc = gt_fieldcat “字段属性”
-
i_callback_pf_status_set = 'F_SET_PF_STATUS' "状态
-
i_callback_user_command = 'FRM_USER_COMMAND_ALV' "控制指令
-
it_event_exit = gt_event_exit i_grid_title = ls_title
-
TABLESi_grid_settings = i_grid_settings
t_outtab = gt_ztprice_log
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘S’ NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_DATA
&---------------------------------------------------------------------
-
获取自建表数据
----------------------------------------------------------------------
FORM frm_get_data .
REFRESH gt_ztprice_log.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_ztprice_log
FROM ztprice_log
WHERE zcjrq IN s_zcjrq AND " 创建日期
zcjsj IN s_zcjsj AND " 创建时间
zname IN s_name AND "账号
ztcode IN s_ztcode AND " ABAP 系统字段:当前事务代码
pricetype IN s_ptype AND " 条件类型
type IN s_type AND " 价格表类型
dateto IN s_dateto AND " 有效截至日期
datefrom IN s_datef AND " 开始生效日期
code IN s_code AND " 条件记录号
price IN s_price AND " 价格
zgroup IN s_zgroup AND " 销售组织
unit IN s_unit AND " 客户编号
product IN s_prot AND " 物料号
category IN s_cate AND " 产品层次
region IN s_region AND " 地区(省/自治区/直辖市、市、县)
pricegroup IN s_pgroup AND " 价格组(客户)
pack IN s_pack AND " 客户组
customkind IN s_custd AND " 客户类型
groupcode IN s_gcode AND " 物料组
productgroup IN s_cgroup AND " 产品组
zdelete IN s_zdel AND " 删除(删除=1)
ztslx IN s_ztslx AND " 推送类型(I正常发送D删除T补推)
ztszt IN s_ztszt . "推送状态(X失败 空成功)
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_SCREEN_TEXT
&---------------------------------------------------------------------
-
文本显示
----------------------------------------------------------------------
FORM frm_screen_text .
DATA:old_date TYPE sy-datum.
old_date = sy-datum - 1.
"PUSHBUTTON 文本初始化
new_text = ‘今天’.
old_text = ‘昨天’.
"昨天成功条目数
SELECT COUNT(*)
INTO @DATA(lv_old_s)
FROM ztprice_log
WHERE zcjrq = @old_date
AND ztszt = ‘’.
"昨天失败条目数
SELECT COUNT(*)
INTO @DATA(lv_old_e)
FROM ztprice_log
WHERE zcjrq = @old_date
AND ztszt = ‘X’.
"今天成功条目数
SELECT COUNT(*)
INTO @DATA(lv_new_s)
FROM ztprice_log
WHERE zcjrq = @sy-datum
AND ztszt = ‘’.
"昨天失败条目数
SELECT COUNT(*)
INTO @DATA(lv_new_e)
FROM ztprice_log
WHERE zcjrq = @sy-datum
AND ztszt = ‘X’.
old_txts = ‘成功:’ && lv_old_s .
old_txte = ‘失败:’ && lv_old_e.
new_txts = ‘成功:’ && lv_new_s .
new_txte = ‘失败:’ && lv_new_e.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_DATA_NEW
&---------------------------------------------------------------------
-
获取今天自建表数据
----------------------------------------------------------------------
FORM frm_get_data_new .
REFRESH gt_ztprice_log.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_ztprice_log
FROM ztprice_log
WHERE zcjrq = sy-datum. " 创建日期
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_DATA_OLD
&---------------------------------------------------------------------
-
获取昨天自建表数据
----------------------------------------------------------------------
FORM frm_get_data_old .
DATA:lv_date_old TYPE sy-datum.
lv_date_old = sy-datum - 1.
REFRESH gt_ztprice_log.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_ztprice_log
FROM ztprice_log
WHERE zcjrq = lv_date_old. " 创建日期
ENDFORM.