一些通过SAP ABAP代码审查得出的ABAP编程最佳实践

  • 时间:
  • 浏览:1
  • 来源:大发彩神下载—大发彩神APP

1. Open the file in application server

1. Check the file path whether it is IPG or MIDH or TPG related. If not, quit the report.

通过比较,第二种避免方案的数率是第五种的四倍。

3. If the file is regarding IPG or MIDH or TPG, handle with each line separately

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 )

The original dump due to out of memory issue could be eliminated by replace SELECT with OPEN CURSOR statement.

注意第二种方案使用STARTING NEW TASK达到的并发执行效果:

你你这个函数里执行一大堆计算,你你这个把传入的product ID写到一张自定义表ZJERRY1里。

定义有另三个白ABAP函数:

肯能都要用ABAP OPEN SQL读取一张带有海量记录的数据库表,没人推荐使用OPEN CURSOR进行分块读取。

这是有另三个白性能问题。使用ABAP原生支持的NOT IN关键字还都都可不可以 获得更好的性能。性能评测如下:

It is an expensive operation to open a file in application server with 80MB file size.

processing.

2. Read the file content line by line

parallel processing (Asynchronous RFC call).

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 .

调用你你这个函数的代码:

通过下面这段代码模拟有另三个白费时的ABAP程序运行池池:

In product / IObject area, the best practice is to use OPEN CURSOR / FETCH NEXT CURSOR to access big DB table.

The correct logic should be:

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.

2. The more number of ZINSERT call, the better performance will be gained by using parallel

你你这个妙招和直接用SELECT相比,能显著减少内存消耗量。

1. The more CPU & DB time spent in ZINSERT, the better performance will be gained by using

1. 这有另三个白IF ELSE分支里检测的条件嘴笨 逻辑上来说就有同一类,应该合并到有另三个白IF分支里进行检查:

Current logic is:

2. Handle with each line directly without evaluate file path in the BIG loop.