PO_ABAPCoding规范(模板)

合集下载

SAP-ABAP 程序规范

SAP-ABAP 程序规范

Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
语句规范
MODIFY
MODIFY IT_TAB FROM WA_TAB INDEX SY-TABIX TRANSPORTING COL1 COL2 WHERE KEY1 = XXX AND KEY2 = XXX
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
语句规范
READ
例: CLEAR WA_TAB. READ TABLE IT_TAB INTO WA_TAB WITH KEY COL1 = XXX COL2 = XXX IF SY-SUBRC = 0. ELSE. ENDIF.
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
SAP-ABAP 培训 --程序规范
ABAP 程序规范
程序模板 语句规范 编程规范 程序相关文档
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司
程序模板
E:\work\IBM\ TEMPLATE_DEVt Information Systems Co.,Ltd. 柯莱特信息系统有限公司
Camelot Information Systems Co.,Ltd. 柯莱特信息系统有限公司

ABAP开发功能规格说明书模板

ABAP开发功能规格说明书模板

此处的签名,表示企业的负责用户确认本文档内容中的报表需求及功能设计。

姓名:……………………………………
职务:……………………………………
日期:……../……../……..
文件名: : 日期: 5/8/2013
关键用户签名
姓名:……………………………………
日期:……../……../……..
业务顾问签名
姓名:……………………………………
日期:……../……../……..
文件名: : 日期: 5/8/2013
报表用途(描述编写报表的用途或目的)
总体要求(报表/程序执行的功能描述)
报表使用者
使用频度(日、月、季度或年)
后台处理/在线处理
打印机类型(激光 / 喷墨 / 针式)
纸张大小/方向
使用语言
开发优先度
注释
文件名: : 日期: 5/8/2013
5.1权限要求(对于某些个别字段须要进行权限控制,如公司代码等)
5.3所需数据表及字段描述
5.5报表 / 表单的输出格式及备注
(附报表格式)
文件名: : 日期: 5/8/2013
文件名: : 日期: 5/8/2013。

ABAP Report一般格式

ABAP Report一般格式
*& AT SELECTION SCREEN
*&----------------------------------------------------------------------
*AT SELECTION-SCREEN.
*
*Extras:
*******************************(3)列表事件Begin******************************
*处理一此报表的交互,如普通列表、ALV等*
*&---------------------------------------------------------------------*
* Date Programmer Correction Number Correction Type *
* Descriptions:
* 2.1 <功能简介>
* 2.2 <功能前提>
************************************************************************
*& TABLES:
*&---------------------------------------------------------------------*
*TABLES: ZTEST
*&---------------------------------------------------------------------*
* END-OF-SELECTION 选择结束事件,一般用于输出列表
*----------------------------------------------------------------------*

SAP_ABAP开发标准书2

SAP_ABAP开发标准书2

ABAP开发标准书序言<目的>该文档定义了在开发与维护ABAP程序过程中必须遵守的规范与标准。

该文档应当被视为一个动态的文档,该文档会根据需要进行增补和修订。

开发规范的重要作用在于保持整个开发团队的开发风格一致,提高程序质量,降低维护压力。

<对象范围>ABAP Developer(如:创建或维护ABAP程序、ABAP Dictionary 对象)必须遵守该文档中的规范约束。

ABAP (1)开发标准书 (1)1 开发规范介绍 (8)2 程序属性 (10)3 程序命名规则 (11)3.1方针 (11)3.1.1 对象名称 (11)3.2 基本命名基准 (11)3.2.1 用户开发的开头文字 (11)3.2.2 系统简称 (11)3.2.3 Module简称 (12)3.2.4 表示处理功能的英文字 (12)3.3.1 Program (13)3.3.2Function Group (14)3.3.3 Function Module (14)3.3.3.1 Function Module名 (14)RFC的区分待整理 (14)3.3.3.2 Import Parameter (14)3.3.3.3 Export Parameter (14)3.3.3.4 Changing Parameter (14)3.3.3.5 Table Parameter (14)3.3.3.6 接口 (14)3.3.5 Set/Get Parameter (15)3.3.6 Dynpro Program (15)3.3.6.1 Dynpro 界面号 (15)3.3.6.2 Module Pool (16)3.3.6.3 Include Program (16)3.3.6.4 Dynpro画面部件 (17)3.3.7 Message (18)3.3.7.1 Message Class (18)3.3.7.2 Message ID (18)3.3.8 编号范围Object(SNRO) (18)3.3.9 Text Element (19)3.3.10 宏(Macro) (19)3.3.11功能代码 (19)3.4 ABAP Program Object (20)3.4.1 Table (20)3.4.1.1 主档表 (20)3.4.1.2 描述表 (20)3.4.2结构 (21)3.4.2.1 结构名 (21)3.4.2.2 构造项目名 (21)3.4.3 其他 (21)3.4.3.1 表类型 (21)3.4.3.2 视图(View) (21)3.4.3.3 Data Element (22)3.4.3.5 Lock Object (22)3.4.3.6 检索help (22)3.5 增强Object (22)3.5.1 Customer Exit (22)3.5.1.1 增强Object(CMOD) (22)标准的名称第一位换成Z (23)3.5.2 Table扩张 (23)3.5.2.1 Append構造 (23)3.5.3 BADI (23)3.5.3.1 命名 (23)3.5.3.2 Class 命名 (23)3.5.4BAPI (23)3.5.5 IDOC (23)3.5.5.1 Subporject (23)3.5.5.2Partner Type (24)3.5.5.3 Partner 号 (24)4 程序格式标准 (25)4.1 Pretty Printer (25)4.2 程序说明 (25)4.3 注释 (26)4.4程序修改 (26)4.4.1追加时 (26)4.4.2删除时 (26)4.4.3修改时 (27)5 ABAP语法 (28)5.1 TABLES参照构造定义 (28)5.2 TYPES定义 (28)5.3内表定义 (29)5.4 工作区定义 (29)5.5 固定值定义 (29)5.6 全局变量定义 (30)5.7 PARAMETERS & SELECT-OPTIONS (30)5.8 事件 (30)5.8.1INITIALIZATION事件 (30)5.8.2 AT SELECTION SCREEN事件 (31)5.8.3 事件记述方法 (31)5.9 FORM (33)5.9.1 FORM说明 (33)5.9.2 FORM抬头 (33)5.9.3 FORM内的变量 (34)6 命令相关 (35)6.1数据赋予 (35)6.2 处理块结束命令 (35)6.3 算术计算 (35)6.4 分支处理 (35)6.4.1逻辑运算符 (35)6.4.2多分支处理 (36)6.5 文字列操作 (36)6.5.1 文字列比较 (36)6.5.2 文字列结合 (36)6.5.3文字列分割 (36)6.5.4空格删除 (36)6.5.5项目值置换 (37)6.6数据库处理 (37)6.6.1更新 (37)6.6.2.2 件数计算 (37)6.6.2.3 单一数据取得 (38)6.6.2.4 集计函数 (38)6.6.2.5 记录的存在性检查 (38)6.6.2.6 内表保存 (39)6.6.2.7 项目取得 (39)6.6.2.8 重复数据的删除 (39)6.7 内表处理 (40)6.7.1 READ (40)6.7.2 LOOP (40)6.7.3 APPEND (40)6.7.4 SORT (41)6.7.5 重复数据删除 (41)6.8 数据转移 (41)6.8.1 相同构造的数据转移 (41)6.8.2 不同构造的数据转移 (41)1 开发规范介绍开发规范的应用能够提升系统运行生命周期中开发、测试、维护阶段的工作效率。

ASP编码规范书

ASP编码规范书

产品编码规范书北京北大方正集团公司北京大学计算机科学技术研究所2001年03月一、语言选择服务器端脚本尽量使用JavaScript,原因在于VBScript的错误处理会影响代码的可读性.二、书写格式代码书写格式整齐统一、、层次清晰便于阅读。

