qmhiro - by - 20 五月, 2008 00:32

Collect语句镶嵌在select---endselect之中使用,在报表开发中经常用到,作用是根据tableunique key,把表中其他的字段进行自动的累加,一般用在对某些数据进行总数统计的时候.

举例如下:

data:begin of mytable,

keyfield like XXX,

fliedl1 like XXX,

field2 like XXX,

end of mytable.

Data: mytable_col like hashed table of mytable

With unique key keyfield with headline.

select keyfield fliedl1 field2 from table_system

into (mytable- keyfield, mytable-fliedl1, mytable- field2).

Collect mytable into mytable_col.

Endselect.

这个例子的作用是以keyfield为主键,fliedl1fliedl2的数据进行累加,计算属于每个keyfieldfliedl1fliedl1的总和.

Collect使用有两个条件:

<!--[if !supportLists]-->1. <!--[endif]-->累加时送入的表必须时hashed table或者 sorted table,即必须拥有唯一的key.

<!--[if !supportLists]-->2. <!--[endif]-->除了key之外的其他属性必须时数字型的,才能进行累加计算.

当然 mytable mytable_col.的表的类型必须完全一致.

一般的报表在生成时都需要对大量的数据进行计算,这时使用collect语句的好处就是不用在把数据取到本地后再loop进行累加,降低报表对系统的压力.

come form: http://blog.csdn.net/nodreamer/archive/2007/02/25/1514272.aspx

从内部表中抽取唯一记录的方法测试

三种方法简单介绍:

方法一: 内部表循环赋值,使用COLLECT语句追加记录

方法二: 内部表循环赋值,使用AT NEW和APPEND语句追加记录

方法三: 整个内部表赋值,使用DELETE ADJACENT DUPLICATES语句删除重复记录.

http://abaper.blogbus.com/logs/2679647.html



qmhiro - by - 19 五月, 2008 10:37

COME FORM: http://i.cn.yahoo.com/02900427056/blog/p_5/

关键字: ABAP面试

问题一:锁对象(Lock Object)和 FM(Function Module),激活Lock Object时,

案 产生的 FM 的名字是什么?

答案:首先要在 ABAP 字典中创建锁对象,然后才能在 ABAP 程序中设锁。

创建锁对象时,系统会自动生成两个 FM 来进行锁管理。

用于设锁的 FM 为: ENQUEUE_<锁对象名>。它用于在锁表(Lock Table)

中生成一个锁项(Lock Entry)。若设锁不成功的话,就会在 Return 中反映出来。

用于释放锁的 FM 为:DEQUEUE_<锁对象名>。它用于从锁表中删除一个锁项。

在 ABAP 程序中,只需使用 "CALL FUNCITION ..." 语句就可以调用它们。

这两个锁 FM 是在 SAP 系统的一个特殊工作进程中执行的,专门进行锁管理。

它运行在一个单独的服务器上,而该服务器专门用于维护整个 SAP 系统的主锁表

(Central Lock Table)。

有两种锁类型:

1. 共享锁——只读锁,一个用户正在读数据时,阻止其他用户更改该数据。

2. 独占锁——可写锁,一个用户正在修改数据时,阻止其他用户更改该数据。

问题二:更新方面的 FM

更新 FM 分为 V1 和 V2,那么首先会执行哪一种更新类型呢?每种类型又是以

哪种模式(异步、同步或本地)执行的呢?

答案:V1 更新类型比 V2 更新类型的优先级高,因此,V1 比 V2 行执行。

V1 的执行模式可以为异步、同步或本地;V2 只能为异步执行。

问题三:ABAP 内存(ABAP Memory)交换

在使用 ABAP 内存的程序间进行数据交换时用到的两个语句是什么?

答案:EXPORT to MEMORY ID 用于将数据复制到 ABAP 内存,IMPORT from

MEMORY ID 用于将数据从 ABAP 内存复制到程序中。

在 ABAP 内存间进行交换的数据必须在两个程序中都进行声明,并包含同样的数据声明。

问题四:授权对象(Authorization Objects)

什么是授权对象?在 ABAP 程序中使用哪条语句进行授权检查?

答案:授权对象由一组字段组成,这些字段中的值将被用于进行授权检查。

ABAP 程序中使用 AUTHORITY-CHECK 语句根据授权对象进行授权检查。

在 AUTHORITY-CHECK 语句中,必须指明授权对象的所有字段,但有一个例外,

可以用 DUMMY 关键字来绕过某个字段的检查。

一个授权对象中最多可以定义 10 个字段。

问题五:修改(Modifications)

在 SAP 系统中是怎样定义"修改"的?它们对更新(upgrade)有怎样的影响?

答案:修改是指用户对 SAP 发布的库对象(Repository Object)进行的更改。

必须在更新期间对修改进行评审(Review),来决定是否应该使用新的 SAP 对象,

以及将来使用时是否需要进一步修改该对象。

问题六:修改助手(Modification Assistant)

什么是修改助手?

答案:修改助手是 4.5 版中引入的一个工具,用于简化更新过程。可以通过

ABAP 编辑器触发修改助手,它会记录对系统进行的修改。修改助手支持通过

ABAP 编辑器、Screen Painter、Menu Painter、文本元素维护、Function Builder 和

ABAP 字典进行的修改。

问题七:功能模块出口(Function Module Exit)

实现功能模块出口时 SAP 应用程序中应使用哪条语句?

答案:某些 SAP 应用程序中存在功能模块出口,它使用户能够向 SAP

程序中添加一些功能。通过搜索 "CALL CUSTOMER" 可以发现是否存在功能模块出口。

问题八:事务变式(Transaction Variants)

什么是事务变式?为何要使用它?

答案:事务变式是一组屏幕变式,用于预定义屏幕行为和默认值。通过使用变式功能,

可以将用户不需要的字段、子屏幕及全屏幕从用户视图中取消。可以给任何输入字

