一些通过SAP ABAP代码审查得出的ABAP编程最佳实践
1. 这两个IF ELSE分支里检测的条件其实逻辑上来说都是同一类,应该合并到一个IF分支里进行检查:
It is an expensive operation to open a file in application server with 50MB file size.
Current logic is:
1. Open the file in application server
2. Read the file content line by line
3. If the file is regarding IPG or MIDH or TPG, handle with each line separately
The correct logic should be:
1. Check the file path whether it is IPG or MIDH or TPG related. If not, quit the report.
2. Handle with each line directly without evaluate file path in the BIG loop.
The validation logic for input records should be improved
Loop at all service BOM, check whether the ID in current loop does exist in validation table lt_valid_prod or lt_valid_sp. If so, delete them via DELETE TABLE XXX FROM .
Improvement: use DELETE XXX WHERE product_id NOT IN . It is more efficient when lt_srv_bom_file has a huge number of records. See comparison below ( unit: second )
这是一个性能问题。使用ABAP原生支持的NOT IN关键字可以获得更好的性能。性能评测如下:
Avoid using SELECT to access table with a large number of entries
In product / IObject area, the best practice is to use OPEN CURSOR / FETCH NEXT CURSOR to access big DB table.
如果需要用ABAP OPEN SQL读取一张包含海量记录的数据库表,那么推荐使用OPEN CURSOR进行分块读取。
Although this solution will spend almost the same time to fetch the data from DB, it has far less memory consumption compared with using SELECT to fetch ALL data from DB at one time.
The original dump due to out of memory issue could be eliminated by replace SELECT with OPEN CURSOR statement.
这种方式和直接用SELECT相比,能显著减少内存消耗量。
使用并发编程提高应用程序场景
通过下面这段代码模拟一个费时的ABAP程序:
定义一个ABAP函数:
这个函数里执行一大堆计算,然后把传入的product ID写到一张自定义表ZJERRY1里。
调用这个函数的代码:
注意第二种方案使用STARTING NEW TASK达到的并发执行效果:
通过比较,第二种解决方案的效率是第一种的四倍。
1. The more CPU & DB time spent in ZINSERT, the better performance will be gained by using
parallel processing (Asynchronous RFC call).
2. The more number of ZINSERT call, the better performance will be gained by using parallel
processing.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
一些通过SAP ABAP代码审查得出的ABAP编程最佳实践的更多相关文章
- 长期内部推荐SAP职位,包括Java ABAP 咨询顾问,Developer,架构师等。
长期内部推荐SAP职位,包括Java ABAP 咨询顾问,Developer,架构师等. 有需要请发简历到邮箱 LoB Position LocationAcquisitions Hybris ...
- SAP 产品条码WMS结合 以及ABAP script的集成 BarCode
条码和RFID打印解决方案 1, 热转印条码标签打印 热转打印技术的原理是通过加温和加压将色带上的固体油墨熔化转印到介质上完成打印的.通过选择热转印色带与标签材料匹配,热转印打印方式可以产生耐高温 ...
- 一步步用ABAP Development Tools连接SAP云平台上的ABAP编程环境
使用ABAP Development Tools的项目创建向导: New->ABAP Cloud Project: Service Instance Connection,选择SAP Cloud ...
- 【ABAP系列】SAP ABAP 高级业务应用程序编程(ABAP)
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 高级业务应用程 ...
- 【ABAP CDS系列】ABAP CDS中的系统信息
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP CDS系列]ABAP CDS中的系统 ...
- SmartbBear给出的11条代码审查最佳实践
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:SmartbBear给出的11条代码审查最佳实践.
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(上)
这篇博文难产了很久,原来是打算一周更新一篇的,上周原计划写MVC,但是写了一半,发现带入了太多的细节,不太符合这个入门系列的主题. 当我们学习一个新的技能的时候,如果一开始就面对大量的细节,很容易陷入 ...
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(下)
上期我们完成了一个简单的主从页面,但是页面是静态的,不能交互,功能也很简单,只有一个销售订单的列表. 我们今天就一鼓作气把代码全都写完,由于本次的代码量较大,所以只对重点代码部分进行讲解. 具体每个文 ...
- [SAP ABAP开发技术总结]ABAP程序之间数据共享与传递
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
随机推荐
- vi 中插入当前时间
声明 笔者最近意外的发现 笔者的个人网站http://tiankonguse.com/ 的很多文章被其它网站转载,但是转载时未声明文章来源或参考自 http://tiankonguse.com/ 网站 ...
- spring整合struts2和hibernate
1.spring 1.1 jar包 1.2 spring.xml <?xml version="1.0" encoding="UTF-8"?> &l ...
- No.2一步步学习vuejs 实例demo篇
简单应用Vue.js 的核心是一个允许采用简洁的模板语法来声明式的将数据渲染进 DOM 的系统: <div id="app"> {{ message }} </d ...
- CF Dima and Salad 01背包
C. Dima and Salad time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 把一个项目a生成后放在另一个项目b使用(b项目是例子中的ScreenWebPage_Tool)
a项目属性---生成事件---后期生成事件命令行 xcopy /r /y $(TargetDir)*.* $(SolutionDir)ScreenWebPage_Tool\bin\Debug\* ...
- Microsoft Windows Scripting Self-Paced Learning Guide
http://www.mums.ac.ir/shares/hit/eduhit/book/windowsscripting.pdfhttp://support.microsoft.com/kb/926 ...
- centos install redis
1. 下载 [logan@localhost java]$ wget http://download.redis.io/releases/redis-3.2.8.tar.gz2. 解压 [log ...
- 移动端mate标签设置
<meta name="viewport" content="width=device-width,height=device-height,initial-sca ...
- 原生js制作标题与内容保持4行的效果
在制作网页或移动端有时会用到一个效果,类似文章标题和文章描述的排列总是保持一样的行数,要么标题总是一行,多出的省略,要么标题内容1:3或2:2或3:1这样,今天练习这样的效果. 实现的原理:给标题和内 ...
- Javascript 多物体淡入淡出(透明度变化)
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...