●缩进TAB键统一为4个空格●赋值语句(=)及逻辑判断符(> < != && ||...etc)左右各空一格●算术运算符左右各空一格●if/while/switch之类的语句右边空一格●每个成员函数内部各个子功能之间用一个空行●公用成员放在程序的最前面,私用成员在后。

三、恰当地使用注释注释应简洁、清楚。

●不提倡使用/* 和*/来注释, 最好使用//来注释。

如果是对某一段程序(算法/结构)的注释, 在程序头直接用//再空一格来进行说明,一行不要超过80字符●注释就占程序的30%,如10行代码中就有不小于3行的注释。

四、关于命名1、变量必须显式定义如果使用VBScript,使用变量前必须显式定义。

虽然VBScript支持变量不定义就直接使用,但使用未经定义的变量可能会导致不可预知的错误。

可以在asp文件的所有执行代码前添加<% OPTION EXPLICIT %>强制要求变量定义.2、变量的命名除了循环变量i,j,k...之外,文件、类、(成员)变量、(成员)函数的命名要有意义,大小写相间,一目了然;成员变量、函数(Method)的首字母小写全局变量名称以“g_”开头。

3、匈牙利命名法命名时可以遵循匈牙利命名法它通过在数据和函数名中加入额外的信息以增进程序员对程序的理解。

如字符串,前面加上str;.var strTemp = “This is ……”;i -----> intu -----> UINTw -----> WORDdw -----> DWORDb -----> BOOLby -----> BYTEch -----> CHARsz -----> CHAR ARRAYstr-----> STRINGl -----> LONGf -----> floatd -----> doubleq -----> SINT64uq -----> UINT64v -----> voidfn -----> functionh -----> HANDLErect -----> RECT, CRectpt -----> POINT, Cpointo ---->objecttxt---->textboxchk---->checkboxrdo--→radiocbo---->select(dropdown)lst---->select(list)div---->DIVpwd---->passwordtbl---->tablefra--→frameconn--→ADODB.CONNECTIONrs--→ADODB.RECORDSET五、局部变量一定要初始化如果你声明一个变量,不要以为编译器会自动将之赋零值!你随手给它赋个初值并不麻烦,却会使程序更可靠,var fTemp = 0.0;六、.成员函数:成员函数的功能一定要单一;实现其功能时不要过分追求技巧,函数体不能过长七、.数组和缓冲区的使用对数组和缓冲区进行检查,防止越界,尤其是变长的情况下八、.尽量不要用goto语句特别谨慎使用goto语句,最好别用它尽管goto语句在某些特殊的情况下(比如编译器中)还很管用, 但它破坏了整个程序的结构,尤其使用goto嵌套时,更让人一头雾水(很久以前就有人提出取消它)。

SAP_ABAP_TCODE讲解

SAP_ABAP_TCODE讲解

stad 可以查到6天内所有的日志DD01V 可以查询数据元素CMOD SAP增强DB15 表格和存档对象DB2 数据库状态OS01 可以查到当前连接的电脑名称OS03 操作系统的参数改变OS04 本的系统配置OS05 远程系统配置OS06 本地系统监视器OS07 远程系统监视器OSS1 登陆到OSSSE13 维护技术设置SM21 系统日志,本地分析SM02 系统消息SM01 事务代码系统管理SM28 安装检查SMLT 语言管理USMM 系统测量SARA 数据归档LICENSE_ADMIN 合并系统测量SM59 RFC目的地SM5E TXCOM维护SM55 THOST维持SICF HTTP服务层次结构维护SCC4 集团建立SCCL 本地集团复制SCC9 远程集团复制SCC1 复制传送请求SCC5 删除集团SCC3 复制日志SCC8 集团输出SCC7 输入编辑SCU0 跨系统查看器SCMP 对象比较SM50 进程概蓝SM51 服务器SM04 用户概蓝SMGW 网关接控器SMICM INTERNET 通讯管理员SM13 更新SM35 批输入SM58 事务性RFCST05 执行跟中ST01 系统轨迹ST11 开发者轨迹SSAA 系统管理助手SU56 用户缓冲区SM56 数字范围缓冲区SM12 锁定条目ST22 转储分析SM19 配置SM20 分析SM18 重新组织SU01 用户SU01D 显示用户SU10 用户批维护SUGR 维护用户组SUCOMP 公司地址file 设定论理路经AL11 查看服务器文件slg1 可以查到某用户的日志文件先写到这里.以后再写.login/system_client 650保存后,重启SAP服务就生效。

要限制同一个帐号同一时间只能在一台机器上登陆,不能同时在多台机器上使用,系统参数是什么? login/disable_multi_gui_login1.增加参数rdisp/gui_auto_logout = 02.表USR41可以看到用户登陆时间的长度3.写个批处理,可以每次用这个来启动SAP服务startsap name=T01 nr=00 SAPHOST=jpzx014.rdisp/max_alt_modes 设置启动多少个画面。

abap报表编程模板

abap报表编程模板

ABAP/4 报表编程模板*&--------------------------------------------------------------**& Report Z_X_XXXXX*& Module : Module \ SubModule*&--------------------------------------------------------------**& Created : author (2003.10.09)*& Modified : author (someday)* Intention : 程序的详细说明* 请用户在ABAP/4 REPORT编程时,参考本程序提供的编程框架** 在编码规范有出入时,以本程序为准* 以下各事件可根据实际编程需要使用,对于需要处理的事件,可将该事* 件后面的语句注释去掉,再编写相应的子程序代码。

*&--------------------------------------------------------------*INCLUDE Z_X_XXXXXTOP . " TOP 子程序,用来声明全局变量*----以下三个子程序只有在多个程序调用同一逻辑时才建议使用-----**INCLUDE Z_X_XXXXXO01 . " PBO 子程序*INCLUDE Z_X_XXXXXI01 . " PAI 子程序*INCLUDE Z_X_XXXXXF01 . " form 子程序INITIALIZATION.* PERform INI_SELECTION_SCREEN. " 初始化选择屏上的变量AT SELECTION-SCREEN.* PERform INI_DATA. " 初始化全局变量START-OF-SELECTION.* PERform PRECESS_DATA. " 主要数据处理逻辑AT LINE-SELECTION.* PERform PRECESS_LINE_SELECTED. " 行选择时的处理AT USER-COMMAND.* PERform PRECESS_USER_COMMAND. * 用自定义命令按钮时的处理TOP-OF-PAGE.* PERform PAGE_HEADER. " 页眉END-OF-PAGE.* PERform PAGE_FOOT. " 页脚*& form PRECESS_DATA*&--------------------------------------------------------------** text*---------------------------------------------------------------** --> p1 text* <-- p2 text*---------------------------------------------------------------*form PRECESS_DATA.*如果逻辑简单, 则合并若干form为一个PERform SEL_DBTAB_XXXXX. " 从透明表中取数据赋给内表 PERform CMP_ITAB_XXXXX. " 内表中数据计算处理PERform WRT_ITAB_RESULT. " 输出内表数据ENDform. " PRECESS_DA TA*&--------------------------------------------------------------**& form SEL_DBTAB_XXXXX*&--------------------------------------------------------------** text*---------------------------------------------------------------** --> p1 text* <-- p2 text*---------------------------------------------------------------*form SEL_DBTAB_XXXXX.select * into corresponding fields of itab_salesfrom bsidwhere bukrs = s_bukrs.authority-check object 'Z:FI-00001'id 'ACTVT' field '03'id 'BUKRS' field itab_sales-bukrsid 'GSBER' field itab_sales-gsber. "权限检查if sy-subrc ne 0. "权限检查未通过continue.endif.append itab_sales.clear itab_sales.endselect.ENDform. " SEL_DBTAB_XXXXX*&--------------------------------------------------------------**& form CMP_ITAB_XXXXX* text*---------------------------------------------------------------* * --> p1 text* <-- p2 text*---------------------------------------------------------------*form CMP_ITAB_XXXXX.ENDform. " CMP_ITAB_XXXXX*&--------------------------------------------------------------* *& form WRT_ITAB_RESULT*&--------------------------------------------------------------* * text*---------------------------------------------------------------* * --> p1 text* <-- p2 text*---------------------------------------------------------------* form WRT_ITAB_RESULT.* PERform WRT_ITAB_SUB.ENDform. " WRT_ITAB_RESULT*&--------------------------------------------------------------* *& form PAGE_HEADER*&--------------------------------------------------------------* * text*---------------------------------------------------------------* * --> p1 text* <-- p2 text*---------------------------------------------------------------* form PAGE_HEADER.ENDform. " PAGE_HEADER*&--------------------------------------------------------------* *& form INI_DATA*&--------------------------------------------------------------* * text*---------------------------------------------------------------* * --> p1 text* <-- p2 text*---------------------------------------------------------------* form INI_DATA.ENDform. " INI_DATA*&--------------------------------------------------------------**& form INI_SELECTION_SCREEN*&--------------------------------------------------------------** text*---------------------------------------------------------------** --> p1 text* <-- p2 text*---------------------------------------------------------------*form INI_SELECTION_SCREEN.ENDform. " INI_SELECTION_SCREEN*&--------------------------------------------------------------**& Include Z_X_XXXXXTOP*&--------------------------------------------------------------*REPORT Z_X_XXXXX .*-------------------声明系统字典对象----------------------------*TABLES: t001.*--------------------声明Selection-screen 变量-----------------*SELECTION-SCREEN BEGIN OF BLOCK B1WITH FRAMETITLE TEXT-001.SELECTION-SCREEN SKIP.SELECT-OPTIONS: S_BUKRS FOR T001-BUKRS MEMORY ID BUK. PARAMETERS: P_DATE LIKE SY-DATUM DEFAULT SY-DATUM.SELECTION-SCREEN END OF BLOCK B1.*--------------------声明全局变量-------------------------------**声明内表时,表名为ITAB_XXXX,后缀尽可能为关联DBTab或内表用途DATA: bldat like bsid-bldat.RANGES: R_FIELD FOR DBTAB-FIELD.说明:以上是模板程序的框架及说明,在R/3系统的开发环境中有该模板程序(Z_X_XXXXX),建议编程序之前,先将该程序另存一新文件,再根据需要修改这新文件。

