ABAP中的代码重复使用

文章目录

1 Introduction

ABAP offers various options for avoiding such code duplicates and for giving a piece of program code a name under which it can be called:

Form routines (these are officially obsolete)
Function modules (this is what this is article is about) and
global classes and their methods. In most cases these are the better choice. A class can have multiple methods. This is a better structure than to have a large number of function modules that have little connection with each other.

2 Detail

Use ABAP Development Tools for Eclipse (ADT)
Is there an alternative to ADT? Nobody would use Notepad to write Java… Seriously: refactoring capabilities (rename method!) as well as ABAP Doc comments are essential features for us. Thus SE80 is not an option.

Put Everything in Classes and Methods
Do not place functional code in programs (reports) or function groups/modules. As we come from Java, this is quite obvious. We use reports and function modules only if there is no other solution possible, e.g. for providing an RFC interface. And also in the rare cases where we had to leave the OO-world, these classical ABAP only serve as a proxy delegating to the actual implementation in a class.

Structure the Source Code by OO Concepts only
Especially, do not use includes. In our own codebase, there was only one exception: When we migrated our code from Z to /CQSE/ namespace, we wanted to keep the old Z programs as legacy interface for a while. Thus the Z programs just included the new /CQSE/ programs, we preferd this approach over code duplication.

Rules for Naming and Usage of Identifiers
In ABAP, it is common to use type prefixes in identifier names (Hunga

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值