SAP Abap Syntax Collection (语法集合)
2013-03-05 15:42
363 查看
abap syntax collection ii
1,abap的数据类型分为三种类型
*1,类型 *2,结构 *3,内表
*******************************************************************************
2,数据定义
*1 直接定义
data int_a type i.
*2 参照自己定义的数据类型定义
type char_six(6) type c.
data chs type char_six.
*3 参照se11中建立的数据类型定义
*4 直接使用like
data ch4 like ch3. (其中ch3已经在se11中定义过)
定义常数:使用constants
基本语法:
constants: <const.
name> type <type> value <literal>.
constants int type i value 99.
*******************************************************************************
3. 选择copy按钮,输入程序名字即可(客户的程序名字,需要以z开头)
*******************************************************************************
4,如何设置关键字的大小写功能?
路径:在utilities--settings—pretty printer
*******************************************************************************
5,模式按钮
作用:可以call function,写write等固定格式,message等功能
操作方法:将光标放在程序中你要输入的地方,然后按pattern,输入你要输入的参数,回车即可。
旁边的pretty printer 是美化program,即是以标准的缩进和注释对program
*******************************************************************************
6,如何进行程序调试?
其中 f5 单步执行
f6 执行子程序的时候,不进入子程序,即跳过子程序
f7 跳出目前的子程序
f8 直接执行
*******************************************************************************
7,在窗口上直接输入 /h 就可以进入程序调试的模式
*******************************************************************************
8,创建事务代码t-code:se93
另一种创建t-code的方法是在程序中点击右键—创建—transaction 也可以创建一个t-code
*******************************************************************************
9,write:a ,b,c。
其中的冒号是语法链的作用。
******************************************************************************
10,如何定义一格结构?
*1,直接定义结构
data : begin of stru_ztaly,
name(10) type c,
……
end of stru_ztaly.
*2,自己在程序里先定义结构类型,再参照类型定义结构对象。
types: begin of stru_ztaly,
name(10) type c,
……
end of stru_ztaly.
data: stru_ztaly2 type stru_ztaly.
*3,在se11定义一个公共的类型,再参照类型定义结构对象。
data :stru_italy type ityp_s_ztaly.
*4,使用like
data stru_italy2 like stru_italy (其中stru_italy是已经定义了的结构)
*******************************************************************************
11,如何建立内表?
*1, 直接建内表
data : begin of itab_italy occurs 0,
ino type i,
…..
end of itab_italy.
*2,自己先建一个结构类型,再根据这个结构类型建内表
type :begin of typ,
ino type i,
……
end of typ.
data: itab_typ type table of typ.
其中关键字table不能少,否则还是结构,而不是内表
*3,现在数据字典中建一个内表类型,再参照这个类型
data:itab_italys type zty_t_italy.
说明:对内表的操作必须依靠结构进行。
for example: append stru_italy to itab_italy.
增加一行到内表中。
*4,内表输出必须依靠于结构,而且要循环输出
for example:
loop at itab_italy into stru_ztaly.
write: / ……….
endloop.
*5,特殊情况
tables: 表名a
说明:定义了一个和a同样名称的数据结构。
a type b occurs n。
说明:定义出来的一格内表
*6,data <itab> type <itabtype> [with header line]
说明:在定义的时候同时生成一个同名的结构
*******************************************************************************
12,如何理解程序中的流程呢?
说明:程序其实存放在database中的
*******************************************************************************
13,数据元素,结构和内表的区别是什么?
用一句话说明:就相当于数学中的 点 线 面
*******************************************************************************
14, open sql与 native sql的流程区别是什么?
说明:使用了open sql 就不必要理会后台的数据库,只要掌握了open sql就ok
使用native sql 只和后台数据库习习相关
上图:主要说明了
open sql 只能使用dml 而 native sql 可以使用dml 和ddl
open sql 包含:insert,update,delete,modfy
*******************************************************************************
15,processing of tha abap processing block resumes(摘要)?
*******************************************************************************
16,系统参数sy-subrc的功能是?
若返回值为 0 表示系统执行数据成功
若返回值不为0 表示系统执行数据不成功(返回具体数据的含义参加f1帮助文件)
*******************************************************************************
17,message 的语法使用的例子?
说明:
其中bc400 是message class
而message:
040:the name of the airline &1 is &2.
041:airline &1 is not available. (&1和&2 都是program中的变量)
*******************************************************************************
18,系统得消息类型有几种?
其中warning的类型,可以不必理会,直接回车,就可继续执行
error的类型,在执行过程中若产生error类型的,将阻止系统继续往下执行
19,t-code:se14的作用?
主要是调整表的作用,具体功能未知
20,系统参数sy-dbcnt的作用是?
sy-dbcnt表示找到的记录的序号,第一条记录为1,第二条记录为2,最后一条记录的序号也是记录数
21,消息管理的t-code:se91
管理请求号t-code:se10
创建帐号 t-code:su01
创建角色 t-code:pfcg
传输管理系统t-code:stms
跨客户端的应用层次 t-code:se81
寻找跨客户端组件 t-code:se84
创建事务代码:t-code:se93
创建增强工程:t-code:cmod
22,modify语句的作用?
这个是sap特有的语句,若该数据在数据库中存在,则update
若该数据在数据库中不存在,则insert
23,报表分为哪四类?
*1,tools --query
*2,simple lists --简单报表
*3,interactivelists --交互式报表
*4,alv grid Control --alv
24,query 的特征
*1,user basic reports
*2,each user defines own quickviews which only they can display
*3,uses existing data
*4,no administrative(管理的) work
*5,可以使用query进行修改
*6,interface to internal(EIS,ABC,ALV)and external application
*7,fewer functions than infoset query
*8,no transports
24,如何产生一个简单的报表?
report zrl003.
data:wa_spfli like spfli.
select carrid connid cityfrom cityto
into corresponding fields of wa_spfli
from spfli.
write: / wa_spfli-carrid, wa_spfli-connid,
wa_spfli-cityfrom, wa_spfli-cityto.
endselect.
25,setting the list format(报表的宽度和高度)?
基本的语法:
report <name> line-size <s> line-count <m[(n)]>.
for example:
report zrl003 line-size 50
line-count 12.
……
write:…
产生出来的效果图为:
26,如何在程序中显示图标?
for example:
report zrl003.
include<icon>
include <symbol>
……
*state of free seats
if seatsfree < 1.
write icon_red_light as icon.
elseif seatsfree >1.
write icon_green_light as icon.
endif.
*state of booked seats
if wa_sflight-seatocc < 10.
write sym_left_hand as symbol
endif.
27,设置固定列和显示最后一页的语法
具体的例子参考sapbc405_fold_scroll_boundary
28,系统参数sy-vline作用是画竖线
sy-pagno 显示页数
sy-colno 显示列数
sy-linno 显示行数
29,如何使用checkbox and radiobutton
参看example
* Radiobutton group with frame and frame text
selection-screen begin of block seats with frame title text-s02.
parameters pa_occ radiobutton group seat.
parameters pa_fre radiobutton group seat.
parameters pa_all radiobutton group seat.
selection-screen end of block seats.
* Parameters displayed in one line
selection-screen begin of line.
selection-screen comment 1(20) text-s03.
selection-screen comment pos_low(8) text-s04.
parameters pa_col as checkbox.
selection-screen comment pos_high(8) text-s05.
parameters pa_ico as checkbox.
selection-screen end of line.
selection-screen end of block out_put.
30,如何使用select-options
程序名称:sapbc405_sscd_sel_screen_i
sapbc405_sscd_sel_screen_ii
其主要的语法为:
select-options for
default
default to
memory id
lower case
obligatory “必输
no-extension “不具有延伸功能
no intervals
屏幕输出还有一个参数为parameter
语法为:
parameter p_xxxxx like 。
而select-option 和parameter的使用区别主要在:
*1 使用Select-option时候,默认的全部的值
而使用parameter的时候,默认的值是空值
*2 使用select-option 用for
使用parameter的时候,使用的是like
说明:
*1 由于parameter,默认的是空值,所有在程序中,往往需要用if先进行判断是否为初始值。****initial****
*2 在程序中如果是与范围的参数进行匹配的时候,where条件中用in
32,如何进行初始值?
在initialization的事件中输入
initialization.
move: mark to pa_all.
move: 'I' to so_carr-sign,
'BT' to so_carr-option,
'AA' to so_carr-low,
'LH' to so_carr-high.
append so_carr.
clear so_carr.
move: 'E' to so_carr-sign,
'EQ' to so_carr-option,
'DL' to so_carr-low.
append so_carr.
31,input checks: at selection-screen
程序名称:sapbc405_sscd_at_sel_screen
* Check of selection criterion SO_DEPT
**判断飞行的事件如果小于6点或者大于22点的时候,提示出错误。
at selection-screen on so_dept.
if ( so_dept-low lt '060000' or so_dept-high lt '060000' )
or ( so_dept-low ge '220000' or so_dept-high ge '220000' )
and airp_fr eq 'FRA'.
message e002(bc405).
endif.
其中message e002(bc405).这句中的bc405是一个message的类,而e002是一个消息
for example:
32,如何在程序中call selection-screen?
程序中的部分代码为:sapbc405_sscd_call_sel_screen
report sapbc405_sscd_call_sel_screen
….
selection-screen: begin of screen 1100.
parameters: pa_cus as check box,
pa_agy as checkbox.
selection-screen:end of screen 1100.
at selection-screen on pa_add.
if pa_add = mark.
call selection-sreen 1100
starting at 5 5 ending at 50 10.
if sy-subrc 0.
leave to screen 1000.
endif.
endif.
显示出来的结果如下:
33,层级报表的流程?
说明的是:
在使用层级报表的时候,必须要进行排序
34,关于使用程序中的关键字notes
说明该程序中使用了逻辑数据库
35,在write语句中,让鼠标移到输出的栏位上就会出现手型的图标
程序中的代码为参见例子
if wa_flights-seatsocc gt 0.
write: wa_flights-seatsocc hotspot on.
else.
write: wa_flights-seatsocc.
endif.
在write中如何画图标
write icon_red_light as icon.
36,如何得到鼠标取得的数?
程序中的代码为参见例子
基本语法:
get cursor field [value ]
for example:
*1,data: field_name(30), field_value(50).
get cursor field field_name value field_value.
*2 Data: field_name(30).
……
at line-selection.
get cursor field field_name.
case field_name.
when 'WA_FLIGHTS-CARRID'.
select single carrname currcode into (carrname, currcode)
from scarr where carrid = wa_flights-carrid.
write: / 'Airline carrier:', carrname,
/ 'Short name:', wa_flights-carrid,
/ 'Local currency of the airline:', currcode.
window starting at pos sy-curow
ending at 50 30.
37,事件on change of
参见例子
on change of 、
new page
说明:当改变变量的时候才开始新的一页。
(1).
any table:即任意表类型,此种定义方式只能在传递参数的时候定义。
例如:form xxx using/changing type any table .
(2).any table包括了两种类型:index table和hashed table 。
《1》.
index table:包括了standard table和sorted table
a.
standard table:其实就是一个线性表,通过key访问内表是线性查找的,也就是说,随着表中记录的增加,对表的操作的时间开销也相应的增加。
定义方法:types/data: like/type standard table of .
b. sorted table:顾名思义,表中的记录是按照一定的顺序排列的。访问表的主要方式是表中定义的key,如果key不唯一,则选择index最小的那个。也可以通过index来访问排序表,如果你想通过index插入一条记录,系统会自动检查你插入的位置是否正确。所以,如果插入的时间比插入到标准表的时间会长。因此,尽量选择key来对排序表进行操作。
定义方法:types/data: like/type sorted table of .
《2》.hashed table:对哈希表只能用你定义的key进行操作,而不能使用index进行操作。因此,定义哈希表必须定义unique key 。注意:所有关于使用index操作表的语句都不能用于操作哈希表。例如:sort,loop等。
定义方法:types/data: like/type hashed table of .
2. 内表的操作:
(1).
创建:
a.
定义一个结构,然后type/like这个结构
例如:
types: begin of ,
...
i> ...,
...
end of .
data type standard table of
with non-unique default key
initial size
with header line.
b. type/like系统表或者数据库表或者结构
data type standard table of <系统表名>
initial size
with header line.
(2).添加数据:
a.append:直接向表中添加数据
1.
append [wa to|initial line to] itab[assigning |reference into dref].
2. append lines of itab1 [from idx1] [to idx2] to itab2.
3. append [wa to] itab sorted by f [assigning
b.向表中插入数据:
1.
insert [wa into|initial line into] itab [index idx] [assigning |reference into dref].
2. insert [wa into|initial line into] table itab [assigning |reference into dref].
3. insert lines of itab1 [from idx1] [to idx2] into itab2 [index idx3].
4. insert lines of itab1 [from idx1] [to idx2] into table itab2.
c.相同字段求和向表里添加:
basic form
collect [wa into] itab.
extras:
1. ...
assigning
2. ...
reference into dref
3. ...
sorted by f
(3).
删除数据:
1.
delete itab.
2. delete table itab with table key k1 = v1 ... kn = vn.
3. delete table itab [from wa].
4. delete itab index idx.
5. delete itab from idx1 to idx2.
6. delete itab where logexp.
7. delete adjacent duplicates from itab.
(4).修改数据:
1.modify itab [from wa] [index idx] [assigning |reference intodref] [transporting f1 ... fn].
2. modify table itab [from wa] [assigning |reference into dref] [transporting f1 ... fn].
3. modify itab [from wa] transporting f1 ... fn where cond.
1,abap的数据类型分为三种类型
*1,类型 *2,结构 *3,内表
*******************************************************************************
2,数据定义
*1 直接定义
data int_a type i.
*2 参照自己定义的数据类型定义
type char_six(6) type c.
data chs type char_six.
*3 参照se11中建立的数据类型定义
*4 直接使用like
data ch4 like ch3. (其中ch3已经在se11中定义过)
定义常数:使用constants
基本语法:
constants: <const.
name> type <type> value <literal>.
constants int type i value 99.
*******************************************************************************
3. 选择copy按钮,输入程序名字即可(客户的程序名字,需要以z开头)
*******************************************************************************
4,如何设置关键字的大小写功能?
路径:在utilities--settings—pretty printer
*******************************************************************************
5,模式按钮
作用:可以call function,写write等固定格式,message等功能
操作方法:将光标放在程序中你要输入的地方,然后按pattern,输入你要输入的参数,回车即可。
旁边的pretty printer 是美化program,即是以标准的缩进和注释对program
*******************************************************************************
6,如何进行程序调试?
其中 f5 单步执行
f6 执行子程序的时候,不进入子程序,即跳过子程序
f7 跳出目前的子程序
f8 直接执行
*******************************************************************************
7,在窗口上直接输入 /h 就可以进入程序调试的模式
*******************************************************************************
8,创建事务代码t-code:se93
另一种创建t-code的方法是在程序中点击右键—创建—transaction 也可以创建一个t-code
*******************************************************************************
9,write:a ,b,c。
其中的冒号是语法链的作用。
******************************************************************************
10,如何定义一格结构?
*1,直接定义结构
data : begin of stru_ztaly,
name(10) type c,
……
end of stru_ztaly.
*2,自己在程序里先定义结构类型,再参照类型定义结构对象。
types: begin of stru_ztaly,
name(10) type c,
……
end of stru_ztaly.
data: stru_ztaly2 type stru_ztaly.
*3,在se11定义一个公共的类型,再参照类型定义结构对象。
data :stru_italy type ityp_s_ztaly.
*4,使用like
data stru_italy2 like stru_italy (其中stru_italy是已经定义了的结构)
*******************************************************************************
11,如何建立内表?
*1, 直接建内表
data : begin of itab_italy occurs 0,
ino type i,
…..
end of itab_italy.
*2,自己先建一个结构类型,再根据这个结构类型建内表
type :begin of typ,
ino type i,
……
end of typ.
data: itab_typ type table of typ.
其中关键字table不能少,否则还是结构,而不是内表
*3,现在数据字典中建一个内表类型,再参照这个类型
data:itab_italys type zty_t_italy.
说明:对内表的操作必须依靠结构进行。
for example: append stru_italy to itab_italy.
增加一行到内表中。
*4,内表输出必须依靠于结构,而且要循环输出
for example:
loop at itab_italy into stru_ztaly.
write: / ……….
endloop.
*5,特殊情况
tables: 表名a
说明:定义了一个和a同样名称的数据结构。
a type b occurs n。
说明:定义出来的一格内表
*6,data <itab> type <itabtype> [with header line]
说明:在定义的时候同时生成一个同名的结构
*******************************************************************************
12,如何理解程序中的流程呢?
说明:程序其实存放在database中的
*******************************************************************************
13,数据元素,结构和内表的区别是什么?
用一句话说明:就相当于数学中的 点 线 面
*******************************************************************************
14, open sql与 native sql的流程区别是什么?
说明:使用了open sql 就不必要理会后台的数据库,只要掌握了open sql就ok
使用native sql 只和后台数据库习习相关
上图:主要说明了
open sql 只能使用dml 而 native sql 可以使用dml 和ddl
open sql 包含:insert,update,delete,modfy
*******************************************************************************
15,processing of tha abap processing block resumes(摘要)?
*******************************************************************************
16,系统参数sy-subrc的功能是?
若返回值为 0 表示系统执行数据成功
若返回值不为0 表示系统执行数据不成功(返回具体数据的含义参加f1帮助文件)
*******************************************************************************
17,message 的语法使用的例子?
说明:
其中bc400 是message class
而message:
040:the name of the airline &1 is &2.
041:airline &1 is not available. (&1和&2 都是program中的变量)
*******************************************************************************
18,系统得消息类型有几种?
其中warning的类型,可以不必理会,直接回车,就可继续执行
error的类型,在执行过程中若产生error类型的,将阻止系统继续往下执行
19,t-code:se14的作用?
主要是调整表的作用,具体功能未知
20,系统参数sy-dbcnt的作用是?
sy-dbcnt表示找到的记录的序号,第一条记录为1,第二条记录为2,最后一条记录的序号也是记录数
21,消息管理的t-code:se91
管理请求号t-code:se10
创建帐号 t-code:su01
创建角色 t-code:pfcg
传输管理系统t-code:stms
跨客户端的应用层次 t-code:se81
寻找跨客户端组件 t-code:se84
创建事务代码:t-code:se93
创建增强工程:t-code:cmod
22,modify语句的作用?
这个是sap特有的语句,若该数据在数据库中存在,则update
若该数据在数据库中不存在,则insert
23,报表分为哪四类?
*1,tools --query
*2,simple lists --简单报表
*3,interactivelists --交互式报表
*4,alv grid Control --alv
24,query 的特征
*1,user basic reports
*2,each user defines own quickviews which only they can display
*3,uses existing data
*4,no administrative(管理的) work
*5,可以使用query进行修改
*6,interface to internal(EIS,ABC,ALV)and external application
*7,fewer functions than infoset query
*8,no transports
24,如何产生一个简单的报表?
report zrl003.
data:wa_spfli like spfli.
select carrid connid cityfrom cityto
into corresponding fields of wa_spfli
from spfli.
write: / wa_spfli-carrid, wa_spfli-connid,
wa_spfli-cityfrom, wa_spfli-cityto.
endselect.
25,setting the list format(报表的宽度和高度)?
基本的语法:
report <name> line-size <s> line-count <m[(n)]>.
for example:
report zrl003 line-size 50
line-count 12.
……
write:…
产生出来的效果图为:
26,如何在程序中显示图标?
for example:
report zrl003.
include<icon>
include <symbol>
……
*state of free seats
if seatsfree < 1.
write icon_red_light as icon.
elseif seatsfree >1.
write icon_green_light as icon.
endif.
*state of booked seats
if wa_sflight-seatocc < 10.
write sym_left_hand as symbol
endif.
27,设置固定列和显示最后一页的语法
具体的例子参考sapbc405_fold_scroll_boundary
28,系统参数sy-vline作用是画竖线
sy-pagno 显示页数
sy-colno 显示列数
sy-linno 显示行数
29,如何使用checkbox and radiobutton
参看example
* Radiobutton group with frame and frame text
selection-screen begin of block seats with frame title text-s02.
parameters pa_occ radiobutton group seat.
parameters pa_fre radiobutton group seat.
parameters pa_all radiobutton group seat.
selection-screen end of block seats.
* Parameters displayed in one line
selection-screen begin of line.
selection-screen comment 1(20) text-s03.
selection-screen comment pos_low(8) text-s04.
parameters pa_col as checkbox.
selection-screen comment pos_high(8) text-s05.
parameters pa_ico as checkbox.
selection-screen end of line.
selection-screen end of block out_put.
30,如何使用select-options
程序名称:sapbc405_sscd_sel_screen_i
sapbc405_sscd_sel_screen_ii
其主要的语法为:
select-options for
default
default to
memory id
lower case
obligatory “必输
no-extension “不具有延伸功能
no intervals
屏幕输出还有一个参数为parameter
语法为:
parameter p_xxxxx like 。
而select-option 和parameter的使用区别主要在:
*1 使用Select-option时候,默认的全部的值
而使用parameter的时候,默认的值是空值
*2 使用select-option 用for
使用parameter的时候,使用的是like
说明:
*1 由于parameter,默认的是空值,所有在程序中,往往需要用if先进行判断是否为初始值。****initial****
*2 在程序中如果是与范围的参数进行匹配的时候,where条件中用in
32,如何进行初始值?
在initialization的事件中输入
initialization.
move: mark to pa_all.
move: 'I' to so_carr-sign,
'BT' to so_carr-option,
'AA' to so_carr-low,
'LH' to so_carr-high.
append so_carr.
clear so_carr.
move: 'E' to so_carr-sign,
'EQ' to so_carr-option,
'DL' to so_carr-low.
append so_carr.
31,input checks: at selection-screen
程序名称:sapbc405_sscd_at_sel_screen
* Check of selection criterion SO_DEPT
**判断飞行的事件如果小于6点或者大于22点的时候,提示出错误。
at selection-screen on so_dept.
if ( so_dept-low lt '060000' or so_dept-high lt '060000' )
or ( so_dept-low ge '220000' or so_dept-high ge '220000' )
and airp_fr eq 'FRA'.
message e002(bc405).
endif.
其中message e002(bc405).这句中的bc405是一个message的类,而e002是一个消息
for example:
32,如何在程序中call selection-screen?
程序中的部分代码为:sapbc405_sscd_call_sel_screen
report sapbc405_sscd_call_sel_screen
….
selection-screen: begin of screen 1100.
parameters: pa_cus as check box,
pa_agy as checkbox.
selection-screen:end of screen 1100.
at selection-screen on pa_add.
if pa_add = mark.
call selection-sreen 1100
starting at 5 5 ending at 50 10.
if sy-subrc 0.
leave to screen 1000.
endif.
endif.
显示出来的结果如下:
33,层级报表的流程?
说明的是:
在使用层级报表的时候,必须要进行排序
34,关于使用程序中的关键字notes
说明该程序中使用了逻辑数据库
35,在write语句中,让鼠标移到输出的栏位上就会出现手型的图标
程序中的代码为参见例子
if wa_flights-seatsocc gt 0.
write: wa_flights-seatsocc hotspot on.
else.
write: wa_flights-seatsocc.
endif.
在write中如何画图标
write icon_red_light as icon.
36,如何得到鼠标取得的数?
程序中的代码为参见例子
基本语法:
get cursor field [value ]
for example:
*1,data: field_name(30), field_value(50).
get cursor field field_name value field_value.
*2 Data: field_name(30).
……
at line-selection.
get cursor field field_name.
case field_name.
when 'WA_FLIGHTS-CARRID'.
select single carrname currcode into (carrname, currcode)
from scarr where carrid = wa_flights-carrid.
write: / 'Airline carrier:', carrname,
/ 'Short name:', wa_flights-carrid,
/ 'Local currency of the airline:', currcode.
window starting at pos sy-curow
ending at 50 30.
37,事件on change of
参见例子
on change of 、
new page
说明:当改变变量的时候才开始新的一页。
(1).
any table:即任意表类型,此种定义方式只能在传递参数的时候定义。
例如:form xxx using/changing type any table .
(2).any table包括了两种类型:index table和hashed table 。
《1》.
index table:包括了standard table和sorted table
a.
standard table:其实就是一个线性表,通过key访问内表是线性查找的,也就是说,随着表中记录的增加,对表的操作的时间开销也相应的增加。
定义方法:types/data: like/type standard table of .
b. sorted table:顾名思义,表中的记录是按照一定的顺序排列的。访问表的主要方式是表中定义的key,如果key不唯一,则选择index最小的那个。也可以通过index来访问排序表,如果你想通过index插入一条记录,系统会自动检查你插入的位置是否正确。所以,如果插入的时间比插入到标准表的时间会长。因此,尽量选择key来对排序表进行操作。
定义方法:types/data: like/type sorted table of .
《2》.hashed table:对哈希表只能用你定义的key进行操作,而不能使用index进行操作。因此,定义哈希表必须定义unique key 。注意:所有关于使用index操作表的语句都不能用于操作哈希表。例如:sort,loop等。
定义方法:types/data: like/type hashed table of .
2. 内表的操作:
(1).
创建:
a.
定义一个结构,然后type/like这个结构
例如:
types: begin of ,
...
i> ...,
...
end of .
data type standard table of
with non-unique default key
initial size
with header line.
b. type/like系统表或者数据库表或者结构
data type standard table of <系统表名>
initial size
with header line.
(2).添加数据:
a.append:直接向表中添加数据
1.
append [wa to|initial line to] itab[assigning |reference into dref].
2. append lines of itab1 [from idx1] [to idx2] to itab2.
3. append [wa to] itab sorted by f [assigning
b.向表中插入数据:
1.
insert [wa into|initial line into] itab [index idx] [assigning |reference into dref].
2. insert [wa into|initial line into] table itab [assigning |reference into dref].
3. insert lines of itab1 [from idx1] [to idx2] into itab2 [index idx3].
4. insert lines of itab1 [from idx1] [to idx2] into table itab2.
c.相同字段求和向表里添加:
basic form
collect [wa into] itab.
extras:
1. ...
assigning
2. ...
reference into dref
3. ...
sorted by f
(3).
删除数据:
1.
delete itab.
2. delete table itab with table key k1 = v1 ... kn = vn.
3. delete table itab [from wa].
4. delete itab index idx.
5. delete itab from idx1 to idx2.
6. delete itab where logexp.
7. delete adjacent duplicates from itab.
(4).修改数据:
1.modify itab [from wa] [index idx] [assigning |reference intodref] [transporting f1 ... fn].
2. modify table itab [from wa] [assigning |reference into dref] [transporting f1 ... fn].
3. modify itab [from wa] transporting f1 ... fn where cond.
相关文章推荐
- sap中用abap语法将excel数据导入到内表
- ABAP SYNTAX COLLECTION II
- ABAP SYNTAX COLLECTION I
- C#语法小知识(二十二)集合Collection
- 08Java语法回顾collection之set集合
- SAP ABAP SEARCH语法
- SAP ABAP内表OCCURS,WORK AREA等 语法对比!
- SAP ABAP7.40新语法简介第一篇
- SAP ABAP入门学习-基本语法
- SAP ABAP7.40新语法简介第二篇
- Objective-C语法之集合对象的那些事儿(九)
- 继承CollectionBase来扩展自定义的集合类型
- 简单SAP ABAP发送邮件示例代码
- 集合源码学习(一):Collection
- Collection方法之五 对集合中元素进行遍历
- SAP(abap) 常用TCode整理
- ABAP--如何创建和使用sap的号码范围对象
- 黑马程序员 Collection 集合的个人总结
- Collection集合、List集合