CppCodingStyleGuide poco代码规范

CppCodingStyleGuide poco代码规范

Applied Informatics C++ Coding Style Guide Rules and RecommendationsVersion 1.3Purpose of This DocumentThis document describes the C++ coding style employed by Applied Informatics.The document is targeted at developers contributing C++ source code to the products of Applied Informatics, including contributions to open-source projects like the POCO C++ Libraries.Copyright, Licensing, Trademarks, DisclaimerCopyright © 2006-2010, Applied Informatics Software Engineering GmbH. All rights reserved. This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit /licenses/by/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.All trademarks or registered marks in this document belong to their respective owners. Information in this document is subject to change without notice and does not represent a commitment on the part of Applied Informatics. This document is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the particular purpose. Applied Informatics reserves the right to make improvements and/or changes to this document or the products described herein at any time.AcknowledgementsThis work is based on various guidelines found on the internet, especially the rules and recommendations by Mats Henricson and Erik Nyquist. Also incorporated are ideas and recommendations from various other sources. See the Appendix for a list of recommended resources.Table of Contents1 Introduction (5)2 Terminology (6)3 General Recommendations (8)4 Source Files and Project Structure (9)4.1 Structure of Source Code 9 4.2 Naming Files 9 4.3 Project Structure 9 4.4 Whitespace 10 4.5 Comments 11 4.6 Header Files 125 Names (15)6 Style (18)6.1 Classes 18 6.2 Functions 19 6.3 Templates 20 6.4 Compound Statements 20 6.5 Flow Control Statements 20 6.6 Pointers and References 21 6.7 Miscellaneous 227 Classes (23)7.1 Access Rights 23 7.2 Inline Functions 23 7.3 Friends 24 7.4 Const Member Functions 25 7.5 Constructors and Destructors 25 7.6 Assignment Operator 27 7.7 Operator Overloading 28 7.8 Member Function Return Types 29 7.9 Inheritance 298 Class Templates (30)9 Functions (31)9.1 Function Arguments 31 9.2 Function Overloading 32 9.3 Formal Arguments 32 9.4 Return Types and Values 32 9.5 Inline Functions 33 9.6 Temporary Objects 33 9.7 General 3310 Constants (35)11 Variables (36)12 Pointers and References (37)13 Type Conversions (38)14 Flow Control (39)15 Expressions (41)16 Memory and Resources (42)17 Namespaces (44)18 Error Handling (45)19 Portability (46)20 References and Recommended Reading (47)21 Appendix: Documentation (49)21.1 General Conventions 49 21.2 Documenting Classes and Structs 49 21.3 Documenting Functions 50 21.4 Documenting Enumerations 51 21.5 Documenting Types 51 21.6 Libraries, Packages and Modules 5122 Appendix: Abbreviations (52)1IntroductionThe purpose of this document is to define one style of programming inC++. The rules and recommendations presented here are not final, butshould serve as a basis for continued work with C++. This collection of rulesshould be seen as a dynamic document; suggestions for improvements areencouraged. Suggestions can be made via e-mail to poco@.Programs that are developed according to these rules and recommendationsshould be:•correct•easy to maintain.In order to reach these goals, the programs should:•have a consistent style,•be easy to read and understand,•be portable to other architectures,•be free of common types of errors,•be maintainable by different programmers.Questions of design, such as how to design a class or a class hierarchy, arebeyond the scope of this document. Recommended books on these subjectsare indicated in the appendix entitled References.In order to obtain insight into how to effectively deal with the most difficultaspects of C++, the provided example code should be carefully studied. C++is a difficult language and there may be a very fine line between a feature anda bug. This places a large responsibility upon the programmer, as this isalways the case when using a powerful tool. In the same way as for C, C++allows a programmer to write compact and, in some sense, unreadable code.In order to make the code more compact, the examples provided do notalways follow the rules. In such cases, the broken rule is clearly indicated.2Terminology1.An identifier is a name used to refer to a variable, constant, functionor type in C++. When necessary, an identifier may have an internalstructure consisting of a prefix, a name, and a suffix (in that order).2. A class is a user-defined data type consisting of data elements andfunctions operating on that data. In C++, this may be declared as aclass; it may also be declared as a struct or a union. Variables definedin a class are called member variables and functions defined in a classare called member functions.3. A class/struct/union is said to be an abstract data type if it does nothave any public or protected member variables.4. A structure is a user-defined consisting of public member variablesonly.5.Public members of a class are member variables and memberfunctions that are accessible from anywhere by specifying an instanceof the class and the name.6.Protected members of a class are member variables and memberfunctions that are accessible by specifying the name within memberfunctions of derived classes.7. A class template defines a family of classes. A new class may becreated from a class template by providing values for a number ofarguments. These values may be names of types or constantexpressions.8. A function template defines a family of functions. A new functionmay be created from a function template by providing values for anumber of arguments. These values may be names of types or constantexpressions.9.An enumeration type is an explicitly declared set of symbolicintegral constants. In C++ it is declared as an enum.10. A typedef is another name for a data type, specified in C++ using atypedef declaration.11. A reference is another name for a given variable. In C++, the“address of” (&) operator is used immediately after the data type toindicate that the declared variable, constant, or function argument is areference.12. A macro is a name for a text string defined in a #define statement.When this name appears in source code, the compiler’s preprocessorreplaces it with the defined text string.13. A constructor is a function that initializes an object.14. A copy constructor is a constructor in which the only argument is areference to an object that has the same type as the object to beinitialized.15. A default constructor is a constructor with no arguments.16.An overloaded function name is a name used for two or morefunctions or member functions having different argument types. 17.An overridden member function is a member function in a baseclass that is re-defined in a derived class. Such a member function isdeclared virtual.18. A pre-defined data type is a type defined in the language itself,such as bool or int.19. A user-defined data type is a type defined by a programmer in aclass, struct, union, enum, or typedef definition or as aninstantiation of a class template.20. A pure virtual function is a member function for which nodefinition is provided. Pure virtual functions are specified in abstractbase classes and must be defined (overridden) in derived classes.21.An accessor is a function returning the value of a member variable.22. A mutator is a function modifying the value of a member variable.23. A forwarding function is a function doing nothing more thancalling another function.24. A constant member function is a function that must not modifydata members.25.An exception is a run-time program anomaly that is detected in afunction or member function. Exception handling provides for theuniform management of exceptions. When an exception is detected, it is thrown (using a throw expression) to the exception handler.26. A catch clause is code that is executed when an exception of a giventype is raised. The definition of an exception handler begins with thekeyword catch.27.An abstract base class is a class from which no objects may becreated; it is only used as a base class for the derivation of other classes.A class is abstract if it includes at least one member function that isdeclared as pure virtual.28.An iterator is an object which, when invoked, returns the next objectfrom a collection of objects.29.The scope of a name refers to the context in which it is visible.30. A compilation unit is the source code (after preprocessing) that issubmitted to a compiler for compilation (including syntax checking).3General RecommendationsRecommendation 1Optimize code only if you know for sure that you have a performanceproblem. Think twice before you begin. Then measure and think again.C++ compilers are pretty good at optimizing these days. So, source codethat “looks fast” does not necessarily produce faster object code. It only isharder to understand and maintain.As C.A.R. Hoare once said: Premature optimization is the root of all evil.Recommendation 2Always compile production code with at least a second compiler and on asecond platform. If the code has been developed with Microsoft Visual C++under Windows XP, compile and test the code with the GNU C++ compileron a Unix platform, and vice versa. Even better is testing with a thirdcompiler, e.g. HP ANSI C++ or Sun Forte C++. This brings to light subtleerrors and portability problems.Recommendation 3Always compile at the highest warning level possible. A lot of bugs can beavoided by paying attention to compiler diagnostics.Rule 1If this style guide leaves anything unclear, see how it has been done in theexisting code base and do it accordingly.4Source Files and Project Structure 4.1Structure of Source CodeRule 2Header (include) files in C++ always have the file name extension ".h".Rule 3Implementation files in C++ always have the file name extension ".cpp". 4.2Naming FilesRule 4Always give a file a name that is unique in as large a context as possible.A header file for a class should have a file name of the form <class name> +extension. Use uppercase and lowercase letters in the same way as in thesource code.Since class names must generally be unique within a large context, it isappropriate to utilize this characteristic when naming its header file. Thisconvention makes it easy to locate a class definition using a file-based tool.4.3Project StructureRule 5Every project (library or application) has its own directory with a well-defined structure.A project directory contains project files, make files, as well as otherdirectories for header files, implementation files, documentation and the testsuite.Figure 1 shows the directory hierarchy for a project.Figure 1: Project directory hierarchyA test suite is a project in itself and thus has the same general structure,within the testsuite directory. Since a test suite has no public headerfiles, there is no include directory in a test suite.Rule 6Public header files always go into the include directory or a subdirectorythereof. To avoid name clashes and for better comprehensibility, theinclude directory may contain subdirectories. For libraries, the includedirectory usually contains a subdirectory with the same name as the library.Rule 7All implementation files and non-public header files go into the srcdirectory.Rule 8All project files, make files and other support files not containing sourcecode go directly into the project directory.Recommendation 4If there is extra documentation for a project (e.g. specifications or standarddocuments), this documentation goes into a directory named doc.4.4WhitespaceRule 9In a header or implementation file, introductory comment, include guards,#include block, using block and function definitions are separated bytwo empty lines. This makes it easier to visually distinguish the variouselements.Rule 10The last line in an implementation or header file must be terminated by anewline. This is required by the C++ standard, but not enforced by mostcompilers.4.5CommentsRule 11Every file that contains source code must be documented with anintroductory comment that provides information on the file name, itsversion and its contents.Rule 12All files must include copyright information.Rule 13All comments are written in English.Rule 14Write a comment for every class, public/protected function andpublic/protected enum/typedef/struct. The standardization ofcomments makes it possible to automatically generate referencedocumentation from source code. This is used to keep source code anddocumentation together up-to-date. The format of these comments isdescribed in the Appendix.Rule 15Use // for comments.It is necessary to document source code. This should be compact and easy tofind. By properly choosing names for variables, functions and classes and byproperly structuring the code, there is less need for comments within thecode.Note that comments in header files are meant for the users of classes, whilecomments in implementation files are meant for those who maintain theclasses.All our code must be copyright marked. If the code has been developed overa period of years, each year must be stated.Comments are often said to be either strategic or tactical. A strategiccomment describes what a function or section of code is intended to do, andis placed before this code. A tactical comment describes what a single line ofcode is intended to do, and is placed, if possible, at the end of this line.Unfortunately, too many tactical comments can make code unreadable. Forthis reason, it is recommended to primarily use strategic comments, unlesstrying to explain very complicated code.If the characters //are consistently used for writing comments, then thecombination /* */ could be used to make comments out of entire sectionsof code during the development and debugging phases. C++, however, doesnot allow comments to be nested using /* */. So it is better to commentout large sections of code using the preprocessor (#if 0 ... #endif).Source files containing commented-out code sections must not be checkedin to the SCM repository, as this would confuse other developers workingwith that code.Example 1Boilerplate text to be included at the beginning of every header orimplementation file://// <FileName>.h//// $Id$//// Library: <LibraryName>// Package: <PackageName>// Module: <ModuleName>//// <One or two sentences describing what the header file is for. Can// be omitted in source (.cpp) files.>//// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.// All rights reserved.//// <License Notice>//4.6Header FilesRule 16Every header file must contain a mechanism that prevents multipleinclusions of the file.Rule 17When the following kinds of definitions are used (in implementation files orin other header files), they must be included as separate header files:•classes that are used as base classes,•classes that are used as member variables,•classes that appear as return types or as argument types infunction/member function prototypes.•function prototypes for functions/member functions used in inline member functions that are defined in the file.Rule 18Definitions of classes that are only accessed via pointers (*) or references (&) shall not be included as header files. Forward declarations shall be used instead. The only exceptions are classes that are in another namespace.Rule 19Never specify relative paths (containing “.” and “..”) in #include directives.Rule 20Every implementation file must include the relevant files that contain: •declarations of types and functions used in the functions that are implemented in the file.•declarations of variables and member functions used in the functions that are implemented in the file.Rule 21Every implementation file must, before any other header files, include its corresponding header file. This ensures that header files are self sufficient.Rule 22Use the directive #include "filename.h"for user-prepared include files.Rule 23Use the directive #include <filename.h>for system and compiler-supplied header files only.Rule 24Compiler include paths always point to the include directory in a project directory. Therefore, if a header file is located in a subdirectory of the include directory, it must be included with #include “dir/filename.h”. As a positive side effect, this avoids name clashes if different projects have a header file with the same name.The easiest way to avoid multiple includes of files is by using an#ifndef/#define block in the beginning of the file and an #endif at theend of the file.The number of files included should be minimized. If a file is included in aninclude file, then every implementation file that includes the second includefile must be re-compiled whenever the first file is modified. A simplemodification in one include file can make it necessary to re-compile a largenumber of files.When only referring to pointers or references to types defined in a file, it isoften not necessary to include that file. It may suffice to use a forwarddeclaration to inform the compiler that the class exists. Another alternativeis to precede each declaration of a pointer to the class with the keywordclass.Example 2Using include guards to prevent multiple inclusions of a header file:#ifndef Foundation_SharedPtr_INCLUDED#define Foundation_SharedPtr_INCLUDED#include "Poco/Foundation.h"...#endif // Foundation_SharedPtr_INCLUDED5NamesRule 25Every class library must define a unique namespace for its globally visibleidentifiers.Rule 26The identifier of every globally visible class, enumeration type, typedefinition, function, constant, and variable in a class library must be insidethe class library’s namespace.Rule 27The names of variables, and functions begin with a lowercase letter.Rule 28The names of abstract data types, classes, structures, types, and enumeratedtypes begin with an uppercase letter.Rule 29In names that consist of more than one word, the words are written togetherand each word that follows the first begins with an uppercase letter. 1Rule 30Global names must not begin with one or two underscores (“_” or “__”).This is forbidden by the C++ standard as such names are reserved for use bythe compiler.Rule 31With the exceptions of constants and enumeration values, there are nounderscores in names (after the first character of the name). 2Rule 32Do not use type names that differ only by the use of uppercase andlowercase letters.1 This is also known as camel-case.2 The leading underscore in names of private and protected member variables (see Rule 33) does not count here.Rule 33The name of a private or protected member variable begins with a singleunderscore.3 This is the only underscore in such a name (see Rule 31).Rule 34The names of constants and enumeration values are all uppercase. In namesthat consist of more than one word, these words are separated by underscorecharacters.Rule 35Encapsulate global variables and constants, enumerated types, and typedefsin a class.Recommendation 5Names should be self-descriptive yet as brief as possible. Cryptic abbreviatednames are as hard to read as well as too long ones.Recommendation 6Names should be pronounceable. It is hard to discuss something that cannotbe pronounced.Recommendation 7Names should not include abbreviations that are not generally accepted. Alist of generally accepted abbreviations can be found in the Appendix.Recommendation 8A variable holding a pointer should be prefixed with “p”. A value holding areference should be prefixed with “r”. A variable holding an iterator shouldbe prefixed with “it”.Recommendation 9Apart from the cases in Recommendation 8, avoid encodings in names.Encoded names require deciphering. Especially, avoid type-encoded variablenames (Petzold-style Hungarian notation like lpcszName).3 There are different opinions regarding the validity of leading underscores in class member names. The C++ standard explicitly states that leading underscores are not allowed in global names. Class members are not global, therefore this rule does not apply to them. Experience with a variety of different compilers does not show any problems. A commonly used alternative is to append an underscore at the end of a member variable name.Recommendation 10Be consistent. If something is a name it should be a name everywhere it isused (not, e.g. an id somewhere else).Example 3Identifier names in a class declaration (comments have been removed): class Net_API HTTPRequest: public HTTPMessage{public:HTTPRequest();HTTPRequest(const std::string& version);HTTPRequest(const std::string& method, const std::string& uri);virtual ~HTTPRequest();void setMethod(const std::string& method);const std::string& getMethod() const;void write(std::ostream& ostr) const;void read(std::istream& istr);static const std::string HTTP_GET;static const std::string HTTP_HEAD;static const std::string HTTP_PUT;static const std::string HTTP_POST;static const std::string HTTP_OPTIONS;static const std::string HTTP_DELETE;static const std::string HTTP_TRACE;static const std::string HTTP_CONNECT;private:enum Limits{MAX_METHOD_LENGTH = 32,MAX_URI_LENGTH = 4096,MAX_VERSION_LENGTH = 8};std::string _method;std::string _uri;};6Style6.1ClassesRule 36The public, protected, and private sections of a class are declared inthat order (the public section is declared before the protected sectionwhich is declared before the private section).Rule 37With the exception of templates where current compiler technologycommands it, member functions are never defined within the classdefinition.Rule 38Inline functions are defined in a separate block following the classdeclaration.Recommendation 11If a member variable has an accessor, but not a mutator, the accessor has thesame name as the variable, sans the underscore prefix. If a member variablehas both an accessor and a mutator, the accessor name has a get prefix andthe mutator name has a set prefix.By placing the public section first, everything that is of interest to a user isgathered in the beginning of the class definition. The protected section maybe of interest to designers when considering inheriting from the class. Theprivate section contains details that should have the least general interest.A member function that is defined within a class definition automaticallybecomes inline. Class definitions are less compact and more difficult to readwhen they include definitions of member functions. It is easier for an inlinemember function to become an ordinary member function if the definitionof the inline function is placed outside of the class definition.Example 4Defining an inline function:class Foundation_API UUID{public:...bool operator == (const UUID& uuid) const;bool operator != (const UUID& uuid) const;bool operator < (const UUID& uuid) const;bool operator <= (const UUID& uuid) const;bool operator > (const UUID& uuid) const;bool operator >= (const UUID& uuid) const;...};//// inlines//inline bool UUID::operator == (const UUID& uuid) const{return compare(uuid) == 0;}inline bool UUID::operator != (const UUID& uuid) const{return compare(uuid) != 0;}...Example 5Accessors and mutators:class Property{public:Property(const std::string& name);Property(const Property& prop);~Property();Property& operator = (const Property&);const std::string& name();void setValue(const std::string& value);const std::string& getValue() const;private:Property();std::string _name;std::string _value;};6.2FunctionsRecommendation 12When declaring functions, the leading parenthesis and the first argument (ifany) are written on the same line as the function name. If space andreadability permit, other arguments and the closing parenthesis may also bewritten on the same line as the function name. Otherwise, each additionalargument is written on a separate line, indented with a single tab (with theclosing parenthesis directly after the last argument).Example 6Long function declarations:DateTime& assign(int year,int month,int day,int hour = 0,int minute = 0,int second = 0,int millisecond = 0,int microseconds = 0);Recommendation 13Always write the left parenthesis directly after a function name. There is nospace between the function name, the opening brace and the first argumentdeclaration. Also there is no space between the last argument and the closingparenthesis.6.3TemplatesRule 39The template keyword, together with the template argument list, is writtenon a separate line before the following class or function definition.6.4Compound StatementsRecommendation 14Braces ("{}") enclosing a block are placed in the same column, on separatelines directly before and after the block.The placement of braces seems to have been the subject of the greatestdebate concerning the appearance of both C and C++ code. We recommenda style that, in our opinion, gives the most readable code. Other styles maywell provide more compact code.6.5Flow Control StatementsRecommendation 15There is always a space between the flow control statement’s keyword andthe opening parenthesis of the control expression. There is no space betweenthe opening parenthesis and the expression. There is also no space betweenthe expression and the closing parenthesis.Recommendation 16The flow control primitives if, else, while, for and do should befollowed by a block, even if it is an empty block, or consisting of only onestatement.At times, everything that is done in a loop may be easily written on one linein the loop statement itself. It may then be tempting to conclude thestatement with a semicolon at the end of the line. This may lead tomisunderstanding since, when reading the code, it is easy to miss such asemicolon. Also, the semicolon could be deleted by accident, leading to ahard-to-find bug. It seems to be better, in such cases, to place an emptyblock after the statement to make completely clear what the code is doing.Even more better is to avoid this style altogether.In certain cases, a code that is more compact might be better readable thancode with many blocks containing only a single statement. As a general rule,readability must always be preferred to strict style adherence.Example 7Blocks and single statements:int ASCIIEncoding::convert(int ch, unsigned char* bytes, int length) const {if (ch >= 0 && ch <= 127){*bytes = (unsigned char) ch;return 1;}else return 0;}Example 8Single-line flow control statements can improve readability by keeping thecode more compact:void MessageHeader::splitParameters(const std::string& s,std::string& value,NameValueCollection& parameters){value.clear();parameters.clear();std::string::const_iterator it = s.begin();std::string::const_iterator end = s.end();while (it != end && isspace(*it)) ++it;while (it != end && *it != ';') value += *it++;Poco::trimRightInPlace(value);if (it != end) ++it;splitParameters(it, end, parameters);}6.6Pointers and ReferencesRecommendation 17The dereference operator “*” and the address-of operator “&” should bedirectly connected with the type names in declarations and definitions.The characters “*” and “&” should be written together with the types ofvariables instead of with the names of variables in order to emphasize that。

