CRM 系统实现中的 get_children 方法里面参数 iv_as_copy 有什么用?

网友投稿 593 2022-05-30

lv_children = iv_account->get_children( iv_as_copy = abap_true ). 的参数啥意思

lo_children = iv_account->get_relation( iv_relation_name =

iv_as_copy = abap_false ).

解释没太看懂

There is one special thing you need to know on the parameter IV_AS_COPY of GET_CHILDREN. It has

only effect on the iterator GET_FIRST etc. of the container list you will receive back. If set to true the

iterator will iterate only on the children inside the container list when it was created. If the parameter is

set to false the iterator will take into account children that are added to the container (or which are deleted

from it) after the container list was get. It is a misunderstanding that you get a copy of the content of the

container if you use this parameter. Knowing this you now have the knowledge going through the

relations of your model getting a separate nested container for every 1:n relation.

Rule of thumb:

(1) iv_as_copy = true => you get a snapshot (preffered)

CRM 系统实现中的 get_children 方法里面参数 iv_as_copy 有什么用?

(2) iv_as_copy = false => list gets updated; use only if you want to keep the list; has negative impact on

performance/memory consumption

其实对于做过debug的developer,看了文档里对这个参数的解释后理解就会更加深刻。但是的确刚刚接触的developer看了解释可能仍然似懂非懂。

这个参数关键起作用的地方就在container object list的构造函数里:

如果你使用iv_as_copy = true得到一个container object list,那么这个container object list A 只是当前parent container object的children的一个snapshot,今后parent container object 如果有新的children加进来之后,新的child不会反映到你得到的snapshot A去,因为technical上讲,你的snapshot并没有注册 parent container object的CHILD_ADDED event,因为不会被通知到。

举一个例子:

我在从Account navigate 到AccountAddress的地方加一段代码,分别存储两种方式得到的account address container object list,这个时候还没有真正取Account address,所以两个container object list里面都只有一个dummy的entry,is_handle = X

我新建一个Address,然后save

因为当前的Account DB里面有50个address,我又在当前session里面添加了1个,所以iv_as_copy = false的有51个item,而snapshot仍然只有1个dummy的。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:spaCy使用
下一篇:【SpringCloud-Alibaba】环境搭建以及注意事项。
相关文章