http://blog.sina.com.cn/s/blog_7dce1fac01014yp2.html转自
sap的字段和对象的修改都会保存旧值,数据保存在CDHDR和CDPOS表中,提取旧值可以采用两种方法

1) 使用sap的标准函数CHANGEDOCUMENT_READ_HEADERS 和CHANGEDOCUMENT_READ_POSITIONS

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS' "Change document: Read change document items 
EXPORTING 
*   archive_handle = 0          " sy-tabix      Handle on Open Archive Files 
    changenumber =              " cdpos-changenr  Change document number 
*   tablekey = SPACE            " cdpos-tabkey  Object class table key 
*   tablename = SPACE           " cdpos-tabname  Object class table name 
*   tablekey254 = SPACE         " cdpos_uid-tabkey  Table Key for CDPOS in Character 254 
*   keyguid = SPACE             " cdpos_uid-keyguid  UUID in Character Format 
*   keyguid_str = SPACE         " cdpos_str-keyguid  UUID in Character Format 
IMPORTING 
    header =                    " cdhdr   Change document header (structure CDHDR) 
   et_cdred_str =              " cdred_str_tab  Additional Change Document - Table for STRINGs 
* TABLES 
*   editpos =                  " cdshw     Table with edited change document items 
EDITPOS_WITH_HEADER =               "CDRED  更改文档,显示结构 
 EXCEPTIONS 
NO_POSITION_FOUND = 1       "               No item foun 
 WRONG_ACCESS_TO_ARCHIVE = 2  "              incorrect access to archive 
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 中设置中断获得对象类型。

ex.

提取有变动的 Acc. changes
SELECT SINGLE tabkey value_new INTO
(cdpos-tabkey,ikoinh)
FROM
cdpos
WHERE objectclas =
'KRED'
AND objectid =
itab-lifnr
AND changenr =
itab-changenr
AND tabname =
'LFBK'
AND fname =
'KOINH'.

提取有变动的vendor最新日期

SELECT MAX( udate ) INTO itab-cndate FROM
cdhdr
WHERE objectclas = 'KRED' AND
objectid = itab-lifnr.

--------------------------------------------------------------------------------

抓取所有有变动的程序

report
ztest001.
TYPE-POOLS slis.
DATA : cdhdr TYPE cdhdr.
SELECT-OPTIONS
:
s_objcls FOR cdhdr-objectclas OBLIGATORY,

s_objtid FOR cdhdr-objectid,
s_chngnr FOR
cdhdr-changenr,
s_usrnam FOR cdhdr-username DEFAULT
sy-uname,
s_udate FOR
cdhdr-udate DEFAULT sy-datum,

s_time FOR cdhdr-utime,
s_tcode FOR
cdhdr-tcode,
s_plncnr FOR cdhdr-planchngnr,

s_chngno FOR cdhdr-act_chngno,
s_wsplnd FOR
cdhdr-was_plannd,
s_chngid FOR
cdhdr-change_ind.

SELECTION-SCREEN SKIP.
PARAMETERS p_max TYPE numc3
OBLIGATORY DEFAULT
'200'.

*---------------------------------------------------------------------*
TYPES
:
BEGIN OF
ty_s_cdhdr.
INCLUDE STRUCTURE
cdhdr.
TYPES : checkbox,
END OF
ty_s_cdhdr,

BEGIN OF
ty_s_cdpos.
INCLUDE STRUCTURE
cdpos.
TYPES : checkbox,
END OF
ty_s_cdpos.

*---------------------------------------------------------------------*
DATA
:
* Layout for ALV
gs_layout TYPE slis_layout_alv,
*
Change document header
t_cdhdr TYPE TABLE OF
ty_s_cdhdr.

*---------------------------------------------------------------------*
START-OF-SELECTION.

*
Read Change document header
SELECT * INTO TABLE
t_cdhdr
UP
TO p_max
ROWS
FROM
cdhdr
WHERE
objectclas IN
s_objcls
and
objectid in
s_objtid
and
changenr in
s_chngnr
AND
username IN
s_usrnam
AND
udate IN
s_udate
AND
utime IN
s_time
AND
tcode IN
s_tcode
AND
planchngnr IN
s_plncnr
AND
act_chngno IN
s_chngno
AND
was_plannd IN
s_wsplnd
AND
change_ind IN s_chngid.

gs_layout-zebra =
'X'.
gs_layout-colwidth_optimize = 'X'.

gs_layout-box_fieldname = 'CHECKBOX'.

* Display ALV
CALL
FUNCTION
'REUSE_ALV_GRID_DISPLAY'
EXPORTING

i_callback_program =
sy-cprog

i_callback_user_command =
'USER_COMMAND'

i_structure_name =
'CDHDR'

is_layout
=
gs_layout
TABLES

t_outtab
=
t_cdhdr.

*---------------------------------------------------------------------*
*
FORM
USER_COMMAND
*
*---------------------------------------------------------------------*
FORM
user_command USING u_ucomm TYPE
syucomm

us_selfield TYPE slis_selfield. "#EC
CALLED

* Macro definition
DEFINE
m_sort.
add 1 to
ls_sort-spos.
ls_sort-fieldname =
&1.
ls_sort-up =
'X'.
append ls_sort to
lt_sort.
END-OF-DEFINITION.

DATA
:
ls_cdhdr TYPE
ty_s_cdhdr,
ls_sort TYPE
slis_sortinfo_alv,
lt_sort TYPE
slis_t_sortinfo_alv,
* Change document
items
lt_cdpos TYPE TABLE OF
ty_s_cdpos.

CASE u_ucomm.
WHEN
'&IC1'.
PERFORM check_marked USING
us_selfield.