代码规范范本

代码规范范本

代码规范范本一、代码命名规范在编写代码时,为了提高代码的可读性和可维护性,需要遵守一定的命名规范。

以下是一些常见的命名规范示例:1. 变量和函数命名- 使用驼峰命名法:变量名和函数名首字母小写,后续单词首字母大写,例如:myVariable, getUserName。

- 变量名和函数名应该具有描述性,避免使用单个字符或过于简单的命名。

2. 常量命名- 全部大写,单词间使用下划线分隔,例如:MAX_LENGTH, PI。

3. 类命名- 使用帕斯卡命名法:每个单词的首字母都大写,例如:MyClass, UserService。

4. 文件命名- 使用有意义且描述性的名称,使用小写字母和连字符分隔单词,例如:user-service.js, data-util.py。

二、代码缩进和格式化规范良好的代码缩进和格式化可以使代码更易于理解和维护。

以下是一些常见的缩进和格式化规范:1. 使用合适的缩进- 使用四个空格进行缩进,不要使用制表符。

2. 代码块的大括号- 左大括号应该与语句在同一行,并且不应单独占用一行。

- 右大括号应该独占一行,且与前面的代码对齐。

3. 行长度限制- 代码行长度应保持在80个字符以内,可以适当增加行数限制。

4. 代码注释- 对于关键代码逻辑,应添加适当的注释,以便他人理解代码意图。