段设置默认值,字段也可以不用带 "Ready for Input" 状态。

只能为对话和报表事务创建事务变式;变式中只能包含普通屏幕、子屏幕及对话屏幕。

开发人员可以使用 GuiXT 脚本语言通过事务变式维护对屏幕进行修改。修改屏幕布局的方式有:插入按钮、值帮助(Value Helps)、移动对象、插入屏幕等等。

问题九:更改 SAP (Changing SAP)

请列出用户修改 SAP 标准功能的不同方式。

答案:SAP Standard 可以通过 Personalization、Customizing、Modifications、Enhancements 及自定义 ABAP 程序进行更改。这些方式的示例如下:

Personalization——Personalization 技术包含创建变式、设置/获取参数及活动组(Activity Groups)。

Customizing ——是最常用的使用 SAP 工具(如 R/3 Reference Model and Implementation Guide)更改 SAP Standard 的方式。可以认为 Customizing 是实施 R/3 所必需的,通常由 Functional Team 来执行。

Enhancements——常由开发 Team 执行,包含的活动有:字典增强、Funciton Module Exits、菜单和屏幕出口及 Business Add-ins (BADI)。

自定义 ABAP 程序——可以与 SAP 对象或自定义开发的对象一起工作。

Modifications——不建议对 SAP 对象使用 Modifications。使用 SSCR (SAP Software Change Registration)注册所有对 SAP 对象的手动修改。

问题十:添加字段

向 SAP 表中添加字段的方法是哪两种?

答案:这两种方法是:Append 结构(Append Structure)和自定义 Include(Customizing Include)。Append 结构是在向表尾添加字段时创建的,自定义 Include 由 SAP 开发人员指定,以使用户可以创建新字段。

问题十一:什么是 BADI?

答案:BADI 是 Business Add-in 的缩写。它是一种新的功能增强概念,使用 ABAP 对象技术。这是一种使用面向对象的方法来进行 SAP 增强。实现 BADI 要用到类、接口及方法等面向对象的概念。

要对一个 SAP 应用程序进行增强,必须首先定义 BADI。为 BADI 创建一个接口,接着创建一个适配器类(Adapter Class)来实现这个接口, 然后创建这个适配器类的实例。



qmhiro - by - 18 五月, 2008 07:53

