sap的字段和对象的修改都会保存旧值,数据保存在CDHDR和CDPOS表中,对于提取旧值你可以采用两种方法
1)使用sap的标准函数CHANGEDOCUMENT_READ_HEADERS 和CHANGEDOCUMENT_READ_POSITIONS
2)使用select语句直接从表中读取。
直接使用SELECT语句读取数据的示例:
*提取信用额度字段修改的抬头信息
select cdhdr~changenr cdhdr~udate cdhdr~utime
into corresponding fields of table p_cdhdr
from cdhdr
where cdhdr~objectclas = 'KLIM' and
cdhdr~objectid = wa_customerinfo-kunnr.
if sy-subrc = 0.
*提取信用额度字段修改的字段值
select cdpos~changenr cdpos~value_old cdpos~value_new
into corresponding fields of table p_cdpos
from cdpos
for all entries in p_cdhdr
where cdpos~objectclas = 'KLIM' and
cdpos~objectid = wa_customerinfo-kunnr and
cdpos~changenr = p_cdhdr-changenr and
cdpos~tabname = 'KNKK' and
cdpos~fname = 'KLIMK'.
if sy-subrc = 0.
endif.
endif.