三、错误处理规范良好的错误处理可以提高代码的健壮性和可靠性。

以下是一些常见的错误处理规范:1. 异常处理- 对于可能出现异常的代码块,应该使用try-catch语句进行异常处理,并适当给出错误提示。

2. 日志记录- 当发生错误或异常时,应该使用日志记录相应的错误信息,以便后续排查和修复错误。

四、命名规范为了保持代码的一致性和易读性,以下是一些通用的命名规范:1. 使用有意义的名称- 命名应该具有描述性,能够清楚地表达变量、函数和类的含义。

2. 避免使用缩写和简写- 除非是通用的缩写词,否则应避免使用缩写和简写,以避免理解上的混淆。

ABAP代码规范

ABAP代码规范

ABAP代码规范ABAP代码规范⽬录命名1. 使⽤描述性名称正例:DATA customizing_entries TYPE STANDARD TABLE ...反例:DATA iso3166tab TYPE STANDARD TABLE...2. 优先使⽤解决⽅案域和问题域术语在任何情况下,请勿尝试组成⾃⼰的语⾔。

3. 使⽤复数正例:DATA countries TYPE STANDARD TABLE ...反例:DATA country TYPE STANDARD TABLE ...4. 使⽤易读的名称宁可使⽤detection_object_types也不实⽤dobjt.5. 杜绝完全不规范的缩写,避免望⽂不知义反例:cust"customizing", "customer", or "custom"?6. 在各处使⽤相同的缩写例如,始终将“检测对象类型”缩写为dobjt,⽽不是混合dotype,detobjtype等7. 类使⽤名词,⽅法使⽤动词8. ⽤is_和has之类的动词开始布尔⽅法9.避免使⽤⼲扰词data,info,object等10. ⿎励您摆脱所有编码前缀例如,result = a + b.⽽不是rv_result = iv_a + iv_b.语法1. ⾯向对象优先于过程编程2. 偏爱功能性⽽⾮程序语⾔构造" MOVE 'A' TO variable.DATA(variable) = 'A'." ADD 1 TO index.index += 1. " 版本 >= 7.54“index = index + 1. " 版本 < 7.54" LOOP AT input INTO DATA(row)." INSERT row-text INTO TABLE result." ENDLOOP.result = VALUE #( FOR row IN input ( row-text ) )." READ TABLE value_pairs INTO DATA(line) WITH KEY name = 'A'.DATA(line) = value #( value_pairs[ name = 'A' ] optional )." READ TABLE value_pairs TRANSPORTING NO FIELDS WITH KEY name = 'A'. " DATA(exists) = xsdbool( sy-subrc = 0 ).DATA(exists) = xsdbool( line_exists( value_pairs[ name = 'A' ] ) ).IF line_exists( value_pairs[ name = 'A' ] )." CREATE OBJECT object TYPE /dirty/my_class.DATA(object) = NEW /clean/my_class( ).3. 在SQL中使⽤@区分程序变量和数据库列SELECT *FROM spfliWHERE carrid = @carrid ANDconnid = @connidINTO TABLE @itab.4. 在适当的地⽅使⽤设计模式常量1. 使⽤常量代替魔术数字正例:IF abap_type = cl_abap_typedescr=>typekind_date.反例:IF abap_type = 'D'.2.优先于枚举类⽽不是常量接⼝CLASS /clean/message_severity DEFINITION PUBLIC ABSTRACT FINAL.PUBLIC SECTION.CONSTANTS:warning TYPE symsgty VALUE 'W',error TYPE symsgty VALUE 'E'.ENDCLASS."orCLASS /clean/message_severity DEFINITION PUBLIC CREATE PRIVATE FINAL.PUBLIC SECTION.CLASS-DATA:warning TYPE REF TO /clean/message_severity READ-ONLY,error TYPE REF TO /clean/message_severity READ-ONLY." ...ENDCLASS."反例INTERFACE /dirty/common_constants.CONSTANTS:warning TYPE symsgty VALUE 'W',transitional TYPE i VALUE 1,error TYPE symsgty VALUE 'E',persisted TYPE i VALUE 2.ENDINTERFACE.3.如果不使⽤枚举类,则将常量分组CONSTANTS:BEGIN OF message_severity,warning TYPE symsgty VALUE 'W',error TYPE symsgty VALUE 'E',END OF message_severity,BEGIN OF message_lifespan,transitional TYPE i VALUE 1,persisted TYPE i VALUE 2,END OF message_lifespan.变量1. 优先选择内联⽽不是预先声明DATA(name) = 'something'."不要在可选分⽀中声明内联:IF has_entries = abap_true.DATA(value) = 1.ELSE.value = 2.ENDIF."反例:DATA name TYPE seoclsname.name = 'something'.2. 优先选择REF TO⽽不是 FIELD-SYMBOLThis section ."1LOOP AT components REFERENCE INTO DATA(component)."2LOOP AT components ASSIGNING FIELD-SYMBOL(<component>).除⾮你需要使⽤以下:ASSIGN generic->* TO FIELD-SYMBOL(<generic>).ASSIGN COMPONENT name OF STRUCTURE structure TO FIELD-SYMBOL(<component>). ASSIGN (class_name)=>(static_member) TO FIELD-SYMBOL(<member>).3. 结构赋值structure-type = 'A'.structure-id = '4711'.or even betterstructure = VALUE #( type = 'A'id = '4711' ).表1. 使⽤正确的表格类型通常,将HASHED表⽤于⼤型表,这些⼤型表仅⼀步就被填充,从不修改,并且经常通过键读取。

