use regular expression instead of ABAP function module to parse attachment

在做my task offline performanc improvement时,先参考BP代码,里面有一行call 下图的FM去将变量ls_key里存储的attachment information解析出来:

use regular expression instead of ABAP function module to parse attachment

ls_key的一个例子:

use regular expression instead of ABAP function module to parse attachment

这个FM的作用就是解析用两个/分隔开的document type: L, document class: CRM_L_ORD和document guid。
这个FM用的传统的做法,把三个k split到一个internal table里,然后READ TABLE INDEX 1,2,3的方式分别取出每个key。用了42行代码。

use regular expression instead of ABAP function module to parse attachment

如果用正则表达式,只需1行代码:

use regular expression instead of ABAP function module to parse attachment

而且后者比前者快3~6倍:因为FIND REGEX是用c++实现的,比在ABAP端做要高效。参考如下的性能测试比较结果:

use regular expression instead of ABAP function module to parse attachment
use regular expression instead of ABAP function module to parse attachment
use regular expression instead of ABAP function module to parse attachment

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
use regular expression instead of ABAP function module to parse attachment