sap的字段和对象的修改都会保存旧值,数据保存在CDHDRCDPOS表中,对于提取旧值你可以采用两种方法

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.

可以在CHANGEDOCUMENT_READ_HEADERS 中设置中断获得对象类型。
参考连接:http://blog.csdn.net/CompassButton/archive/2006/11/04/1366572.aspx

05-11 14:44