编码规范模板

编码规范模板

编码规范模板一、引言编码规范是软件开发中至关重要的一环,它规定了开发人员在编写代码时应遵循的规范和标准。

一个良好的编码规范可以提高代码的可读性、可维护性和可扩展性,有助于团队协作和项目的顺利进行。

本文将介绍一套编码规范模板,以供开发人员参考和使用。

二、命名规范1. 变量名和函数名应采用有意义的英文单词或缩写,使用驼峰命名法,避免使用拼音或无意义的缩写。

2. 类名应采用大写字母开头的驼峰命名法,避免使用下划线。

3. 常量名应全部大写,单词之间用下划线分隔。

4. 文件名应采用小写字母,单词之间用下划线分隔。

三、代码风格1. 缩进统一使用四个空格,不使用制表符。

2. 每行代码长度不超过80个字符,超过时应进行换行。

3. 每个函数之间应空一行,使代码结构清晰。

4. 注释应详细描述代码的功能和实现方法,帮助其他开发人员理解代码。

5. 代码中不应出现无用的注释和调试信息,避免影响代码的可读性。

6. 操作符前后应添加空格,使代码更易读。

四、错误处理1. 所有的错误和异常应该被捕获和处理,避免程序崩溃或出现不可预料的错误。

2. 错误信息应该清晰明了,包含错误的原因和解决方法。

3. 错误处理的代码应与业务逻辑分离,使代码更加清晰和易于维护。

