As you may already know SAP keeps track of table content changes if you switch on ‘Log Data Changes’ option in table technical settings. Here you can see how to activate this small but effective checkbox for database tables.
[su_tooltip style=”dark” content=”standard table”]DBTABLOGÂ [/su_tooltip] is the main object to hold log changes for all logged database tables. However the records are kept in raw format in LOGDATA field. Therefore you have to make some conversion so that you can obtain the tables’ fields. Another very important field in DBTABLOG is OPTYPE which represent operation type applied to the table record. For OPTYPE field domain values are: ‘D’ which means Delete, ‘I’ which means Insert, whereas ‘U’ means Update.
In the light of this information i have written an ABAP program to extract update logs of a selected table in the determined period. You could adjust this program with many variations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
report zya_read_log. parameters p_table type tabname. parameters p_from type sy-datum. parameters p_to type sy-datum. field-symbols <fs_data> type any. field-symbols <ft_data> type any table. data go_alv type ref to cl_salv_table. start-of-selection . perform read_log. end-of-selection. perform list_log. *&---------------------------------------------------------------------* *& Form READ_LOG *&---------------------------------------------------------------------* form read_log . data lt_obj_list type stprt_h_tablist with header line. data lt_log_list type stprt_log_stable_type with header line. data lo_data type ref to data. clear lt_obj_list[]. lt_obj_list-tab = p_table. insert table lt_obj_list. call function 'DBLOG_READ_TABLE' exporting from_day = p_from to_day = p_to obj_list = lt_obj_list[] changing log_list = lt_log_list[]. delete lt_log_list where optype ne 'I' and optype ne 'U' and optype ne 'D'. create data lo_data type table of (p_table). assign lo_data->* to <ft_data>. loop at lt_log_list. assign lt_log_list-logdata to <fs_data> casting type (p_table). insert <fs_data> into table <ft_data>. endloop. endform. *&---------------------------------------------------------------------* *& Form LIST_LOG *&---------------------------------------------------------------------* form list_log . cl_salv_table=>factory( importing r_salv_table = go_alv changing t_table = <ft_data> ). go_alv->display( ). endform. |
[su_divider]
MOST COMMENTED
ABAP / SAP ARCHITECTURE / SAP BASIS / TRANSPORT MANAGEMENT
simulate request in target system before transportation – source code – part 2
PROGRAM LIBRARY / SAP ARCHITECTURE / WEBSERVICE
consume REST oauth service from ABAP – get access token in order to call main webservice – part 1
ABAP / DICTIONARY OBJECTS / SAP BASIS
read table logs and extract table columns from DBTABLOG
ABAP / SAP PERFORMANCE
‘Exception condition “RESOURCE_FAILURE” raised’ error in parallel processing
ABAP / ALV / PROGRAM LIBRARY
converting CL_SALV_TABLE into CL_GUI_ALV_GRID
BACKGROUND JOB / SAP BASIS
‘Extended job selection’ in SM37
ABAP
selection screen custom button