2008/10/30
BOM展开和反查函数
2008/10/29
SY-SUBRC ABAP
The result table contains at least one record.
SY-SUBRC = 4:
The result table is empty.
Applies only to SELECT SINGLE FOR UPDATE:
2008/10/24
POSTING_INTERFACE_***
ABAP demo
2008/10/23
POSTING_INTERFACE_CLEARING
POSTING_INTERFACE_DOCUMENT
FIRST_DAY_IN_PERIOD_GET
FI_TERMS_OF_PAYMENT_PROPOSE
2008/10/22
CALCULATE_TAX_FROM_NET_AMOUNT
2008/10/21
FI伝票タイプ(全リスト)
2008/10/16
R/3 ABAP开发学习笔记 zz
中国自学编程网收集整理http://www.zxbc.cn/html/20080317/32526_2.html
R/3 ABAP开发学习笔记
T-Code:ST05,SE38,SE37,SE93,SE73,ABAPhelp
1、ST05是用于在开发ABAP程序时,对应事务码取得的字段是"数据结构"而不是"透明表"的时候,通过ST05的"SQL跟踪"来获得相关"Select"的语句;一般查看"REC"列耗时比较多的"Select"语句;
2、跟踪时如果有涉及到"数量"这类有对数据表进行更新或插入操作的,则直接去查Update和Insert的SQL语句;
3、在跟踪后,直接双击"对象名"列的名称,点选"表格字段"转到"SE11"的表字段表;
4、ABAP程序开头的Tables:"数据表名",只有在屏幕中有用到的表,才需要声明;在程序中用到的表则不需要进行在Tables内声名;
5、抓SAP"文本"字段的数据,要先自定义变量,然后通过SE37的函数"FUNCTION 'ZREAD_TEXT'"取回文本数据;
6、新建的ABAP程序,在测试运行的时候要先进行"激活",才能测试运行;
7、SE93:把ABAP写好的程序指定一个事务码执行;
8、abap引号内的字符''必须要是大写;
9、ABAP select 里面的语句,不能像mssql有那么丰富的函数使用,需要导到内表后再对数据进行操作;
10、'EQ'是单个数据值,'BT'是between区间的意思。
11、在写select inner join 里面,要注意是否需要加上销售组织的条件;on 条件1 and 销售组织条件。
12、SELECTION-SCREEN,里面有两个子项,PARAMETERS和select-options。
PARAMETERS一般是用于必输项的屏幕参数设置,如果这个参数不是必输项的,就要用select-options。在select ...where条件里,用PARAMETERS的条件语法是"数据字段 = 屏幕字段";而select-options的条件语法是"数据字段 in 屏幕字段"。
13、在where判断一个日期型数据是空,不是DEAKT = '',也不是DEAKT is initial,而应该写成DEAKT = '00000000' (8个0)。
14、一对多的inner join,如果取出的数据有重复,前面加上distinct,用法和MSSQL相同。
15、sy-subrc,指上一个语句执行是否成功;执行成功返回0,执行不成功返回非0。用if判断。
16、如果一个语句中,该名称同时可能代表内表或者同名表工作区,则需要在内表名称之后加"[]"指明当前操作的是内表对象。不提倡使用带有表头行的内表,而是应该总是声明结构相同的其他数据对象作为显示工作区进行内表行操作。
come from a PLMM blog , thank you
: http://space.flash8.net/space/?177700/action_viewspace_itemid_284523.html
如何调整ABAP程序的性能(copy)
1、使用where语句
不推荐
Select * from zflight.
Check : zflight-airln = 'LF' and zflight-fligh = 'BW222'.
Endselect.
推荐
Select * from zflight where airln = 'LF' and fligh = '222'.
Endselect.
2、使用聚合函数
不推荐
Maxnu = 0.
Select * from zflight where airln = 'LF' and cntry = 'IN'.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
推荐
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'.
Endselect.
推荐
Select * from zcnfl where cntry like 'IN%' and airln = 'LF'.
Endselect.
4、使用INTO table 代替select endselect
不推荐
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
推荐
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 search.
7、两个内表添加使用批量增加代替逐行
不推荐
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
推荐
Append lines of int_fligh1 to int_fligh2.
8、使用table buffering
Use of buffered tables is recommended to improve the performance considerably. The buffer is bypassed while using the following statementsSelect distinct
Select … for update
Order by, group by, having clause
Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting 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 base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index
To choose an index, the optimizer checks the field names specified in the where clause and then uses 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 use that index.
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.
12、正确地使用inner joinLet us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates. [Page]
Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
Select a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~airln = b~airln.
In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.
13、使用sort by 代替order by
14、避免使用SELECT DISTINCT语句
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.
定义内表与工作区最方便的方法
*定义 名为 ITAB 的内表, 内表结构 参照表 TABLE 。
DATA: ITAB TYPE TABLE OF TABLE.
*定义 名为 WA 的工作区, 其 行结构与 内表 ITAB 相同 。
DATA: WA LIKE LINE OF ITAB.
----------------------------------------------------------------
1.使用occurs 0,定义的不再是对象,而是internal table
2.使用with header line后缀,定义为internal table的同时也定义了一个同名对象,因此可以用以下语句:
LOOP AT STH.
WRITE: / STH.
ENDLOOP.
3.TYPE后面接结构,LIKE后面接对象
4.OBLIGATORY为必输字段
5.DATA SEPARATER . = DATA SEPARATER TYPE C.
6.关于内表的结构描述,它的当前记录数据是放在header line中的,Occurs 是分配数据缓冲区,大小不重要,系统会自动分配。但定义内表不用occurs就需要用with header line,occurs语句记得是为了向下兼容。
7.occurs 指明的�量是有一���的.
1.�你知道可能每次用Select命中或交�的���xxx�,可指明 occurs xxx.
2.如用occurs 0 �明�, buffers 由系�自�分配.
8.SELECT在into时记得一般都要加上table,不然是into一个工作区,即wa,而工作区要写入内表,则需要再append,所以直接定放内表即可,内表和工作区的区别就在于工作区就相当于表头,是有一行,data定义begin of itab时不加occurs就是工作区,加了就是内表,occurs *,后面表示系统初始分配给此内表多少行,每次满时再多分配多少行,我们平常为了节约内存,一般直接用0,with header line是为了定义含表头的内表,平常occurs就直接带表头,而with header line一般是在itab1 like itab occurs 0 with header line时用,这是参照一个内表定义另一内表,如果要带表头,一定要加with header line。
你这样问不是办法,最好不懂时直接接F1,查到SAP的帮助即可. check是检查后面的逻缉是否满足,不满足则在上例是跳出form,不的执行下面的语句。
说实在,初略的看了一下上面的程序,写得太烂了,竟然将usr01或usr03透明表中的字段按条件取到一个表工作区,竟然不加single,象这种不加single的select按理说应该是调不过的,必须在后面再对应一个endselect,而这种select加endselect用每次去读一次透明表,访问数据库的次数太多了,换个好一点程序自己研究吧。
Sorted and Hashed Tables ABAP zz
6. Sorted and Hashed Tables
6.1. Single Read: Sorted vs. hashed tables
数据在SORTED TABLE类型的内表中按照Binary Search方式组织,检索数据的时间维度为(O (log n))。
数据在HASDED TABLE类型内表中按照hash-algorithm组织,检索数据的时间维度为(O (1))。
HASHED TABLE为单条记录的存取进行了优化,它没有索引(index),而SORTED TABLE优化为loop操作的部分顺序数据的存取。
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
" ...
ENDIF.
ENDDO.
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE STAB INTO WA WITH KEY K = N.
IF SY-SUBRC = 0.
" ...
ENDIF.
ENDDO.
注:根据实测,Hashed Table的Read Table操作比Sorted Table + Binary Search大约快1倍。
6.2. Part. seq. access: Hashed vs. sorted
Hashed tables优化为单条记录的存取,数据在内表中没有特定的顺序,内表没有索引(sy-tabix),而且它必须是UNIQUE KEY。
SORTED TABLE内表中数据按照Key字段升序排序。
LOOP AT STAB INTO WA WHERE K = SUBKEY.
" ...
ENDLOOP.
LOOP AT HTAB INTO WA WHERE K = SUBKEY.
" ...
ENDLOOP.
2008/10/14
提高BSEG处理效率
这篇文章我们就来谈谈如何高效地对BSEG进行访问处理。
对於簇表来说,在数据库中没有与之同名的实体物理表相对应,所以虽然其可在ABAP中使用,但还是有一些限制的 :
1. 不能使用Select distinct语法
BSEG中的字段存储在VARDATA中,所以不能使用distinct语句对单个项目去除重复。
2. 不能使用Native SQL
在数据库中没有与之同名的实体物理表相对应,所以不能使用Native SQL 对BSEG操作。
3. 不能使用Order by 语法
BSEG中的字段存储在VARDATA中,所以不能使用Order by语句对单个项目排序。
4. 不能再追加创建索引
BSEG中的字段存储在VARDATA中,所以不能再追加创建索引。
除此之外,对BSEG的访问要使用主键项目,如果没有主键项目虽然语法调试能够通过,但是程序执行起来,耗时长,效率低,而且随着业务量的增加执行时间问题会越发严重,甚至导致程序不能正常执行结束。
那么如果当键值不足时怎么办呢?回答,使用二次索引透明表,具体方法如下描述。
比如和销售凭证有关的业务,根据销售凭证编号和明细编号,选取相关会计凭证明细信息。
SELECT *
FROM BSEG
WHERE VBEL2 = 'XXXXXXXXXX' " 销售凭证编号
AND POSN2 = 'YYYYYY'. " 销售凭证明细编号
在这个例子中,对BSEG的检索条件中因为没有主键项目,所以执行起来,程序很慢。
变通的方法:
1)首先根据销售凭证编号和明细编号,从BSID中检索出未清帐明细行项目。
SELECT BURKS " 公司代码
BELNR " 财务凭证编号
GJAHR " 会计年度
BUZEL " 会计凭证中的行项目
FROM BSID
INTO TABLE TAB_KEY " 存放主键项目的内部表
WHERE VBEL2 = 'XXXXXXXXXX' " 销售凭证编号
AND POSN2 = 'YYYYYY'. " 销售凭证明细编号
2)再根据销售凭证编号和明细编号,从BSAD中检索出已清帐明细行项目。
SELECT BURKS " 公司代码
BELNR " 财务凭证编号
GJAHR " 会计年度
BUZEL " 会计凭证中的行项目
FROM BSAD
APPEND TABLE TAB_KEY " 存放主键项目的内部表
WHERE VBEL2 = 'XXXXXXXXXX' " 销售凭证编号
AND POSN2 = 'YYYYYY'. " 销售凭证明细编号
3)然后再根据上面检索出的主键列表,从BSEG中检索出相应的明细行项目。
SELECT BSCHL "��キ�
KOART "勘定タイプ
UMSKZ "特殊仕�コ
SHKZG "借方/�方
HKONT "�勘定元�
GSBER "事��域
DMBTR "国内通��
WRBTR "�票通��
ZUONR "ソ�トキ�
SGTXT "明�テキス
ZFBDT "期日�算の
ZTERM "支�条件キ
ZLSCH "支�方法
ZLSPR "支�保留キ
HBKID "取引�行の
BVTYP "取引先�行
FROM BSEG
INTO TABLE TAB_BSEG " 存放检索结果的内部表
FOR ALL ENTRIES IN TAB_KEY " 存放主键项目的内部表
WHERE BUKRS = TAB_KEY-BUKRS. " 公司代码
AND GJAHR = TAB_KEY-GJAHR " 财务凭证编号
AND BELNR = TAB_KEY-BELNR " 会计年度
AND BUZEI = TAB_KEY-BUZEI. " 会计凭证中的行项目
4)这么处理之所以能够提高效率,关键还得对透明表BSID和BSAD追加以VBEL2(销售凭证编号)和POSN2(销售凭证明细编号)为键值的索引(对于透明表可追加索引)。
这样一来,1)和2)步骤地操作有索引,3)步骤的操作有全主键项目,检索速度应该有保证。
采购方面的业务、物料方面的业务等都可如法炮制。
最后需要说明一点,不是所有的SAP体统都可以使用这种方法,能否使用取决于R/3系统的设计和配置。所以在试图使用该方法时应充分调查相关透明表与BSEG中的纪录是否相符,别速度提高了,结果处理对象范围减小了或增大了,那就与初衷背道而驰了,效率的提升一定要在确保业务数据正确的基础上再加以考虑。
SAP R/3系统中也有几个专门用来读取BSEG表信息的函数,可适当参考使用,它们是:
READ_BSEG
GET_ALL_BSEG
另外最有效率的方法是改善你的应用和需求,要使需求合理规范,这才能使效率达到最高化。
FOR ALL Entries ZZ
Use of FOR ALL Entries
Use of FOR ALL Entries
http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_ForAllEntries.asp
Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
- Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
- If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
- If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
2008/10/02
ABAP数据库操作(学习SAP程序设计的整理-数据库) [zz 秋之韵]
http://bbs.erp100.com/viewthread.php?tid=18306
2、使用OPen SQL注意的原则:
a、尽可能减少满足条件的数据条目数量。
b、减少数据的传输量,以减少网络流量。
c、减少访问的数据库表量。
d、减少查询难度,可以通过整理选择标准来实现。
e、减少数据库负载。
3、使用Native sql有两个前提:
a、知道使用数据库的类型。
b、了解该数据库的SQL语法。
4、ABAP的数据定义由数据字典创建。
5、提取数据方式:内表,工作区,变量。
6、select语句:
select <result> from <source> into <target>
where <condition> [group by <field>]
[having <cond>][order by <field>].
7、选择单行全部数据:
select single * from spfli into wa_spfli where cityform='singapore' and into
cityto='beijing'.
8、选择单行指定字段:
select single carrid connid from spfli into (wa_carrid,wa_connid) where cityform='singapore'
and into cityto='beijing'.
9、选择相关字段:
select single carrid connid *from spfli into corresponding fields of
wa_spfli where cityform='singapore' and into cityto='beijing'.
10、循环选择:
select *
from spfli into wa_spfli.
write:/ wa_spfli-carrid,wa_spfli-connid.
endselect.
11、选择至内表:
select *
from spfli into table ta_spfli.
读取时:
loop at ta_spfli.
write:/ta_spfli-carrid ta_spfli-connid.
end loop.
12、指定查询条件
比较运算符:= < > <> <= >=
范围限定运算符: [not] between
字符比较运算符:[not] like '_'替代单个字符,'%'任意字符
忽略符号:
select....where func like 'EDIT#_%' escape '#'. escape是指忽略'#'。
检查值列表:
select .....where city in ('Berlin','Rome','London').指定城市'Berlin','Rome','London'。
检查空值:where ...f is [not] null.....
检查选择表:where ...f [not] in seltab.... seltab是选择标准表,是具有特定格式的内表,可以
通过select-options语句添加到程序和报表选择屏幕,并由报表用户填充,在可以在程序中创建(如使用
range语句)
13、动态指定查询条件:
report Z_test.
data:cond(72) type c,
itab like table of cond,
city1(10) value 'BEIJING',
city1(10) value 'SINGAPORE',
itab_spfli like talbe of spfli with header line...
concatenate 'cityfrom = '''city1'''' into cond.
append cond to itab.
concatenate 'cityfto' ='''city2'''' into cond.
append cond to itab.
select * into table itab_spfli from spfli
where (itab).
14、多表结合查询(嵌套,效率较低):
reprot z_test.
data: wa_carrid type spfli-carrid,
wa_connid type spfli-connid,
wa_carrname type scarr-carrname.
select carrid connid
from spfli into (wa_carrid,wa_connid)
where cityform='singapore' and into cityto='beijing'.
select carrname from scarr into wa_carrname where carrid = wa_carrid.
write wa_carrname.
endselect.
endselect.
15、for all entries选项
reprot z_test.
data: begin of wa_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
end of wa_spfli,
begin of wa_scarr,
carrid type scarr-carrid,
carrname type scarr-carrname,
end of wa_scarr,
spfli_tab like table of wa_spfli.
select carrid connid
from spfli
into table spfli_tab
where cityfrom ='Singapore'.
select carrid carrname
from scarr
into wa_scarr
for all entires in spfli_tab
where carrid = spfli_tab-carrid.
...
endselect.
16、使用视图
reprot z_test.
data: wa_carrid type scarrspfli-carrid,
wa_connid type scarrspfli-connid,
wa_carrname type scarrspfli-carrname.
select carrid carrname connid
from scarrspfli
into (wa_carrid,wa_carrname,wa_connid)
where cityfrom = 'Singapore'.
...
endselect.
17、结合查询
内连接:inner join 主表和结合表都满足on的条件
左连接:left join 主选择表的数据,即使在结合表中不存在,也会查询出,以空白显示。
report z_test.
data:wa_carrid type spfli-carrid,
wa_connid type spfli-connid,
wa_carrname type scarr-carrname.
select spfli-carrid scarr-carrname spfli-connid
from spfli
inner join scarr on spfli-carrid =scarr-carrid
into (wa_carrid,wa_carrname,wa_connid)
where spfli-cityfrom = 'Singapore'
..-
endselect.
18、子查询(没有into子句)
select ....
from scarr
into
where exist (select *
from spfli
where carrid = scraa-carrid and cityfrom ='Singapore').
...where city in (select cityform from spfli where carrid = scarr-carrid...)
...where city = (select cityform from spfli where carrid = scarr-carrid...)
...where city > all (select cityform from spfli where carrid = scarr-carrid...)
19、组合结果查询
总计功能
select carrid connid sum(seatsocc)
from sflight
into (wa_carrid,wa_connid,sum_seatsocc)
where spfli-cityfrom ='Singaport'.
分组统计:
select carrid min (price) max(price)
into (carrid,minnum,maxnum)
from sflight
group by carrid
write:/ carrid,minnum,maxnum.
endselect.
指定分组条件:
select carrid min(price) max(price)
into(carrid,minnum,maxnum)
from sflight
group by carrid
having min(minnum)>1000.
指定行的顺序:
select carrid connid max(seatsocc) as max
into (wa_carrid,wa_connid,sum_seatsocc)
from sflight
group by carrid
order by carrid ascending max descending.
20、使用表工作区:
声明:tables dbtab.
tables spfli.
...
select single * from spfli wherer cityfrom ='Singapore'.
write:/ spfli-corrid..
21、动态指定数据库表
dbname='spfli'.
select carrid connid
from (dbname) into (carr_id,conn_id)
where cityfrom = 'Singapore'.
22、指定数据区域
select * from spfli client specified into ....
where mandt between '100' and '103'.
//从表spfli中读取集团100到103中存储的所有数据。
23、设置缓冲机制
select....from dbtab bypassing buffer...取消在数据字典中对该表设定的缓冲。
使用distinct与结合选择,总计选择,is null条件,子查询,以及group by ,order by同时使用时,也
会自动忽略缓冲。
24、限定选择的行数
select ...from dbtab up to n rows....
25、操作性能分析
report z_test.
data:wa_carrid type spfli-carrid,
wa_connid type spfli-connid,
wa_carrname type scarr-carrname.
data:t1 type i,t2 type i,time type i,n type i value 1000.
do n times.
get run time field t1.
select carrid connid from spfli
into (wa_carrid,wa_connid) where cityfrom = 'Singapore'.
select carrname from scarr
into wa_carrname where carrid = wa_carrid.
...
endselect.
endselect.
get run time field t2.
time = t2-t1.
enddo.
write :/ 'Runtime:',time.
26、使用数据库光标(就是游标)
report z_test.
data: cur type cursor,
wa_carrid type spfli-carrid,
wa_connid type spfli-connid,
wa_cityfrom type spfli-cityfrom,
wa_cityto type spfli-cityto.
start-of-selection.
open cursor cur for
select carrid connid cityfrom cityto
from spfli
where carrid= 'AA'
order by carrid.
...
do.
fetch next cursor cur
into (wa_carrid,wa_connid,wa_cityfrom,wa_cityto).
...
if sy-subrc <> 0.
close cursor cur.
exit.
endif.
enddo.
27、更新数据
插入单行数据
insert into dbtab values wa.
insert into dbtab form wa.
插入多行数据
insert dbtab from table itab.
更新单行数据
update dbtab from wa.
更新多行数据
update dbtab set f1=g1...fi=gi [where <conditions>].
update target from table itab.(从内表)
添加或更新单行
modify dbtab from wa.(已存在则更新,不存在则插入)
添加或更新多行
modify dbtab from table itab.(从内表)
删除单行数据
delete from dbtab where <fix_key>.
delete from dbtab from wa.
删除多行数据
delete from dbtab where <conditions>.
delete from [client specified] table itab.(从内表)
删除所有数据
.在通过内表删除多行数据条目的过程中将内表置为空。
.使用where field like '%' 作为where子句中的唯一条件。
28、数据库表的锁定
report z_test.
data:wa_sflight like sflight.
wa_sflight = 'CA'.
...
call function 'ENQUEUE_ENEMOFLHT' //锁定
EXPORTING
mode_sflight = 'X'
carrid = wa_sflight-carrid
connid = wa_sflight-connid
fldate = wa_sflight-fldate
EXCEPTIONS
foreign_lock =1
system_failure =2
OTHERS =3.
if sy-subrc <>0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
update sflight set carrid = wa_sflight-carrid. //数据处理
call function ''DEQUEUE_EDEMOFLHT. //解除锁定
29、程序中的授权检查
report z_test.
parameters p_carrid type sflight-carrid.
authority-check object 's_carrid'
id 'CRRID' field p_carrid
id 'ACTVT' field '03'.
if sy-subrc = 4.
message e045(sabapdocu) with p_carrid.
elseif sy-subrc <>0.
message a888(sabapdocu) with 'Error!'.
endif.
30、应用服务器文件操作
report z_test.
parameters file(30) type c default '\tmp\myfile'.
data: wa_sflight type sflight,
sflight_tab_1 like table of wa_sflight,
sflight_tab_2 like table of wa_sflight.
open dataset file for output in binary mode.
select * from sflight into wa_sflight.
transfer wa_sflight to file.
append wa_sflight to sflight_tab_1.
endselect.
close dataset file.
open dataset file for input in binary mode.
do.
read dataset file into wa_sflight.
if sy-subrc <> 0.
exit.
endif.
append wa_sflight to sflight_tab_2.
enddo.
close dataset file.
if sfilght_tab_1 = sflight_tab_2.
message i888(sabapdocu) with 'ok'.
endif.
31、展示服务器文件操作
report z_test.
parameters: fname type rlgra-filename default 'c:\temp\myfile.dat',
ftype type rlgra-filetype default 'BIN',
data:
sflight_tab_1 like table of sflight,
sflight_tab_2 like table of sflight,
tab_line like line of sflight_tab_1,
leng type i,
lins type i,
size type i.
select * from sflight into table sflight_tab_1.
describe field tab_line lenght leng.
describe table sflight_tab_1 lines lins.
size = leng * lins.
call function 'WS_DOWNLOAD'
exporting
filename=fname
filetype=ftype
bin_filesize=size
tables
data_tab=sflight_tab1
exceptions
...
if sy-subrc <>0
message e888(sabapdocu) with 'sy-subrc =' sy-subrc.
endif.
call function 'WS_UPLOAD'
exporting
filename =fname
filetype=ftype
tables
data_tab=sflight_tab_2
exceptions
...
if sy-subrc <> 0
message e888(sabapdocu) with 'sy-subrc =' sy-subrc.
endif.