五、性能优化1. 避免不必要的循环和递归,尽量减少代码的执行时间和内存消耗。

2. 使用合适的数据结构和算法,提高代码的执行效率。

3. 避免频繁的IO操作和数据库查询,尽量减少系统的负载。

六、安全性1. 输入验证是保证系统安全的重要环节,应对用户输入进行严格的验证和过滤。

2. 避免使用硬编码的密码和敏感信息,应使用安全的存储和传输方式。

3. 对于涉及到用户隐私的数据,应采取加密和权限控制等措施,保护用户的个人信息。

七、版本控制1. 使用版本控制系统管理代码,避免代码丢失或被覆盖。

2. 每次提交代码时,应写明修改的内容和原因。

3. 避免在主分支上直接提交代码,应使用分支进行开发和测试。

abap项目经验模板

abap项目经验模板

abap项目经验模板
ABAP项目经验模板可以根据个人的实际项目经验进行构建,
以下是一个可能的ABAP项目经验模板的示例:
项目名称:ABAP系统优化项目
项目描述:本项目旨在对公司现有的ABAP系统进行优化,
提高系统的效率和性能,减少系统运行时间。

项目职责:
1. 分析现有系统的性能瓶颈和问题,并提出优化方案和解决方案。

2. 根据需求设计和开发ABAP程序,以优化现有系统的性能。

3. 优化数据库查询和数据传输,以减少系统运行时间。

4. 与团队成员进行合作,对代码进行审查和优化,以提高代码质量和可维护性。

5. 对系统进行测试和调试,确保优化后的系统正常运行。

项目成果:
1. 优化后的系统运行时间减少了30%,大大提高了用户体验
和生产效率。

2. 通过优化数据库查询和数据传输,减少了系统对数据库的负载,提高了系统的稳定性和可靠性。

3. 通过优化代码,减少了系统的bug数量,提高了系统的可维护性和可扩展性。

4. 将优化方案和解决方案整理成文档,作为项目成果和经验总结。

项目技术和工具:
1. ABAP编程语言
2. SAP NetWeaver系统
3. SAP HANA数据库
4. ABAP调试器和性能分析工具
以上仅是一个简单的ABAP项目经验模板示例,根据个人的实际项目经验和职责,可以添加或修改相应内容。

ABAP编码规范 V1.0

ABAP编码规范 V1.0

ABAP编码规范Version 1.0变更履历审批记录此文档的目的此文档记述了开发除标准SAP之外的ABAP程序的规则。

此文档是根据SAP R/3 Version ECC6.0 编写而成的。

此开发规则如有问题或不足的地方,请速向研发部负责人提出意见和建议。

目录1、读取数据库的方式 (4)1.1、不能单次单条访问数据库的表,禁止使用SELECT----ENDSELET,要使用SELECT …..INTOTABLE ITAB (4)1.2、用多少字段,就写多少字段,禁止用SELECT * (4)1.3、在LOOP中,一般不要使用查询数据库表的语句,要将数据先发到内表,再通过READ TABLE的方式 (4)1.4、在WHERE语句中尽量使用数据库表的索引, WHERE条件语句中指定Key Field时,必须根据Dictionary设定的顺序。

(5)1.5、要将输入屏幕上的条件尽量用在SELECT语句中的WHERE条件里,可以将不必要的数据甩选出来 (6)1.6、对于是否使用INNER JOIN,是要考虑到表的数据量,但原则上不允许3个以上的表内联,要通过分析,得出最优的方案,下面是分析的过程 (8)1.7、对于更新数据库表的语句,尽量用MODIFY …..FROM TABLE.对整个表进行更新,不要一条的,对于TABLE很大的,超过10w条的,需要分开更新,对于更新表没有COMMIT WORK的,需要每1000条更新数据库一次. (10)1.8、对于使用for all entries in itab的,在SELECT 之前,需要对itab进行判断是否为空 (10)2、内表处理的方式 (11)2.1、 Copy Internal Table时,使用APPEND LINES OF命令。

(11)2.2、根据特定条件对Internal Table进行LOOP时,使用WHERE语句而不用CHECK语句。

(11)2.3、 Update Internal Table的Item时,使用MODIFY命令。

SAP最佳业务实践-ABAP开发规范

SAP最佳业务实践-ABAP开发规范

Han Consulting (China) Ltd. 2006 Copyright
AB开头,变量的定义、子程 序的调用、关键的逻辑运算式必须进行相应的注解。注解要用中 文。 例如: DATA: BEGIN OF ITAB_MARA OCCURS 0, MATNR LIKE MARA-MATNR, MEINS LIKE MARA-MEINS, MATKL LIKE MARA-MATKL, MTART LIKE MARA-MTART, MAKTX LIKE MAKT-MAKTX, END OF ITAB_MARA. PERFORM GET_DATA.
TOP-OF-PAGE. PERFORM OUTPUT_TITLE. AT SELECTION-SCREEN. PERFORM CHECK_MATNR. START-OF-SELECTION. PERFORM GET_DATA.
"调用输出抬头子程序
"调用检查物料号子程序
"调用获取数据子程序 "调用输出数据子程序 "输出抬头子程序
c.
d.
e.
f.
Han Consulting (China) Ltd. 2006 Copyright
Han Consulting (China) Ltd. 2006 Copyright
一、关于开发相关的命名规范
2.
开发类(Package)的命名规则: ZDEV: 所有开发都存放在该开发类中.
3. 事务代码(Transaction)的命名规则: Z XXXXX(与程序的后五位命名规则相同) XX: 前面两个XX代表的是模块名称,如:MM,SD,FI, CO,PP,QM等。 XXX: 后面三个XXX是序列号,事务码的命名以Z开头后面 加序列号,序列号可通过SE93来查询。

ABAP的代码规范标准 (某公司使用)

ABAP的代码规范标准 (某公司使用)

ABAP的代码规范标准 (某公司使用)2008年02月06日星期三 19:02ABAP代码编写要求1、单元格式********************************************************************* **** Copyright 2006 C-BonsWuhan ** All RightsReserved **----------------------------------------------------------------------** Program Name :ZXXXXX ** Project : C-Bons SAP ImplementationProject ** ProgramTitle: ** Created by :DEVXX ** Created on :2006/02/18 ** Version :1.0 ** FunctionDescription: ** **----------------------------------------------------------------------** Data TableList: **如维护操作的表,数据计算来源等表*----------------------------------------------------------------------** Refrence TableList: **如联络处描叙,输入帮助等用到的表*----------------------------------------------------------------------** ModificationLog: ************************************************************************** Date Programmer Correction Number DesingDoc Number ** YYYY/MM/DDXXXXXXXX DEVK9nnnnnn ********************************************************************** ***注意:版本修改信息中设计文档版本有对应的文档则必须填写。

ABAP编码规范

ABAP编码规范

ABAP编码规约更改履历目录1.目的2.前提条件3.以后编码规约1.目的本文档是规定使用ABAP语言R/3Add・On开发编码的标准化。

其目的是使程序标准一致。

2.前提条件本文档是针对使用R/3リリース4.70(Enterprise)のABAP语言的程序(Report、Dynpro、功能模块、Class、SAPscript、SmartForms)3.Source Header用以下的书写格式书写。

(英数字是半角)************************************************************************ ** Program ID : ZZTEMP01** Program Detail : xxxxxxxxxxxx** Author : xxxxxxxxxxxx(NTT DATA ITEC)** Creation Date : yyyy.mm.dd**** Modifications :** No. Date Author** Description** xxxx-xxxxx yyyy.mm.dd xxxxxxxxxxxx** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx **** xxxx-xxxxx yyyy.mm.dd xxxxxxxxxxxx** xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ************************************************************************ REPORT ZZTEMP01 MESSAGE-ID 00NO STANDARD PAGE HEADINGLINE-SIZE 170LINE-COUNT 58(2).4.定义部分4-1.表定义定义表名。

ABAP开发规范

ABAP开发规范

