‎2007 Jun 15 5:20 AM
I have developed a program to read the DBTABLOG Table entries which keeps a Log Records of Table Changes.
On update of an entry in any table (say TCJ1T), DBTABLOG stores the entry that was updated ie. the old entry.
TO get the new entry I read the key fields of the table TCJ1T form DBTABLOG and query TCJ1T using a select query. The issue is that if an entry is updated twice I can only get the latest updated record if I read the table TCJ1T and the previously updated value is lost.
Is there a way to read the old value , new value using DBTABLOG.
Thanks and Regards
Ashwin
‎2007 Jun 15 5:26 AM
Try with select command accepting duplicates,so that you will get all values
‎2007 Jun 15 5:42 AM
Hi Seshu,
I use the select query to read from main table. I read all vaues from DBTABLOG.
There is a single entry in a Table say TCJ1T with a particular primary key.
say EN : LA : Logical Accounting
If I make 3 changes to the text Logical accounting
Logical accounting -> Logical accounting1
Logical accounting1 -> Logical accounting2
Logical accounting2 -> Logical accounting3
Now my 3 DBTABLOG entries in logdata field contains the values Logical accounting,Logical accounting1,Logical accounting2 ( old value of the field that was updated ). I will get the new value Logical accounting3 from the table but not from the logdata field of DBTABLOG.
The issue here is that I can only use DBTABLOG to read the old values of an updated record.
‎2007 Jun 15 6:37 AM
‎2007 Jun 15 7:33 AM
TYPE-POOLS : stprt.
DATA : tables_list TYPE HASHED TABLE OF stprt_tlist WITH UNIQUE KEY tab, table_list TYPE stprt_tlist.
DATA : log TYPE stprt_log_stable_type, log_wa TYPE dbtablog.
Internal table structures for main data
DATA: BEGIN OF st_tcj1tdata,
logdate LIKE dbtablog-logdate,
logtime LIKE dbtablog-logtime,
optype LIKE dbtablog-optype,
langu LIKE tcj1t-langu,
prart LIKE tcj1t-prart,
pratx LIKE tcj1t-pratx,
END OF st_tcj1tdata.
Internal tables for main data
DATA: it_tcj1tdata LIKE TABLE OF st_tcj1tdata,
wa_tcj1tdata LIKE st_tcj1tdata.
PARAMETERS: p_tabnm(30).
*----
Data Processing
*----
get table name from user
table_list-tab = p_tabnm.
*Append table name
INSERT table_list INTO TABLE tables_list.
read the log records from table dbtablog
Time interval to be changed
CALL FUNCTION 'DBLOG_READ_TABLE'
EXPORTING
from_day = sy-datum
FROM_TIME = '000000'
to_day = sy-datum
TO_TIME = '235959'
obj_list = tables_list
USER_LIST =
LOG_KEYS =
CHANGING
log_list = log.
PERFORMS
TRANSLATE p_tabnm TO UPPER CASE.
PERFORM get_tcj1t_data.
FORM get_tcj1t_data.
DATA: l_langu LIKE tcj1t-langu,
l_prart LIKE tcj1t-prart.
CLEAR wa_tcj1tdata.
REFRESH it_tcj1tdata.
LOOP AT log INTO log_wa.
WRITE : / log_wa-logdata.
Convert the hex data into string
loc_xstring = log_wa-logdata.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = loc_xstring
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true
RECEIVING
conv = loc_conv.
TRY.
CALL METHOD loc_conv->read
IMPORTING
data = loc_string.
CATCH cx_sy_conversion_codepage.
*-- Should ignore errors in code conversions
CATCH cx_sy_codepage_converter_init.
*-- Should ignore errors in code conversions
CATCH cx_parameter_invalid_type.
CATCH cx_parameter_invalid_range.
ENDTRY.
*Read the primary keys
l_langu = loc_string+3(1).
l_prart = loc_string+4(2).
SELECT SINGLE pratx
FROM tcj1t INTO CORRESPONDING FIELDS OF wa_tcj1tdata
WHERE langu = l_langu
AND prart = l_prart.
wa_tcj1tdata-langu = l_langu.
wa_tcj1tdata-prart = l_prart.
wa_tcj1tdata-logdate = log_wa-logdate.
wa_tcj1tdata-logtime = log_wa-logtime.
wa_tcj1tdata-optype = log_wa-optype.
APPEND wa_tcj1tdata TO it_tcj1tdata.
CLEAR wa_tcj1tdata.
ENDLOOP.
Display Output
LOOP AT it_tcj1tdata INTO wa_tcj1tdata.
WRITE: / wa_tcj1tdata-optype, wa_tcj1tdata-langu, wa_tcj1tdata-prart, wa_tcj1tdata-pratx.
ENDLOOP.
ENDFORM. " get_TCJ1T_data
‎2007 Aug 17 4:48 PM
Hi Ashwin,
i m facing same kind of problem, hw did u solve it,
Pls let me know i m in urgency of it,
thx a lot in advance
‎2009 Feb 26 2:22 PM
Hi Ashwin,
I tried your code, I am getting output like #8#0#0# # #2#0#0#8#1#2#1#2#...... .
I used the same code without any change.
Can u help me in this if you have done something else?
Or if possible can I see the final code?
Thanks...
Umesh
‎2009 Feb 26 3:02 PM
Age old thread, and what is the added benefit over transaction SCU3?
‎2009 Jan 27 7:08 AM
The issue was solved when I noticed the behaviour of DBTABLOG after transport.
When we transport our customizing request from System A to system B then on System B only the latest Update entry gets made. Hence I used this entry to read from main table.