* Read Change document
items
LOOP AT t_cdhdr INTO ls_cdhdr WHERE
checkbox = 'X'.
SELECT *
APPENDING TABLE
lt_cdpos
FROM
cdpos
WHERE
objectclas =
ls_cdhdr-objectclas
AND
objectid =
ls_cdhdr-objectid
AND
changenr =
ls_cdhdr-changenr.
ENDLOOP.

m_sort 'CHANGENR'.

* Display
ALV
CALL FUNCTION
'REUSE_ALV_GRID_DISPLAY'
EXPORTING

i_structure_name =
'CDPOS'

is_layout =
gs_layout

it_sort =
lt_sort
TABLES

t_outtab =
lt_cdpos.

ENDCASE.

ENDFORM. "
USER_COMMAND
*--------------------------------------------------------------------

FORM
check_marked USING us_selfield TYPE
slis_selfield.

FIELD-SYMBOLS :

<cdhdr> TYPE ty_s_cdhdr.

READ TABLE t_cdhdr
TRANSPORTING NO FIELDS WITH KEY checkbox = 'X'.
IF NOT sy-subrc
IS INITIAL AND
NOT us_selfield-tabindex IS
INITIAL.
READ TABLE t_cdhdr INDEX
us_selfield-tabindex ASSIGNING <cdhdr>.

<cdhdr>-checkbox = 'X'.
ENDIF.

ENDFORM.

SAP保存操作记录CDHDR和CDPOS表的更多相关文章

  1. 【VerySky原创】怎样查找到CDHDR、CDPOS表中的OBJECTCLAS字段

    可以通过pooled table TCDOB - Objects for change document creation 找到对应的表的对象值: se38 run:  RSSCD1TS object ...

  2. Linux服务器记录并查询历史操作记录

    Linux服务器在使用过程中,经常会有除自己之外的其他人员使用.并不是每个人都对Linux服务器特别熟悉,难免会有一些操作导致服务器报错. 因此,监控Linux服务器的操作并记录下来,是非常有必要的! ...

  3. Mycat读写分离、主从切换、分库分表的操作记录

    系统开发中,数据库是非常重要的一个点.除了程序的本身的优化,如:SQL语句优化.代码优化,数据库的处理本身优化也是非常重要的.主从.热备.分表分库等都是系统发展迟早会遇到的技术问题问题.Mycat是一 ...

  4. oracle中查找某用户执行某张表的操作操作记录

    转载:http://www.cnblogs.com/nizuimeiabc1/p/9441937.html 1,首先查找表的操作记录 select * from v$sqlarea a where a ...

  5. 利用Oracle GoldenGate记录源系统所有表的操作

    通过goldengate,可以实现目标表和源表不同结构之间的实时复制,包括记录源系统所有表的变更操作,供ETL或其它审计系统使用. 记录信息包括表名.操作时间.操作SCN,事务标记,操作类型到一个流水 ...

  6. mongodb安装,库操作,集合操作(表),文档操作(记录)

    安装 1.下载地址 https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.8-signed.msi 2.如果报没 ...

  7. Mysql备份系列(4)--lvm-snapshot备份mysql数据(全量+增量)操作记录

    Mysql最常用的三种备份工具分别是mysqldump.Xtrabackup(innobackupex工具).lvm-snapshot快照.前面分别介绍了:Mysql备份系列(1)--备份方案总结性梳 ...

  8. LVM基础详细说明及动态扩容lvm逻辑卷的操作记录

    LVM概念:---------------------------------------------------------------------------------------------- ...

  9. mysql数据库补充知识2 查询数据库记录信息之单表查询

    一 单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field LIMIT 限制条数 二 关键 ...

随机推荐

  1. Android ClearEditText:输入用户名、密码错误时整体删除及输入为空时候晃动提示

    package com.lixu.clearedittext; import android.app.Activity; import android.os.Bundle; import androi ...

  2. 用C#用C#实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码

    run(){        while(true)        {                show();                if(条件)                {     ...

  3. HDU 4046 Panda

    线段树单点更新,要注意两段合并多出的答案的计算即可 //======================================================================== ...

  4. java.util.ResourceBundle使用详解(转)

    java.util.ResourceBundle使用详解   一.认识国际化资源文件   这个类提供软件国际化的捷径.通过此类,可以使您所编写的程序可以:          轻松地本地化或翻译成不同的 ...

  5. CodeIgniter 让控制器可以支持多级子目录的 Router 类库

    MY_Router.php 放到 system/application/libraries 目录下,就可以让 CI 的控制器支持多级子目录了.这样,你就可以在 system/application/c ...

  6. php base64_decode 解码方法

    <?php header('Content-Type:text/html;charset=utf-8'); function encode_file_contents($filename) { ...

  7. C++-new操作符

    1,new操作符实际上包含三部分:operator new分配内存和调用构造函数初始化刚刚分配的内存,类型转换刚刚的指针. string* ps = new string("lalalala ...

  8. C++-不要在构造和析构函数中调用虚函数

    在实习的单位搞CxImage库时不知为什么在Debug时没有问题,但是Release版里竟然跳出个Pure virtual function call error! 啥东西呀,竟然遇上了,就探个究竟吧 ...

  9. [windows驱动]基本概念

    https://msdn.microsoft.com/zh-cn/library/windows/hardware/ff554721 1.设备节点和设备堆栈 在windows中,设备通过即插即用设备树 ...

  10. PHP ceil() 函数

    定义和用法 ceil() 函数向上舍入为最接近的整数. 语法 ceil(x) 参数 描述 x 必需.一个数. 说明 返回不小于 x 的下一个整数,x 如果有小数部分则进一位.ceil() 返回的类型仍 ...