ABAP开发规范目录1ABAP对象命名规范 (6)1.1开发类 (6)1.2程序名 (6)1.3数据字典 (7)1.3.1表/结构/数据元素/域 (7)1.3.2表类型 (7)1.3.3范围表类型 (7)1.3.4搜索帮助 (7)1.3.5锁对象 (7)1.4函数组及函数模块 (8)1.4.1函数组 (8)1.4.2函数模块 (8)1.5BADI实施 (8)1.6消息类 (9)1.7类 (9)1.8SMARTFORM (9)1.9自定义权限对象 (9)1.10E NHANCEMENT PROJECT (9)1.11W EB S ERVICE命名 (9)1.12P ROXY 命名 (10)2通用ABAP代码规范 (11)2.1代码格式 (11)2.1.1Pretty Printer (11)2.1.2Spacing (11)2.1.3代码行 (12)2.1.4代码注释 (13)2.2程序变量 (14)2.2.1变量使用说明 (14)2.2.2命名规范 (14)2.2.3常量 (15)2.2.4全局变量 (17)2.2.5内表/结构 (18)2.2.6文本变量 (20)2.3常用语句格式 (21)2.3.1Message (21)2.3.2Call function (21)2.3.3Perform (22)2.3.4Select (22)2.3.5IF (23)2.3.6CHECK (24)2.3.7LOOP (25)2.3.8READ (25)2.3.9WHILE (25)2.3.10DO (26)2.3.11CASE (26)2.3.12CONCATENATE (27)3报表程序规范 (29)3.1程序结构 (29)3.1.1数据初始化子程序 (31)3.1.2数据存取子程序 (32)3.1.3数据处理子程序 (32)3.1.4数据组合子程序 (33)3.1.5数据输出子程序 (35)4子程序规范 (36)4.1模块化代码 (36)4.2参数 (37)4.2.1参数命名 (37)4.2.2参数类型 (37)4.2.3Table参数 (37)4.2.4参数个数要求 (38)4.2.5参数对齐 (40)4.3子程序结构 (40)4.4P ERFORM语句 (41)4.5子程序注释 (42)5功能模块规范 (43)5.1函数模块结构 (43)5.2函数返回值 (43)5.3函数调用 (43)6屏幕对话程序规范 (45)6.1屏幕逻辑流结构 (45)6.2PAI/PBO/POV模块 (46)6.2.1User-command模块 (47)7BADI增强规范 (49)8CMOD增强规范 (51)9BTE增强规范 (52)10程序性能相关代码规范 (53)10.1SQL语句 (53)10.2内表操作 (58)10.3其他语句 (66)10.3.1CASE语句 (66)10.3.2WHILE语句 (67)10.3.3比较语句 (67)附录 (68)1.1SAP业务模块命名表 (68)1.2数据字典对象类型命名表 (68)版本控制1ABAP对象命名规范1.1开发类Z<XX>_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文1.2程序名Z<XXY>_<Short text><XX>-业务模块,见附录1<Y>-程序类型代码<Short text>-简短描述,英文注:用于特定程序的include程序按以下方式命名:<主程序名>_<Xnn>, nn-两位流水码1.3数据字典1.3.1表/结构/数据元素/域Z<TXX>_<Short text><T>-数据字典对象类型,参见附表2<XX>-业务模块,见附录1<Short text>-简短描述,英文1.3.2表类型[Z_]<structure >_T[Z_]-如果< structure >名称以Z开头,则可省略<structure>-使用的结构名1.3.3范围表类型[Z_]<dataelement>_T[Z_]-如果<dataelement>名称以Z开头,则可省略<dataelement>-使用的数据元素名1.3.4搜索帮助Z<XX>_SH_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文1.3.5锁对象E[Z] <tablename>[Z]-如果<tablename>名称以Z开头,则可省略<tablename>-表名1.4函数组及函数模块1.4.1函数组Z<XX>_<nn><XX>-业务模块,见附录1<nn>-两位流水码1.4.2函数模块<FunctionGroup>_<Short text><FunctionGroup>-函数模块所在的函数组名< Short text >-函数基本功能的短文本1.5BADI实施a) Custom Business Add-inZ<XX>_BADI_< Short text><XX>-业务模块,见附录1< Short text >-BADI 定义的名称b) Custom Business Add-in ImplementationZ<XX>_BADIM_< Short text><XX>-业务模块,见附录1< Short text >-BADI 定义的名称c) SAP Business Add-in ImplementationZ<XX>_IMPL_< Short text><XX>-业务模块,见附录1< Short text >-BADI 定义的名称d) SAP BADI Method< Short text >-自由定义,但有意义,简单描述该方法实现的功能1.6消息类Z<XX>_<nn><XX>-业务模块,见附录1< Short text >-简短描述,英文1.7类Z<XX>_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文1.8SMARTFORM[Z]<Reportname>_<Short text>[Z]-如果<Reportname>名称以Z开头,则可省略<Short text>-简短描述,英文1.9自定义权限对象Z<XX>_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文1.10Enhancement projectZ<XX><nnnn><XX>-业务模块,见附录1<nnnn>-四位流水码1.11Web Service命名ZWS<XX>_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文1.12Proxy 命名Z<XX>_<Short text><XX>-业务模块,见附录1<Short text>-简短描述,英文2通用ABAP代码规范2.1代码格式2.1.1 Pretty Printer所有程序代码应使用pretty printer功能进行规范,包含:代码缩进;关键字大写,其余小写。

ABAP的代码规范标准

ABAP的代码规范标准
*----------------------------------------------------------------------** INTERNAL TABLES AND WORK AREAS **----------------------------------------------------------------------*DATA: I_AUFK TYPE T_AUFK OCCURS 0, WA_AUFK TYPE T_AUFK.
*----------------------------------------------------------------------** GLOBAL VARIABLES **----------------------------------------------------------------------*DATA: G_FLAG.
子函数的格式************************************************************************* Form Name : XXXXX ** Created by : DEVXX ** Created on : 2006/02/18 ** Form Description: ** **----------------------------------------------------------------------**参数说明 ** **----------------------------------------------------------------------** Modification Log: ************************************************************************** Date Programmer Description ** YYYY/MM/DD XXXXXXXX *************************************************************************(注:标为蓝色部分可以省略)
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

目录
1SAP模块清单 (2)
2程序类型 (2)
3命名规范 (3)
3.1程序中变量命名 (3)
4程序说明 (5)
4.1程序头部注释 (5)
4.2子程序头的注释 (6)
4.3代码块的注释 (6)
4.4在线文件 (6)
1SAP模块清单
2程序类型
3命名规范
3.1程序中变量命名
ABAP Queries
Program Attributes
4程序说明
4.1程序头部注释
* PROGRAM ID/NAME: DATE WRITTEN:
* AUTHOR'S NAME: LAST UPDATE:
* PROGRAM TITLE:
* PROJECT NAME:
* VERSION: 1.0
*------------------------------------------------------------------*
* DESCRIPTION:
*------------------------------------------------------------------*
* INCLUDE: N/A
*------------------------------------------------------------------*
* CALLS: (RFC AND BPI)
*------------------------------------------------------------------*
* TABLE:
*------------------------------------------------------------------*
* CHANGE HISTORY
*------------------------------------------------------------------*
* DATE | PROGRAMMER | Flag
***DESCRIPTION
*********************************************
(说明:Flag是用来查找本次所修改的所有内容的依据,建议用M.YYYY.MM.DD --- M (Modify)YYYY (年)MM(月)DD(天),在程序修改起始位置前一行加上:*BO – M.YYYY.MM.DD Description ,在程序修改结尾加上*EO – M.YYYY.MM.DD Description )
4.2子程序头的注释
*********************************************
*功能说明 *
*参数说明 *
*********************************************
4.3代码块的注释
*********************************************
*功能说明 *
*********************************************
4.4在线文件
∙Purpose of the Program: 程序的目的
∙Inputs to the Program: 输入参数的说明
∙Processing Description: 粗线条的处理说明(high level description )
∙Outputs from the Program: 输出结果说明。

相关文档
最新文档