您现在的位置是:首页 >其他 >SAP SM30表格维护生成器隐藏记录日志字段网站首页其他

SAP SM30表格维护生成器隐藏记录日志字段

Yisoon 2023-06-20 00:00:02
简介SAP SM30表格维护生成器隐藏记录日志字段

1.背景

在表格维护生成器中往往会隐藏记录日志字段,不让用户直接查看,而供运维或者开发部门使用,如下所示:
在这里插入图片描述

2.实现

2.1 SM30逻辑流和屏幕元素中删除日志记录字段

在这里插入图片描述
在这里插入图片描述

2.2 创建事件,写入记录日志代码

在这里插入图片描述

2.2.1 记录日志方式1

在这里插入图片描述
FORM z_data_change_after .

DATA: lv_total TYPE sy-tabix,
lv_tabix TYPE sy-tabix,
ls_field TYPE zmrs_log.

LOOP AT total.
lv_total = sy-tabix.
CHECK IS NOT INITIAL.
MOVE-CORRESPONDING <vim_total_struc> TO ls_field.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc IS INITIAL.
lv_tabix = sy-tabix.
ELSE.
CLEAR lv_tabix.
ENDIF.

IF ls_field-crnam IS INITIAL.
  ls_field-crnam = sy-uname.
  ls_field-crdat = sy-datum.
  ls_field-crtim = sy-uzeit.
ELSE.
  ls_field-upnam = sy-uname.
  ls_field-updat = sy-datum.
  ls_field-uptim = sy-uzeit.
ENDIF.

ls_field-uppgm = sy-repid.

MOVE-CORRESPONDING ls_field TO <vim_total_struc>.
MODIFY total INDEX lv_total.

IF lv_tabix IS NOT INITIAL.
  extract = total.
  MODIFY extract INDEX lv_tabix.
ENDIF.

ENDLOOP.

CLEAR sy-subrc.

ENDFORM.

2.2.1 记录日志方式2

在这里插入图片描述
FORM frm_write_log .

CALL FUNCTION ‘ZBCFM_FILL_LOG2’

  • EXPORTING
  • IV_UPDKZ       =
    
    CHANGING
    cs_data = zvsd806.

ENDFORM.

FUNCTION zbcfm_fill_log2.
*“----------------------------------------------------------------------
"“本地接口:
*” IMPORTING
*” VALUE(IV_UPDKZ) OPTIONAL
*" CHANGING
*" REFERENCE(CS_DATA)
*"----------------------------------------------------------------------

FIELD-SYMBOLS:<fs_f> TYPE any.
DATA:lv_updkz TYPE c.

IF iv_updkz IS INITIAL.
ASSIGN COMPONENT ‘CRDAT’ OF STRUCTURE cs_data TO <fs_f>.
IF <fs_f> IS ASSIGNED.
IF <fs_f> = ‘00000000’.
lv_updkz = ‘I’.
ELSE.
lv_updkz = ‘U’.
ENDIF.
UNASSIGN:<fs_f>.
ENDIF.
ELSE.
lv_updkz = iv_updkz.
ENDIF.

CASE lv_updkz.
WHEN ‘I’."插入
ASSIGN COMPONENT ‘CRDAT’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-datum.
ENDIF.
ASSIGN COMPONENT ‘CRTIM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-uzeit.
ENDIF.
ASSIGN COMPONENT ‘CRNAM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-uname.
ENDIF.
ASSIGN COMPONENT ‘CRPGM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-repid.
ENDIF.
WHEN ‘U’."更新
ASSIGN COMPONENT ‘UPDAT’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-datum.
ENDIF.
ASSIGN COMPONENT ‘UPTIM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-uzeit.
ENDIF.
ASSIGN COMPONENT ‘UPNAM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-uname.
ENDIF.
ASSIGN COMPONENT ‘LCPGM’ OF STRUCTURE cs_data TO <fs_f>.
IF sy-subrc = 0.
<fs_f> = sy-repid.
ENDIF.
ENDCASE.

ASSIGN COMPONENT ‘UPPGM’ OF STRUCTURE cs_data TO FIELD-SYMBOL(<fs_uppgm>).
IF <fs_uppgm> IS ASSIGNED.
<fs_uppgm> = sy-tcode.
ENDIF.

ENDFUNCTION.

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。