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 <current line>.
Improvement: use DELETE XXX WHERE product_id NOT IN <range table>. 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 代码备份下载到本地程序代码
从实例学sap abap编程,从实例学sap abap编程,从实例学sap abap编程
资源名称:sap abap开发从入门到精通 内容简介: 《SAP ABAP开发从入门到精通》以应用实例的形式,讲解了SAPABAP开发的相关知识点,详细介绍了SAPABAP开发者必须掌握的包与变更传输系统(CTS)、数据类型、数据库...
SAP ABAP 1.4.4代码下载
实战SAP程序开发——从实例学SAP ABAP编程前12章
SAP ABAP 数据库操作,快速学会ABAP!
实战sap程序开发——从实例学sap abap编程
《SAP ABAP开发技术详解(实例篇)(第二版) [1] 》除了对对SAP ABAP开发所需的常用技术(SAP报表、批量导入、对话程序、函数)做了详尽的介绍,包括基本报表、交互式报表、复杂报表、ALV(SAP List Viewer)报表、...
sap abap ,快速掌握ABAP编程,63页内容,
SAP应用及ABAP开发最佳实践—Internal Table,
SAP ABAP开发学习——第9课:ALV2(视频教程) 1.SAP ABAP开发入门学习 2.含视频教程学习、PPT、作业 3.视频非常清晰
《SAP ABAP开发从入门到精通》以应用实例的形式,讲解了SAP ABAP开发的相关知识点,详细介绍了SAP ABAP开发者必须掌握的包与变更传输系统(CTS)、数据类型、数据库、模块化程序、内表、调试、ABAP数据字典、锁对象...
从实例学SAP ABAP编程完整版
想学习sap但又无所下手的同学可以看这个了解下什么是sap,每一步都有详细的描述,简单易学,从实例学SAP ABAP编程...
SAP+ ABAP开发实用教程:顾问培训资料,含实例代码和教程,详细描述ABAP开发过程:数据表读法、程序规范、代码实例、调试方法以及ABAP开发环境和总体介绍、 ABAP语法示例 、ALV控件的使用、 实战Form设计 ,分基础、...
ABAP开发从入门到精通_高清自学版 SAP+ABAP开发从入门到精通 SAP开发自学必读 SAP SAP开发自学入门到精通完整版HANA开发
全面介绍SAP ABAP语言编程与开发(SAP官方文档)
实战SAP程序开发--从实例学SAP ABAP编程,有兴趣的可以下载
DOC版ABAP编程手册,包含完整13章
实战SAP程序开发——从实例学SAP ABAP编程 13-19章