SAP-ABAP语法整理

更新时间:2023-07-20 09:14:28 阅读: 评论:0

1ST05是用于在开发ABAP程序时,对应事务码取得的字段是数据结构而不是透明表的时候,通过ST05“SQL苹果汁的做法跟踪来获得相关“Select”的语句;一般查看“REC”列耗时比较多的“Select”语句;
2、跟踪时如果有涉及到数量这类有对数据表进行更新或插入操作的,则直接去查UpdateInrtSQL语句;
3、在跟踪后,直接双击对象名列的名称,点选表格转到“SE11”的表字段表;
4ABAP程序开头的Tables:“数据表名,只有在屏幕中有用到的表,才需要声明;在程序中用到的表则不需要进行在Tables内声名;
5抽卡技巧SAP“文本字段的数据,要先自定义变量,然后通过SE37的函数“FUNCTION ’ZREAD_TEXT’”取回文本数据
6、新建的ABAP老人言程序,在测试运行的时候要先进行激活,才能测试运行;
7SE93:把ABAP写好的程序指定一个事务码执行;
8abap引号内的字符’’必须要是大写;
9ABAP lect 里面的语句,不能像mssql有那么丰富的函数使用,需要导到内表后再对数据进行操作;
10’EQ’是单个数据值,’BT’between区间的意思。
11、在写lect inner join 里面,要注意是否需要加上销售组织的条件;on 条件1 and 销售组织条件。
12SELECTION-SCREEN,里面有两个子项,PARAMETERSlect-options
PARAMETERS 一般是用于必输项的屏幕参数设置,如果这个参数不是必输项的,就要用lect-options。在lect ...where条件里,用PARAMETERS的条件语法是数据字段 = 屏幕字段;而lect-options的条件语法是数据字段 in 屏幕字段绣鞋垫。
13、在where判断一个日期型数据是空,不是DEAKT = ’’,也不是DEAKT is initial,而应该写成DEAKT = ’00000000’ (80)一年定期存款利率。
14、一对多的inner join,如果取出的数据有重复,前面加上distinct,用法和MSSQL相同。
15sy-subrc,指上一个语句执行是否成功;执行成功返回0,执行不成功返回非0。用if判断。
16、如果一个语句中,该名称同时可能代表内表或者同名表工作区,则需要在内表名称之
后加“[]”指明当前操作的是内表对象。不提倡使用带有表头行的内表,而是应该总是声明结构相同的其他数据对象作为显示工作区进行内表行操作。 
如何调整ABAP程序的性能(copy)
1、使用where语句 
不推荐
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endlect.
推荐
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endlect.
2、使用聚合函数
不推荐
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endlect.
推荐
Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
3、使用视图代替基本表查询
不推荐
小白鹅Select * from zcntry where cntry like ‘IN%’. [Page]
Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
Endlect.
推荐
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endlect.
4、使用INTO table 代替lect endlect
不推荐
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endlect.
推荐
Refresh: int_fligh.
Select * from zflight into table int_fligh.
5、使用批量修改内表代替逐行修改
高纤维水果不推荐
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’. 中果皮
Endif.
Modify int_fligh.
Endloop.
推荐
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.
6、使用二分法查询,提高查询内表数据速度
不推荐
Read table int_fligh with key airln = ‘LF’.
推荐
Read table int_fligh with key airln = ‘LF’ binary arch.
7、两个内表添加使用批量增加代替逐行
不推荐
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
推荐
Append lines of int_fligh1 to int_fligh2.
8、使用table buffering
U of buffered tables is recommended to improve the performance considerably. The buffer is bypasd while using the following statementsSelect distinct 
Select … for update 
Order by, group by, having clau 
Joins 
U the Bypass buffer addition to the lect clau in order to explicitly bypass the buffer while lecting the data.
9 使用FOR ALL Entries
不推荐
Loop at int_cntry. Select single * from zfligh into int_fligh where cntry = int_cntry-cntry. Append int_fligh. Endloop.
推荐
Select * from zfligh appending table int_fligh
For all entries in int_cntry 
Where cntry = int_cntry-cntry.
10、正确地使用where语句,使查询能使用索引When a ba table has multiple indices, the where clau should be in the order of the index, either a primary or a condary index
To choo an index, the optimizer checks the field names specified in the where clau and then us an index that has the same order of the fields. One more tip is that if a table begins with MANDT, while an index does not, there is a high possibility that the optimizer might not u that index.
11、正确地使用MOVE语句
Instead of using the move-corresponding clau it is advisable to u the move statement instead. Attempt should be made to move entire internal table headers in a sin
gle shot, rather than moving the fields one by one.

本文发布于:2023-07-20 09:14:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1088856.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:内表   使用   数据
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图