SAP ABAP小结
=========================================================== 作者: qiujun(http://qiujun.itpub.net)
出处:http://qiujun.itpub.net/post/24006/298614
---------------------------------------------------------------

1 使用binary search之前,需要sort,并且sort by ascending(系统默认的顺序也是ascending)。而且read table with key的顺序同sort的顺序相同,否则出错,常会找不到纪录。Delete adjacent duplicates之前一定要sort。

2 关于内部表示和外部表示:调用BAPI和Update DB的时候,一定要使用内部形式(物料号有前导零的时候被认为是内部形式;单位一般也有内部形式外部形式之分)。在se11浏览数据的时候,显示数据的画面是使用内部形式,当detail overview的时候,则是外部形式。

3 使用at new, at first, at last, at end of的时候要注意:loop的时候不能加条件;at和endat之间不能使用loop into的working area。手动实现at new, at end of的时候,需要注意,容易出错,尤其是在at end of的时候。

4 一般情况下,更新数据库需要commit,但debug会自动commit,程序结束也会自动commit。

5 对于选择界面上的select-options,clear s_lifnr[]是指clear body part,clear s_lifnr是指clear header part。一般不直接编辑界面上的select-options。

---------------------------------------------------------------
come from : http://blog.csdn.net/CompassButton/archive/2007/03/08/1524491.aspx
---------------------------------------------------------------
1、AT New事件触发说明
如 AT New f.
f 是内表的一个字段,当f字段或者f字段左边的字段内容发生变化是该事件后面的语句都会执行。
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.

DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.

...

LOOP AT COMPANIES INTO WA_COMPANIES.
AT NEW PRODUCT.
NEW-PAGE.
WRITE / WA_COMPANIES-NAME WA_COMPANIES-PRODUCT.
ENDAT.
WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.
ENDAT.
ENDLOOP.
这个样例当name变化时,AT new事件也会执行。

2、AT New 发生时工作区的字段的值

All character type fields (on the right) are filled with "*" after the current control level key.

All other fields (on the right) are set to their initial values after the current control level key.

AT NEW 和AT END OF的用法
http://www.sapclub.org/blog/nyf425/archive/2008/01/07/67689.html
-------------------------------------------------------------------
使用 AT NEW f. 和 .AT END OF f 时需要注意:

1,f 必须是内表的第一个字段。

2,内表中f 之后的字段的值都会变成 *。

例:

REPORT Z_TEST.

DATA: BEGIN OF TH_LIFNR,
LIFNR TYPE LFA1-LIFNR,
ITEM TYPE C,
END OF TH_LIFNR.

DATA: TD_LIFNR LIKE TABLE OF TH_LIFNR.

SELECT LIFNR FROM EKKO
INTO TABLE TD_LIFNR
WHERE EBELN > 4500006374
AND EBELN < 4500006390.

SORT TD_LIFNR ASCENDING BY LIFNR.

LOOP AT TD_LIFNR INTO TH_LIFNR.
AT NEW LIFNR.
WRITE:/10 TH_LIFNR-LIFNR.
WRITE:/ 'The next is new lifnr.'.
ENDAT.
ENDLOOP.


----------------------------------------------------------------
http://www.chinavalue.net/Article/Archive/2007/1/18/54443_2.html

在写abap 的过程中,可能需要统计,求和等那么如何实现呢?其实在loop ... endloop 中间,有个AT <LEVEL>,<…>,ENDAT循环. 其中的<LEVEL>包括: FRIST, LAST, NEW , END OF.这些可以用来进行内表中按某个字段进行分组统计.
FIRST 内 表的第一行
LAST 内 表的最后一 行
NEW <f> 行组 的开头,与 字段 <f> 和 <f> 剩余字段中 的内容相同
END Of <f> 行组 的结尾,与 字段 <f> 和 <f> 剩余字段中 的内容相同

AT - ENDAT 块中的语句 块使用这些 行条件代表 预定义的控 制结构。用 户可以使用 它们处理内 表中的控制 断点,而不 必使用 编程分支和循环 中所述的控 制语句自己 编程。
在 AT - ENDAT 语句块中, 工作区域没 有用当前表 格行进行填 充。初始化 所有不是标 准关键字部 件的字段( 参见
标识表格行 )。对于行 条件 FIRST 和 LAST, 系统用星号 (*) 改写所有标 准关键字段 。对于行条 件 NEW <f> 和 END OF <f>,系 统用星号 (*) 改写所有出 现在工作区 域中指定字 段 <f> 右边的标准 关键字段。 用户可根据 自己的需求 在 AT - ENDAT 语句块中填 充工作区域 。

DATA: BEGIN OF LINE,
COL1 TYPE C,
COL2 TYPE I,
COL3 TYPE I,
END OF LINE.
DATA ITAB LIKE LINE OCCURS 10.
LINE-COL1 = A.
DO 3 TIMES.
LINE-COL2 = SY-INDEX.
LINE-COL3 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
LINE-COL1 = B.
DO 3 TIMES.
LINE-COL2 = 2 * SY-INDEX.
LINE-COL3 = ( 2 * SY-INDEX ) ** 2.
APPEND LINE TO ITAB.
ENDDO.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
AT END OF COL1.
SUM."按Col1 求和.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
SKIP.
ENDAT.

AT LAST.
SUM."总求和.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
ENDAT.
ENDLOOP.
其输出为:
A 1 1
A 2 4
A 3 9
________________________________
A 6 14

B 2 4
B 4 16
B 6 36
________________________________
B 12 56

________________________________
* 18 70




qmhiro - by - 17 五月, 2008 23:35

学习一下,查漏补缺
别人的面试记实-转摘(首先声明是转摘,如侵权的话,可联系我!)
1.
介绍一下自己?
说了毕业来的项目情况,大约3-5分钟
哪方面比较熟?
idoc没做过,其他差不多都做过了
alv里如果有多种货币,怎么保证各种货币和金额正确显示?
只做过设置两列,一列数字一列金额单位。如果要汇率转换的话有相关函数(不知道是不是他要的答案)
怎么设置cell的颜色?
没做过,只做过设置行的颜色,并介绍了一下方法。设置cell颜色的程序记在机器里了(还是在100easy看到的)
怎么控制alv列的宽度,包括列名的宽度?
fieldcat里面有一个output length,还有seltext有短中长3个长度可以设置
如果alv有很多列,怎么固定住alv的某几个列让其不随滚动条移动?
没做过。说了table control可以设置key来做到。
r3 470以后,bdc有一种p模式,做过么?
不好意思,没做过。
屏幕编程的时候,怎么让某个字段自动显示一个值?
这个问题一开始没听明白,后来才知道他的意思。原来是设置parameter id。可惜自己还回答成了memory id。
如果多语言的report,怎么让其在多种语言环境下面自动显示不同的语言?
文本的翻译功能可以做到。用text也可以。
smartform里面,table和template有什么区别?
table没用过,随便侃了几句。
smartform的main窗口和普通窗口什么区别?
main窗口可以跨页。
smartform的xx控件用过么?
没有。(控件的名字现在想不起来了,抱歉)
接下来是业务相关的问题。
哪个模块比较熟?
pp mm sd。
建立工单的时候展开bom有什么用?
指导生产。工人可能不知道生产一个成品需要哪些组件。展开以后就很清楚。
mrp/mps的一个问题,是和controller有关的问题。
没听懂,赶快承认pp模块只对主数据比较了解。
sd里面的document flow,so和do怎么对应?是一对多还是?
可以分开交货,也可以合并交货。具体情况可以看vbfa表。
do的表?
likp lips
bom的表?
stko,stpo,还有mast。
最后一个问题,物料主数据的accounting view,数据在哪个表?
mvke。(马上被告知答错了,然后告饶,说不知道,需要查一下。)

期间还问了过去项目上的一个sapscript问题,反正自己做过,就介绍了一下。


后来自我总结了一下,其实很多问题自己不知道,可以介绍一下大概怎么去找解决方法。这次的面试时间大约是20-30min,问的问题也是不太难的那种。

2.
英文自我介绍一下
......
不到一年就升leader?
企业管理基础好,abap不仅仅是编程。
哪个模块比较熟悉
fi co mm sd
sd 的主要流程以及相关的数据库表
......表名想不起来了,告饶两次
sd的业务数据怎么传递到总帐的
建发票会产生会计凭证。借应收客户,贷主营收入。
解释一下统驭科目(英文,告饶后说了中文)?
特殊的总帐科目,用来联系总帐和分类帐
系统中常见的统驭科目类型
客户 供应商 资产 物料
系统中常见的移动类型
101 102 301 302 561 (呵呵,不敢继续说了)
清账的分录是什么?
清账没分录。付款的分录是借银行存款贷应收客户。
没有清账的会计凭证在哪个表里?
未清客户bsid,已清客户bsad。
现在客户要做一个报表,看某客户某日期欠款额度,如何取数?
(有点不得要领)取bsid该客户该日期前的数据,(经提示)补充bsad该客户该日期之后的数据。
abap 编程你主要擅长哪方面?
对员工做过5次abap基础培训,各种技术都有了解。
idoc能讲讲么?
(汗!)没做过,看过资料。源系统业务生成文本文件,目标系统文本文件驱动业务。格式双方协商。
创建财务凭证用哪个bapi?
不知道,可以用bapi这个事务去查。
如果我客户有很多凭证放在excel里,怎么把数据导入系统?
bdc catt lsmw,这个没用过。另外就是您说的bapi。
excel中数据的上传下载用什么方式?有函数么?
文件在服务器上用dataset,在客户端用函数,下载用ws_excel,上传没有特定函数(坚持,失败~)
bdc的时候如何确定表控件里各行的数据?
有个括号可以输入行数。
如果bdc出错了,如何处理?
可以设置“出错时转前台运行”。有机会输入修正数据。
如果不想马上转前台呢?
不会了,请教。原来是用 insert_group 插入一个session。
报表出现了性能问题,处理步骤是什么?
se30定位错误。有一个运行分析图示,找到瓶颈:是数据库操作还是代码运行的问题。
如果是代码运行的时间较长呢?
把标准内表类型改成sorted或者hash的内表。
sorted的内表read的时候有什么特别的么?
没答上,原来是with table key。
sorted的内表还能插入和删除么?
语法是允许的,但是规范里不推荐。由于会引起性能问题,因索引重排。
那么数据库访问时间较长呢?
规范中不允许loop嵌套select循环,一般用for all entries in 来替代,但是有时候会有distinct的bug。
还要注意一个什么bug?
这个竟然没马上答出来,看来是紧张了。要先检查内表是否为空。
还有其他办法解决数据库问题么?
自定义表截取特定数据。前一个项目几个co报表很慢,因为提成本只针对当月数据,我们就预先抓取当月数据放入自定义表zcovp中,性能提升很明显。
smartforms做过么?
做过,是一些单据打印的程序。国内项目上script用的比较多。
script的输出类型都知道是么?如标准程序数据的打印输出?
没做过,f.01里有个参数输入script 的form名。这个form可以开发,用rep加报表节点编号的方式取数。有人这样做过资产负债表。(不知道是不是答非所问)
alv你们用哪种方式做?
grid和list按用户要求都用过。OO的用法没写过。我们尽量把程序写得简单。
如果一个alv输出的程序要运行2小时或更长时间,怎么处理?
没敢说转后台运行。竟然忘了问答案。
如果运行list输出的程序,不想输出到屏幕上,直接打印怎么做?
用set_print_parameter这个函数就行了(答错了,还狡辩,确实看人作过这样的功能),原来是给new-page事件加尾巴。
如果不想直接打印,要发到spool里呢?
前台打印对话框是有一个立即打印checkbox的,估计new-page的尾巴里有这么一个参数,置空(不会可以蒙)。
屏幕编程作过么?
作过一个rf终端的屏幕程序,做采购入库,预留出库,库间转移,销售出库的各种操作,后面用bapi。
pbo和pai能否解释一下?
pbo是屏幕显示前的操作,pai是用户触发function-code后的操作。
field module有什么作用?
我恨,没答上。不这么用error时就都变灰了。提示了半天,我们都很急。
还有一个比较常用的事件是什么?
f4吧,on value-request,呵呵,这个蒙对咯!

销售凭证流数据在哪个表?

对不起,不知道。

bom的两个表呢?

对不起,不知道。

历时一个小时,感觉发挥不是很好,75分吧,不知道要不要75分的?

come from: http://www.cnblogs.com/omygod/archive/2008/01/27/1055220.html



qmhiro - by - 17 五月, 2008 22:11

SmartForms总结

步骤一:Create Form

Tcode: smartforms

2在Form后面输入名称,然后单击“创建”;

3输入描述;

4设计界面;

5保存并激活;

6执行,可以自到系统会自动产生一个Function module,如:/1BCDWB/SF00000016

7执行,输入必要的参数;

8执行,输入OutputDevice

9打印预览,可以看到设计的界面。

步骤二:建立程序

代码如下:

DATA W_SFLIGHT like sflight occurs 0 with header line.

*Name of Function Module

DATA: fm_name TYPE rs38l_fnam.

select * from sflight into table w_sflight.

*SmartForms生成的功能模块名称*

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZTESTSMART_AJAX2' "Smartforms name

* VARIANT = ' '

* DIRECT_CALL = ' '

IMPORTING

FM_NAME = fm_name

* EXCEPTIONS

* NO_FORM = 1

* NO_FUNCTION_MODULE = 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.

*调用SmartForms生成的功能模块,将触发打印功能*

CALL FUNCTION fm_name

EXPORTING

* ARCHIVE_INDEX =

* ARCHIVE_INDEX_TAB =

* ARCHIVE_PARAMETERS =

* CONTROL_PARAMETERS =

* MAIL_APPL_OBJ =

* MAIL_RECIPIENT =

* MAIL_SENDER =

* OUTPUT_OPTIONS =

* USER_SETTINGS = 'X'

zcompany = '某某公司' “自定义的接口

* IMPORTING

* DOCUMENT_OUTPUT_INFO =

* JOB_OUTPUT_INFO =

* JOB_OUTPUT_OPTIONS =

tables

i_sflight = W_SFLIGHT “自定义的接口(内表)

* EXCEPTIONS

* FORMATTING_ERROR = 1

* INTERNAL_ERROR = 2

* SEND_ERROR = 3

* USER_CANCELED = 4

* OTHERS = 5

.

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

说明:

<!--[if !supportLists]-->1)<!--[endif]-->屏幕左测显示所有对象,双击它可以显示属性;

