0
点赞
收藏
分享

微信扫一扫

比较有意思的比较内表的小函数

包       :CT

函数组:CTVB 

函数模块:CTVB_COMPARE_TABLES  



CALL FUNCTION ‘CTVB_COMPARE_TABLES’
EXPORTING
table_old = t_old
table_new = t_new
key_length = 22
IMPORTING
table_del = t_result

* table_mod = 
* table_add
no_changes = g_flag.





这个函数模块比较两个内表,将被删除、增加和修改的内表行分别分组输出。

输入参数:
TABLE_OLD :旧表
TABLE_NEW :新表
KEY_LENGTH :键长度,指定内表中的前若干个字节(在 Unicode 系统中为字符,因此指定长度内不能存在数值类型的字段)为主键,做为内表行是否为增加的判断条件。
IF_SORTED :排序标记,如果已排序,在比较时可以提高效率。

输出参数:
TABLE_DEL :被删除的行
TABLE_ADD :被增加的行
TABLE_MOD :被修改的行
NO_CHANGES :表没有被修改的标记,如果这个标记为 “X”,就不必去读前面三个内表了。


t_result 如果不为空,就是想要的内表,可以对它进行处理。

g_flag如果为’X’,两个内表数据相同。

另外,像两个内表的新增数据和修改数据都可以在返回参数TABLE_ADD和TABLE_MOD得到。



里面还有很多其他的,没研究,可以去试试


例子

DATA:
      l_it_makt  LIKE STANDARD TABLE OF makt ,
      l_it_makt1  LIKE STANDARD TABLE OF makt ,
      l_it_makt3  LIKE STANDARD TABLE OF makt ,  
      l_it_makt4  LIKE STANDARD TABLE OF makt ,
      l_it_makt5  LIKE STANDARD TABLE OF makt ,
      l_it_makt2  LIKE STANDARD TABLE OF makt .


SELECT * FROM makt INTO TABLE l_it_makt.
SELECT * FROM makt INTO TABLE l_it_makt1.

DELETE l_it_makt1  WHERE matnr = '000000000500000003'.

CALL FUNCTION 'CTVB_COMPARE_TABLES'
  EXPORTING
    table_old        = l_it_makt
    table_new        = l_it_makt1
    key_length       = 21     " client 3位  +     物料号18位
*   IF_SORTED        =
 IMPORTING
   TABLE_DEL        = l_it_makt2
   TABLE_ADD        = l_it_makt3
   table_mod        = l_it_makt4
*   NO_CHANGES       = l_it_spfl5
          .
IF 1 = 2.

ENDIF.

函数模块:BUS1088_DATABASE_UPDATE 



BUS1088_DATABASE_UPDATE is a standard SAP function module available within R/3 SAP systems depending on your version and release level.

 Below are the pattern details for this FM showing its interface including any import, export parameters etc and for your convenience any standard documentation available. All this information and more can be viewed if you enter the function module name BUS1088_DATABASE_UPDATE into the relevant SAP transaction such as SE37 or SE80. 

Within the comments section below there is also an opportunity for you to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name BUS1088_DATABASE_UPDATE or its description.


Pattern for FM BUS1088_DATABASE_UPDATE - BUS1088 DATABASE UPDATE Associated Function Group: CTVB 
Released Date: Not Released
CALL FUNCTION 'BUS1088_DATABASE_UPDATE' "
* EXPORTING
*   it_aennr =                  " tt_rctae
*   it_cabn =                   " tt_cabn       Characteristic
*   it_cabnt =                  " tt_cabnt      Characteristic Descriptions
*   it_cabnz =                  " tt_cabnz
*   it_cawn =                   " tt_cawn       Values
*   it_cawnt =                  " tt_cawnt      Value Descriptions
*   it_tcme =                   " tt_tcme       Class Types
*   it_atinn_delete =           " tt_atinn_range
*   dep_changed =               " flag
    .  "  BUS1088_DATABASE_UPDATE


举报

相关推荐

0 条评论