这篇文章将为大家详细讲解有关SAP CRM get_children 方法里面参数iv_as_copy 有什么用,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
lv_children = iv_account->get_children( iv_as_copy = abap_true ). 的参数啥意思
lo_children = iv_account->get_relation( iv_relation_name = <rel>
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)
(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的。
关于SAP CRM get_children 方法里面参数iv_as_copy 有什么用就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。