<!--[if !supportLists]-->2)<!--[endif]-->只有主窗体中数据才能在多个页面中连续输出;

<!--[if !supportLists]-->3)<!--[endif]-->表格:

静态表格: Template节点

动态表格: TableLoopComplex section节点,最好要放在主窗口中,可以输出多页。

<!--[if !supportLists]-->4)<!--[endif]-->节点处理流程:从顶端到底端

come from:http://blog.csdn.net/ft1612796/archive/2007/06/15/1653746.aspx

more Smart Form templates available from SAP SAP Labs also has some more Smart Form templates for around 20 forms. They're preconfigured & have versions or translations in a few languages besides English. MOstly they cover SD and MM modules.
You have to have access to the Service Marketplace though.
SAP SmartForms lib:
http://help.sap.com/saphelp_46c/helpdata/en/a9/de6838abce021ae10000009b38f842/frameset.htm
Alternatively, go to help.sap.com, go to Basis components, then go to Basis Services/Communications Interface.
This has loads of information on SMARTFORMS



qmhiro - by - 12 五月, 2008 14:44

DATA: BEGIN OF wa_tab1,
fld1(4) VALUE ’FLD1’,
fld2(4) VALUE ’FLD2’,
fld3(4) VALUE ’FLD3’,
fld4(4) VALUE ’FLD4’,
fld5(4) VALUE ’FLD5’,
END OF wa_tab1,
BEGIN OF wa_tab2,
fld1(4),
fld2(4),
fld3(4),
fld4(4),
END OF wa_tab2.

