If logging is activated, any changes to table entries are logged in the log table .
T-code:RZ10
This also require the profile parameter to be set accordingly. This profile parameter can have the following values:
Logging is cross-client.
Changes are logged only in the specified clients
clnt1,
clnt2, ...
No logging.
The logs can be analyzed using the transaction "Table History" (transaction ). Logging takes place independently of updates.
If there are more than 250 characters in the table key or if a full table row has more than 16000 bytes, the table cannot be logged. The lengths of fields with the predefined types STRING, RAWSTRING, LCHR, and LRAW are counted in full here.
*&---------------------------------------------------------------------*
*& Report ZTEST04
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztest05.
TYPE-POOLS stprt .
DATA: lv_tabname TYPE tabname VALUE 'ZYCHCN_TEST',
lv_date_s TYPE d VALUE '20170314',
lv_date_e TYPE d VALUE '20170314'.
DATA: lt_tablist TYPE stprt_h_tablist WITH HEADER LINE,
lt_dfies TYPE TABLE OF dfies,
ls_dfies TYPE dfies,
ls_head TYPE x030l,
lv_tabdata_old TYPE logdata,
lt_log TYPE stprt_log_stable_type,
ls_log TYPE LINE OF stprt_log_stable_type.
DATA: dyn_wa TYPE REF TO data.
FIELD-SYMBOLS: TYPE any,
TYPE x,
TYPE any, TYPE any,
TYPE x, TYPE x.
**************************************************************
REFRESH lt_dfies . CLEAR ls_head .
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = lv_tabname
IMPORTING
x030l_wa = ls_head
TABLES
dfies_tab = lt_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
SORT lt_dfies BY position .
CHECK lt_dfies[] IS NOT INITIAL .
CREATE DATA dyn_wa TYPE (lv_tabname). " 定义动态结构
ASSIGN dyn_wa->* TO .
REFRESH: lt_log,lt_tablist .
lt_tablist-tab = lv_tabname .
INSERT TABLE lt_tablist.
CALL FUNCTION 'DBLOG_READ_TABLE'
EXPORTING
from_day = lv_date_s
to_day = lv_date_e
obj_list = lt_tablist[]
CHANGING
log_list = lt_log.
LOOP AT lt_log INTO ls_log WHERE optype <> 'U'.
CHECK ls_log-versno >= '01'.
MOVE ls_log-logdata(ls_log-dataln) TO lv_tabdata_old.
*
LOOP AT lt_dfies INTO ls_dfies WHERE tabname = lv_tabname.
* convert endianess
ASSIGN: COMPONENT ls_dfies-fieldname OF STRUCTURE TO ,
TO CASTING.
IF ls_log-versno >= '01' OR ls_dfies-keyflag IS INITIAL.
ASSIGN lv_tabdata_old+ls_dfies-offset(ls_dfies-intlen)
TO CASTING.
ELSE.
* Old type of log: key not in data-part
ASSIGN +ls_dfies-offset(ls_dfies-intlen)
TO CASTING.
ENDIF.
= .
PERFORM convert_endianess USING lv_tabdata_old
ls_log-versno
ls_dfies
CHANGING .
ENDLOOP.
CLEAR .
ENDLOOP.
FORM convert_endianess USING p_logdata TYPE logdata
p_versno TYPE dbtablog-versno
p_dfies TYPE dfies
CHANGING p_field TYPE any.
DATA: f_type LIKE x031l-fieldtype.
CONSTANTS: type_numc TYPE fldtype VALUE 'B0', "UC
type_clnt TYPE fldtype VALUE '98', "UC
type_lang TYPE fldtype VALUE '50', "UC
type_time TYPE fldtype VALUE 'BC', "UC
type_date TYPE fldtype VALUE '9C', "UC
type_char TYPE fldtype VALUE '28', "UC
type_accp TYPE fldtype VALUE '94', "UC
type_cuky TYPE fldtype VALUE '40', "UC
type_prec TYPE fldtype VALUE 'B4', "UC
type_unit TYPE fldtype VALUE '44', "UC
type_lstr TYPE fldtype VALUE 'E4', "#EC *
type_sstr TYPE fldtype VALUE 'EC', "#EC *
type_rstr TYPE fldtype VALUE 'E8',
type_i4 TYPE fldtype VALUE 'AC', "UF160698B
type_i2 TYPE fldtype VALUE 'A8',
type_f TYPE fldtype VALUE '88', "UF160698E
single_byte TYPE tcp00-cpbyteind VALUE '01', "#EC *
double_byte TYPE tcp00-cpbyteind VALUE '02',
quadruple_byte TYPE tcp00-cpbyteind VALUE '05',
empty_entry LIKE dbtablog-optype VALUE '*', "UF133143/2001
c_int4len TYPE i VALUE 4.
FIELD-SYMBOLS: TYPE x.
* Little/big endian conversion
CHECK ( NOT p_versno IS INITIAL
OR ( p_dfies-keyflag = space
AND 'sIF' CS p_dfies-inttype ) )
AND 'PX' NS p_dfies-inttype.
ASSIGN p_field TO CASTING.
CASE p_dfies-inttype.
WHEN 'C'.
CASE p_dfies-datatype.
WHEN 'CHAR'.
f_type = type_char.
WHEN 'LANG'.
f_type = type_lang.
WHEN 'CLNT'.
f_type = type_clnt.
WHEN 'CUKY'.
f_type = type_cuky.
WHEN 'UNIT'.
f_type = type_unit.
ENDCASE.
WHEN 'N'.
IF p_dfies-datatype = 'ACCP'.
f_type = type_accp.
ELSE.
f_type = type_numc.
ENDIF.
WHEN 'D'.
f_type = type_date.
WHEN 'T'.
f_type = type_time.
WHEN 's'.
IF p_dfies-datatype = 'PREC'.
f_type = type_prec.
ELSE.
f_type = type_i2.
ENDIF.
WHEN 'I'.
f_type = type_i4.
WHEN 'F'.
f_type = type_f.
WHEN 'g'.
* C-string is handled as character:
f_type = type_char.
WHEN 'y'.
f_type = type_rstr.
ENDCASE.
CALL FUNCTION 'DB_CONVERT_FIELD_TO_HOST'
EXPORTING
type = f_type
CHANGING
field =
EXCEPTIONS
wrong_param = 0
OTHERS = 0.
ENDFORM. " convert_endianess
阅读(947) | 评论(0) | 转发(0) |