************* Move Corresponding *************
MOVE-CORRESPONDING wa_tab1 to wa_tab2.
************ End Move Corresponding

******************************Move********************
MOVE: wa_tab1-fld1 to wa_tab2-fld1,
wa_tab1-fld2 to wa_tab2-fld2,
wa_tab1-fld3 to wa_tab2-fld3,
wa_tab1-fld4 to wa_tab2-fld4.
****************** End Move ******************

In above example, the result of MOVE and MOVE-CORRESPONDING is same. MOVE-CORRESPONDING is look like easy to coding but

MOVE statement have performance better than MOVE-CORRESPONDING because when you apply MOVE-CORRESPONDING CPU usage of system

will be increased.


Question:
Among "Move" and "Move Corresponding", which is efficient one?
Answer :

move statement is more effienet than move-corresponding.
In case of dialog programming move/movecorresponding stsmt are used to put internal table workarea data into screen fields.

data: begin of itab occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
ort01 like lfa1-ort01,
end of itab. (here lfa1 is DBtable name)
:
* in case of movecorresponding

Move-Corresponding itab to lfa1.
(here:lfa1 is screen fields name).

* in case of MOVE stmt.

Move itab-lifnr to lfa1-lifnr.
Move itab-name1 to lfa1-name1.
Move itab-ort01 to lfa1-ort01.

Movecorresponding :
If DBtable having 1000 fields and you are using movecorresponding, then system has to check all the field in table to move.



qmhiro - by - 08 四月, 2008 23:24

ABAP 中的表类型及作用(转)

Transparent tables

A transparent table in the dictionary has a one-to-one relationship with a table in the database. Its structure in R/3 Data Dictionary corresponds to a single database table. For each transparent table definition in the dictionary, there is one associated table in the database. The database table has the same name, the same number of fields, and the fields have the same names as the R/3 table definition. When looking at the definition of an R/3 transparent table, it might seem like you are looking at the database table itself.

Transparent tables are much more common than pooled or cluster tables. They are used to hold application data. Application data is the master data or transaction data used by an application. An example of master data is the table of vendors (called vendor master data), or the table of customers (called customer master data). An example of transaction data is the orders placed by the customers, or the orders sent to the vendors.

Transparent tables are probably the only type of table you will ever create. Pooled and cluster tables are not usually used to hold application data but instead hold system data, such as system configuration information, or historical and statistical data.

Both pooled and cluster tables have many-to-one relationships with database tables. Both can appear as many tables in R/3, but they are stored as a single table in the database. The database table has a different name, different number of fields, and different field names than the R/3 table. The difference between the two types lies in the characteristics of the data they hold.

Table Pool and Pooled Tables

A pooled table in R/3 has a many-to-one relationship with a table in the database. For one table in the database, there are many tables in the R/3 Data Dictionary. The table in the database has a different name than the tables in the DDIC, it has a different number of fields, and the fields have different names as well. Pooled tables are an SAP proprietary construct.

When you look at a pooled table in R/3, you see a description of a table. However, in the database, it is stored along with other pooled tables in a single table called a table pool. A table pool is a database table with a special structure that enables the data of many R/3 tables to be stored within it(in database, it is only one table). It can only hold pooled tables.

R/3 uses table pools to hold a large number (tens to thousands) of very small tables (about 10 to 100 rows each). Table pools reduce the amount of database resources needed when many small tables have to be open at the same time. SAP uses them for system data. You might create a table pool if you need to create hundreds of small tables that each hold only a few rows of data. To implement these small tables as pooled tables, you first create the definition of a table pool in R/3 to hold them all. When activated, an associated single table (the table pool) will be created in the database. You can then define pooled tables within R/3 and assign them all to your table pool (see Figure 3.2).

Pooled tables are primarily used by SAP to hold customizing data.

When a corporation installs any large system, the system is usually customized in some way to meet the unique needs of the corporation. In R/3, such customization is done via customizing tables. Customizing tables contain codes, field validations, number ranges, and parameters that change the way the R/3 applications behave.

Some examples of data contained in customizing tables are country codes, region (state or province) codes, reconciliation account numbers, exchange rates, depreciation methods, and pricing conditions. Even screen flows, field validations, and individual field attributes are sometimes table-driven via settings in customizing tables.

During the initial implementation of the system the data in the customizing tables is set up by a functional analyst. He or she will usually have experience relating to the business area being implemented and extensive training in the configuration of an R/3 system.

Table cluster and cluster tables

A cluster table is similar to a pooled table. It has a many-to-one relationship with a table in the database. Many cluster tables are stored in a single table in the database called a table cluster.

A table cluster is similar to a table pool. It holds many tables within it. The tables it holds are all cluster tables.

Like pooled tables, cluster tables are another proprietary SAP construct. They are used to hold data from a few (approximately 2 to 10) very large tables. They would be used when these tables have a part of their primary keys in common, and if the data in these tables are all accessed simultaneously. 这些表一起存储在于他们有共同的主键。

Table clusters contain fewer tables than table pools and, unlike table pools, the primary key of each table within the table cluster begins with the same field or fields. Rows from the cluster tables are combined into a single row in the table cluster. The rows are combined based on the part of the primary key they have in common. Thus, when a row is read from any one of the tables in the cluster, all related rows in all cluster tables are also retrieved, but only a single I/O is needed.

A cluster is advantageous in the case where data is accessed from multiple tables simultaneously and those tables have at least one of their primary key fields in common. Cluster tables reduce the number of database reads and thereby improve performance.

As another example, assume the data from order header and order item tables is always needed at the same time and both have a primary key that begins with the order number. Both the header and items could be stored in a single cluster table because the first field of their primary keys is the same. When implemented as a cluster, if a header row is read, all item rows for it are also read because they are all stored in a single row in the table cluster. If a single item is read, the header and all items will also be read because they are stored in a single row.

Restrictions on Pooled and Cluster Tables

Pooled and cluster tables are usually used only by SAP and not used by customers, probably because of the proprietary format of these tables within the database and because of technical restrictions placed upon their use within ABAP/4 programs. On a pooled or cluster table:

Ø Secondary indexes cannot be created.

Ø You cannot use the ABAP/4 constructs select distinct or group by.

Ø You cannot use native SQL.

Ø You cannot specify field names after the order by clause.

Ø Order by primary key is the only permitted variation.

CAUTION

The use of pooled and cluster tables can prevent your company from using third-party reporting tools to their fullest extent if they directly read data-base tables because pooled and cluster tables have an SAP proprietary for-mat. If your company wants to use such third-party tools, you may want to seek alternatives before creating pooled or cluster tables.

Because of these restrictions on pooled and cluster tables and because of their limited usefulness, this book concentrates on the creation and use of transparent tables. The creation of pooled and cluster tables is not covered.

come from :http://www.cnblogs.com/omygod/archive/2007/12/28/1018961.html



qmhiro - by - 13 三月, 2008 21:44

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%’.
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 statements
Select 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.

11、正确地使用MOVE语句
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.
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用每次去读一次透明表,访问数据库的次数太多了,换个好一点程序自己研究吧。

9.透明表可以连接查询,簇表只能通过简单的select查询,如bseg.
内表相当于数组,可以通过loop,read进行查询。
内表中的记录都是放在工作区中进行编辑和察看的。结构同内表。程序中声明内表时,表名为 ITAB_XXXX,后缀尽可能为关联DBTab或内表用途



qmhiro - by - 13 三月, 2008 21:17

ABAP数据库操作(学习SAP程序设计的整理-数据库)

1、abap语言使用的数据库语言:open sql ,Native sql(特定数据库自身sql)
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 'tmpmyfile'.
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:tempmyfile.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.

thank you

come from :http://bbs.erp100.com/archiver/tid-18306.html



qmhiro - by - 10 三月, 2008 10:39

在学习这门语言之前,让我们先看看SAP的二次开发具有哪些工具和技术 ,这里给大家一个overview:
1、REPORT(报表) :报表程序的主要作用是从数据库中抓取数据通过整理陈列出来,给企业高层或具有相关需求的人员查看。如无特殊需求,此类程序一般不需客制screen、menu、title。
A、ABAP LIST(最简单的一种报表程序,显示在屏幕上的数据及格式都通过ABAP中的WRITE语句实现,开发工具:SE38)
B、ALV REPORT (属于报表的一种高级形式,显示出来的报表整洁美观,具有很大的交互功能,屏幕上的数据及格式主要通过系统的FUNCTION实现,开发工具:SE38)
C、SAPSCRIPT(属于商务报表,主要应用于商业用途或对外的报表设计,开发工具:SE38、SE71)
D、SMARTFORM (属于商务报表,主要应用于商业用途或对外的报表设计,是SAPSCRIPT的升级版,包含了SAPSCRIPT的绝大多数功能,但开发起来比SAPSCRIPT更方便,快捷。开发工具:SE38、SMARTFORMS)
E、QUERY (适用于简单的查询报表开发,无需具有ABAP编程知识,但又提供了写ABAP代码的功能,对于一些简单的、无太多计算逻辑或判断逻辑的报表,推荐用其开发,开发工具:SQ01、SQ02、SQ03)
F、REPORT PAINTER(此类报表主要应用于FICO模块,比较少用,但功能也非常强大。)

2、DIALOG(事务程序):
事务程序属于对话型程序,提供对话框界面,方便操作人员与系统进行数据交互,这种程序会更新数据库。企业的讯息如果需要录入或更新到系统就需要此类程序的协助。它包含客制的screen、menu、title。

3、REPORT与DIALOG技术合并产生的程序:
这类程序往往不太好给其归类,程序的类型属于“可直接执行程序”,但往往因为一些特殊的需求,需要将DIALOG程序的一些技术合并在报表中来,它同样具有客制的screen、 menu、 title, 可以更新数据库。

4、其他类型:
A、FUNCTION GROUP(函数组,可以包含大量function module,同其他语言一样,针对一些具有共同运算或判断规则的程序,可以将其写成一个可以共用的代码段,这样就大大避免的冗余代码的存在)
B、TYPE POOLS (类型池,包含许多系统自定义的数据类型及类型组,如ALV要用到的数据类型都包含在SLIS这个类型池里)
C、MODULE POOLS(模块池,主要包含以“MODULE”关键字引导的代码段)
D、SUBROUTING POOLS(子程序池,主要包含以“form”关键字引导的代码段)
E、INTERFACE POOLS (接口池,主要应用于OO程序,定义了许多interface 与 class)

5、多系统之间数据交换技术:
A、RFC (一种特殊的function module,用于SAP系统与非SAP系统之间数据交换,SAP <-> 其他系统)
B、EDI (一种SAP系统与非SAP系统之间数据交换的技术,SAP <-> 文件服务器 <-> 其他系统)
C、XI (一种SAP系统与非SAP系统之间数据交换的技术,SAP <-> IDOC <-> 其他系统)
D、BAPI(可以看作是封装过的的RFC,用于SAP系统与非SAP系统之间数据交换,SAP <-> 其他系统)

6、增强技术:在遇到需要修改标准程序中某些逻辑或者数据时,一般不建议直接去修改标准程序,而是尽量利用SAP提供的出口。
A、USER EXIT
B、CUSTOM EXIT
C、SCREEN EXIT
D、MENU EXIT
F、BADI (属于EXIT的升级版,用OO技术实现)

7、 数据导入导出技术:下列工具主要应用在项目进入测试阶段,需要导入大量主数据的时候。
A、CATT、ECATT(系统会提供一些基本的组件供顾问适用,但如有特殊的需求,还是需要顾问自行录制)
B、BDC(BATCH INPUT) (用这种方式导入数据需要通过ABAP代码协助实现)
C、LSMW(适用于录入数据量非常大的场景,但建立的步骤比较细,看起来比较繁杂,每一步都是环环相扣的,如果前面一步你没做,后面的就会进行不下去哦。)

以上只是简单的列出一些常用的工具与技术,可能还会有漏掉的部分,但是如果能把这些都掌握好,就是算不上一个顶级高手也是一个顶级老鸟咯,呵呵,今天到此为止。嘎嘎!


qmhiro - by - 11 二月, 2008 12:48

Rule Group

Use

A rule group is a group of transformation rules. It contains one transformation rule for each key field of the target. A transformation can contain multiple rule groups.

Rule groups allow you to combine various rules. This means that for a characteristic, you can create different rules for different key figures.

Features

Each transformation initially contains a standard group. Besides this standard group, you can create additional rule groups.

If you have defined a new rule in rule details, you can specify whether this rule is to be used as a reference rule for other rule groups. If it is used as a reference rule, then this rule is also used in existing rule groups as a reference rule where no other rule has been defined.

Example

The source contains three date characteristics:

Order date

Delivery date

Invoice date

The target only contains one general date characteristic. Depending on the key figure, this is filled from the different date characteristics in the source.

Create three rule groups which, depending on the key figure, update the order date, delivery date, or invoice date to the target.

http://help.sap.com/saphelp_nw2004s/helpdata/en/44/32cfcc613a4965e10000000a11466f/frameset.htm



qmhiro - by - 26 十一月, 2007 22:03

80% of development costs are in the construction of the data model and data extracts.
************************************
Shared Data Model *
Pre-configured Extracts *
Metadata Repository linked to R/3 *
Reduced custom ABAP requirements.
Integrate multiple R/3 versions, modules and external data
************************************


qmhiro - by - 10 十一月, 2007 00:21

BUSINESS WAREHOUSE QUESTIONS

Note: A large portion of this information came from SAP’s online Help. For additional information, follow the links included in these questions and answers.

What is the Business Warehouse? [answer]

How is data structured in the Business Warehouse for queries, reporting and analysis? [answer]

What is Business Explorer (BEx) Analyzer? [answer]

What is BEx Web Reporting? [answer]

What are the basic navigation functions in BEx? [answer]

What kind of reports should be written in BW? Which ones should be written in R/3? [answer]

Why are most BW reports written against an InfoCube, rather than an ODS? [answer]

What is required to report against the Business Warehouse? [answer]

Can one user see or overwrite another’s report views? [answer]

How can a report view be deleted? [answer]

Who are Power Users? [answer]

Who are Report Developers? [answer]

Can other tools (such as Crystal, Brio, WebFOCUS) be used to get to IRIS data? [answer]

What is the Business Warehouse?

Answer: Business Warehouse is the long-term solution for IRIS reporting. With a data warehouse as its core, Business Warehouse offers tools for data extraction from SAP R/3, reporting, and analysis; delivered Business Content reports; and a web-based user interface called Business Explorer (BEx). As with other IRIS modules, the Business Warehouse implementation will occur in phases.

The SAP Business Warehouse (BW) will use DB2 (database software) and the existing Informatica ETL servers to migrate (over the next three to five years) historical data currently in the Oracle Data Warehouse Environment, as well as any other external (non-SAP) data into BW. BW includes its own reporting tools which will be evaluated during the first six months of the BW implementation to determine if they meet the needs currently filled by SAS, WebFOCUS and desktop reporting tools such as Brio and Crystal.

How is data structured in the Business Warehouse for queries, reporting and analysis?

Answer: The data in the Business Information Warehouse is structured into self-contained business data areas (InfoProviders). Some InfoProviders included are InfoCubes (a quantity of relational tables), Operational Data Stores (ODS) which store consolidated and cleansed transaction data on a document level, or combinations of these called MultiProviders. Queries will be defined so users can analyze the data. By selecting and combining InfoObjects (characteristics and key figures) or reusable structures in a query, users determine the way in which they navigate through and evaluate the data in the selected InfoProvider.

What is Business Explorer (BEx) Analyzer?

Answer: The Business Explorer Analyzer (BEx Analyzer) is the analysis and reporting tool that is embedded in Microsoft Excel and will be used by Power Users to write reports. It provides flexible reporting and analysis for strategic analyses and decision-making support. An employee with authorization can evaluate data to varying degrees of detail and from different perspectives on the Web and in MS Excel.

What is BEx Web Reporting?

Answer: BEx Web Reporting gives users a spectrum of access to the information in Business Warehouse. Users can customize and run reports (views) written by others. The data, displayed in the form of a pivot table, is the starting point for detailed analysis. Navigation functions allow users to change the query and generate further views of the data. There are more functions in the context menus of the InfoObjects. BW users can change the display of characteristics and key figures; adjust settings that affect the display of the entire query, the characteristics, the key figures, or the data; define sort orders (for example, ascending or descending) and filters; swap characteristics or recalculate values; and configure the presentation of the data in accordance with their requirements. Using exception reporting, users can readily identify objects that deviate from the norm or are critical. In addition, once they export the query to Excel, users can use the editing functions in Microsoft Excel in order to set up individual format templates, print results areas, or create graphics such as bar charts or pie charts. They can export the report view to MS Excel or a CSV (Comma Separated Value) file.

What are the basic navigation functions in BEx?

Answer: Navigation allows BW users to view and evaluate the query data from different points of view. When users navigate, they change the initial query view and create new views of the query data.

The basic navigation functions are:

  • Displaying a hierarchy
  • Filtering a characteristic by a characteristic value
  • Drilling down according to a characteristic and changing the drilldown status
  • Filtering a characteristic and drilling down by another characteristic
  • Distributing the characteristics and key figures along the row axes and the column axes of the query
  • Putting the characteristics and key figures in order
  • Hiding and showing key figures
  • Activating and deactivating conditions
  • Activating and deactivating exceptions

What kind of reports should be written in BW? Which ones should be written in R/3?

Answer: To determine specific reporting needs and ensure use of the right reporting tools, it is helpful to classify information requests into two basic types — (1) tactical and (2) strategic. Tactical reports typically contain real-time, dynamic transactional-level information. Tactical reporting is also referred to as operational reporting (R/3). Strategic reports gather detailed data into an aggregated format for strategic analysis. Strategic reporting is also known as analytical reporting (BW).

BW provides much better performance and stronger data analysis capabilities than R/3. With BW the user can analyze data from SAP applications, as well as from any external (non-SAP) data sources that have been migrated to BW. These external data sources will eventually include the existing historical data in the Oracle Data Warehouse Environment, and may include data from some of the “peripheral” administrative applications created by departments.

Why are most BW reports written against an InfoCube, rather than an ODS?

Answer: Because the data is summarized, reports written against an InfoCube return data quickly. When a report is written against an ODS, the data is generally more detailed and more voluminous, thus taking longer to be returned.

Detail reports against an ODS will be provided. The preferred method of accessing these reports is to first access a summarized report and then drill down to the applicable detail by linking to the detail report.

What is required to report against the Business Warehouse?

Answer: To report against BW, users must complete training on the Business Warehouse Business Explorer (BEx) Web reporting tool anddemonstrate competency to gain access to BW Production. The BEx tool will allow them to report on data entered into IRIS and extracted nightly for the Business Warehouse.

A BEX_300 Web Simulation class is available. Employees should contact BWRequests@email.uky.edu to request access to the simulation.

BEX_300 classroom training will also be available, based on demand. Employees who prefer classroom training should send their requests to: BWRequests@email.uky.edu.

A web simulation [Simulation – BW Introduction to Ledgers – Java Version (preferred)] and handout are also available for Ledger reporting in the Business Warehouse portion of myHelp.

Users must have an Active Directory account to sign on to Business Warehouse.

Can one user see or overwrite another’s report views?

Answer: Users who have the same security role will be able to see all the report views in that role. This is advantageous for sharing report views.

No one will be able to overwrite a report view. To change a report view and save the changes, the user must save the report view with a new technical name.

How can a report view be deleted?

Answer: BW users can ask a Power User to delete report views or send a request for deletion (with Technical Name of the report view) to BWRequests@email.uky.edu.

Who are Power Users?

Answer: Power Users are employees with knowledge of the data available in R/3 and BW, advanced skills in writing reports, and the need to create custom reports on an ad hoc basis. Due to the advanced functionality of BEx Web Reporting, a limited number of Power Users will need to be trained to write queries. Power Users will only be able to share reports with other Power Users.

Who are Report Developers?

Answer: Report Developers are familiar with the data available in R/3 and BW. Equipped with advanced skills in writing reports, they can create reports for others and make reports accessible for BEx Web Users.

Can other tools (such as Crystal, Brio, WebFOCUS) be used to get to IRIS data?

Answer: At this time, there are no other tools connected to the data. Users can export the data from IRIS to Excel or CSV (Comma Separated Values file), however, and then use another tool (e.g., Crystal) against the file. When there is more data than will fit into an Excel spreadsheet, users can create a CSV file and import the data into MS Access. They can then use Access, Brio or Crystal to report against the MS Access database. This allows users to take advantage of special functionality in the desktop tools which may not be currently available in BEx.



qmhiro - by - 31 十月, 2007 23:49

sap bw LO Extraction

  1. Go to transaction code RSA3 and see if any data is available related to your DataSource. If data is there in RSA3 then go to transaction code LBWG (Delete Setup data) and delete the data by entering the application name.
  2. Go to transaction SBIW –> Settings for Application Specific Datasource –> Logistics –> Managing extract structures –> Initialization –> Filling the Setup table –> Application specific setup of statistical data –> perform setup (relevant application)
  3. In OLI*** (for example OLI7BW for Statistical setup for old documents : Orders) give the name of the run and execute. Now all the available records from R/3 will be loaded to setup tables.
  4. Go to transaction RSA3 and check the data.
  5. Go to transaction LBWE and make sure the update mode for the corresponding DataSource is serialized V3 update.
  6. Go to BW system and create infopackage and under the update tab select the initialize delta process. And schedule the package. Now all the data available in the setup tables are now loaded into the data target.
  7. Now for the delta records go to LBWE in R/3 and change the update mode for the corresponding DataSource to Direct/Queue delta. By doing this record will bypass SM13 and directly go to RSA7. Go to transaction code RSA7 there you can see green light # Once the new records are added immediately you can see the record in RSA7.
  8. Go to BW system and create a new infopackage for delta loads. Double click on new infopackage. Under update tab you can see the delta update radio button.
  9. Now you can go to your data target and see the delta