zoukankan      html  css  js  c++  java
  • PA教材提纲 TAW101

    Unit1 SAP systems(SAP系统)

    1.1 Explain the Key Capabilities of SAP NetWeaver(解释SAP NetWeaver的关键能力)

    Repository里显示的都是SAP系统里的东西

    SAP Netweaver Capabilities

    • User productivity(用户生产力)
    • Business Intelligence
    • Business Process Composition(即业务组合,用户使用composite applications而不是code-based approach)
    • Enterprise Information Management
    • Service-Oriented Architecture Middleware(SOA)
    • Custom Development
    • Security and Identity Management
    • Application Lifecycle Management(ALM)

    1.2 Explain the Architecture of an SAP System Application Server(AS) ABAP and Application Server(AS) Java(解释SAP AS ABAP和AS Java的结构)

    Single-Tier Configuration: Only one computer performs all the processing tasks(即一台机器同时担任展示层presentation processes、应用层application processes、数据库层database processes的功能,网络层internet交给互联网)

    Two-Tier Configuration: 即presentation服务器负责展示层,应用服务器负责应用层和数据层,网络层交给互联网

    Three-Tier Configuration: 除网络层交给互联网之外,其它层都有自己的服务器

    Multi-Tier Configuration: 各层都有自己的服务器,但是展示层使用的是web browser

    增加Tier,有利于增加可扩展性scalability和负载均衡load balancing,但是不利于简化管理simpler administration

    SAP systems: 一个SAP solution,由很多instance组成;

    SAP instances: 即application servers,由一个Central Service Instance(SCS)和其它普通instances组成。

    Unit2 SAP Portfolio Overview(SAP产品集概览)

    2.1 Identifying the Components of the SAP Applications Portfolio(识别SAP产品集的组件)

    Key Areas of SAP:

    • ON DEVICE: Extending the reach of customers(移动设备)
    • ON DEMAND: Innovating through extensions(可定制增强)
    • ON PREMISE: Scaling the core businesses of customers(预定义核心功能)

    SAP Business One: 专为小型企业(small businesses)设计,支持ON PREMISE(本地实施)也支持Cloud,自开发性较弱;

    SAP Business ByDesign: 为小型或中型企业设计,云产品(cloud based on-demand software-as-a-service, SAAS),只支持云上自开发;

    SAP Business All-in-One: 简化版Business Suite,限定一个公司代码,唯一含有industry specific(行业定制解决方案)country specific(国家定制解决方案)的中小企业产品;

    SAP Business Suite: 为大型企业设计。

    Architecture of SAP Business Suite(Business Suite结构)

    1. Core applications(核心功能),即SAP ERP、SAP CRM、SAP SCM、SAP SRM、SAP PLM等

    2. Industry applications(行业定制)

    3. Supplementary applications(企业定制)

    4. Enhancement Packages

    Solutions(解决方案)> Applications(应用系统)> Components(组件,计价和发货的最小单位)

    SAP S/4HANA name:

    • S for both simple and suite
    • full name is SAP Business Suite 4 SAP HANA
    • the solution is named SAP S/4HANA because it runs on HANA natively and is highly optimized for SAP HANA(与旧BI定期从ERP抽数相比,NANA是实时取数的)

    SAP S/4HANA redefined the following business practices:

    • Business models
    • Business decisions
    • Business processes

    SAP S/4HANA reimagined:

    • Reimagined User Experience: Function oriented功能导向, Role oriented角色导向
    • Reimagined System Configuration: Cloud云端简化配置, On Premise非云端产品依然复杂
    • Reimagined Data Models: Traditional databases, in-memory platform

    针对三类用户的升级路线(注意:S/4要发挥最好性能只能用HANADB,而不能用第三方DB)

    • 新用户:实施最新版本ON-PREMISE->实施云系统->实施混合系统(Hybrid)
    • 使用Business Suite on any DB的用户:迁移到Business Suite on HANA(migrate)并升级->实施云系统->实施混合系统(Hybrid)
    • 使用Business Suite on HANA的用户:升级到新版本->实施云系统->实施混合系统(Hybrid)

    Unit3 Navigation Basics(导航基础)

    3.1 Navigating with SAP Graphical User Interface (GUI) for Windows in AS ABAP Systems(Windows环境下ABAP系统用户界面导航)

    Clients: correspond to independent business entities and can be used to represent a company in an SAP system.

    User Data: in SAP systems is called the user master data

    SAP Easy Access Menu(进入后初始界面)

    • Favorites list收藏夹
    • Role-based menu用户菜单(可以按钮切换成SAP菜单)

    Screen Elements in the SAP GUI(注意,事务代码GUIT可以查看全部屏幕元素)

    • Command field命令字段
    • Menu bar菜单栏(即User、Edit、Systems、Help等)
    • System toolbar系统工具栏(即客户端带有的保存、返回、上一层、终止等按钮)
    • Title bar标题栏
    • Application toolbar应用工具栏(即程序设置的按钮)
    • Tab pages页签
    • Input field输入字段
    • Status bar状态栏(用于成功、警告、错误等提示信息)

    You can use the F1 key on the command field to display the following possible entries:

    • /N to cancel the current transaction
    • /NXXXX to call transaction XXXX
    • /O to display the overview of the SAP GUI sessions展示当前开了几个窗口
    • /OXXXX to call transaction XXXX in a new window
    • /NEND to end the log on session with a confirmation dialog box
    • /NEX to end the log on session without a confirmation dialog box
    • /I to delete the window you are currently using
    • /H 进入调试模式

    Press the key list button in the command field shows the last 15 transactions that you have entered.

    本节其它实用要点:

    • 对于structure可以用检查表确认字段位置,也可以找到域,然后用where-used-list查看
    • F4帮助(Search Help)的设置在Help->Settings中

    Unit4 SAP User Interfaces(SAP用户界面)

    4.1 Accessing AS ABAP Systems with SAP GUI(通过SAP GUI访问AS ABAP系统)

    Most SAP applications are based on SAP NetWeaver AS ABAP: SAP ERP, SAP CRM, SAP SCM, SAP SRM, SAP PLM

    Some SAP applications and components are based on SAP NetWeaver AS Java: SAP Enterprise Portal, SAP Process Integration, SAP Composition Environment

    一些面向最终用户的途径

    SAP ERP: SAP GUI for Windows or SAP GUI for HTML

    SAP Business Warehouse (BW): Browser-based interface

    SAP Business ByDesign: Browser-based interface, software as a service

    SAP Business All-in-One solutions: SAP NetWeaver Business Client

    SAP S/4HANA: SAP Fiori

    SAP GUI for Windows is written in C or C++.

    Favorites Menu收藏夹

    • 右键加入项目,有完整路径
    • 拖入项目,无完整路径
    • 支持上传下载

    重要事务代码

    • 事务代码SEARCH_SAP_MENU,查看SAP菜单中的事务代码及其描述
    • 事务代码SDMO,根据描述返查事务代码
    • 事务代码SEARCH_USER_MENU,查看用户菜单中的事务代码及其描述
    • 事务代码SE16SE11,查看数据表,事务代码数据存放在TSTCT表中

    Unit5 System Core(系统内核)

    5.1 Explaining AS ABAP and AS Java System Architecture(解释AS ABAP和AS Java的结构)

    三种SAP NetWeaver AS

    • AS ABAP system
    • AS Java system
    • AS ABAP + Java system, 通过SAP Java Connector(JCo)连接

    AS ABAP7.0x版本与后续版本没有结构变化,但有称呼变化:

    • central instance(7.0及以前版本): Primary Application Server (PAS)(7.1及以后版本)
    • dialog instance(7.0及以前版本): Additional Application Server (AAS)(7.1及以后版本)
    • The database can be installed on a different host to the central instance.(数据库可以不和central instance在一个服务器中)
    • 一个主机host可以运行多个实例instances,实例名称组成为主机名+数据库名+系统编号

    AS ABAP 7.1x及以后版本的变化:

    • 引入了ABAP Central Services (ASCS),该模块将原来central instance中的Message Server和Enqueue Server放入
    • Application Server可以同时是dialog server和update server,如果它同时提供dialog work process和update work process
    • 事务代码SM51可以查看AS ABAP instances(或Tools->Administration->Monitor->System Monitoring->Servers)
    • 事务代码SM50可以查看当前登录的instance下的work process(或Tools->Administration->Monitor->System Monitoring->Servers)
    • 事务代码SM04可以查看当前登录的instance中的用户(或Tools->Administration->Monitor->System Monitoring->User Overview)
    • 要查看当前登录的instance,可通过System->Status
    • Internet Communication Manager (ICM),当用户通过网络访问时,该模块用于接收request
    • Gateway Reader,当用户通过remote function call (RFC)访问时,该模块用于接收通讯

    AS Java 7.0x:

    • 主服务器运行central instance和central service (Java CS),附加服务器运行dialog instances
    • central instance,运行着software development manager (SDM)
    • central service,运行着message server和enqueue server
    • entire Java environment referred as Java cluster, individual processed referred as nodes to the Java cluster

    AS Java 7.1x:

    • SDM被弃用,转而使用ICM和server processes
    • central message service for internal communication, each node of the Java cluster can communicate directly with the message service
    • enqueue service holds logical locks, each node of the Java cluster can communicate directly with the enqueue service

    AS ABAP + Java 7.0x:

    • ABAP和Java各有一个Dispatcher,ABAP Dispatcher运行的是ICM,而Java Dispatcher运行的是SDM
    • Java另有一个单独的central service (Java CS)
    • ABAP + Java Central Instance有gateway (GW)
    • SAP JCo提供了RFC,允许SAP或非SAP的Java产品与SAP ABAP Systems进行连接

    AS ABAP + Java 7.1x:

    • ABAP和Java共用ABAP Dispatcher,Java通过ICM与ABAP进行连接(ICM通过URL判断request目的地),SDM被弃用
    • Java另有一个单独的central service (Java CS),且该模块中增加了gateway process (GW)
    • ABAP + Java PAS和Java CS中各有一个gateway process (GW)

    SAP NetWeaver AS 7.1x更新点总结:

    • central instance更名为Primary Application Server (PAS)
    • dialog instance更名为Additional Application Server (AAS)
    • Java Dispatcher更换为ICM process
    • SDM process was discontinued
    • Java central services增加了gateway process(以前只有ABAP + Java Central Instance中有gateway process)

    5.2 Identifying the Processes of an AS ABAP System(确认AS ABAP系统中的进程)

    每个application server运行着一个Dispatcher和若干个工作进程(work processes)。

    五大工作进程类型:

    • D型(dialog work process),执行dialog steps,每个Dispatcher至少要有两个dialog work processes
    • S型(spool work process),处理sequential flow of data(数据流),每个SAP system至少有一个spool work process,但也可以在Dispatcher中配置多个
    • V型(update work process),执行update request,每个SAP system至少有一个update work process,但也可以在Dispatcher中配置多个
    • B型(background work process),执行与用户无交互(interact)的programs,每个SAP system至少有一个background work process,但是通常有两个,一个用于普通后台作业,一个用于ABAP transport request,也可以在Dispatcher中配置多个
    • E型(enqueue work process),administers the lock table in the shared memory, this table contains the logical database locks of the ABAP runtime environment,每个SAP system只需要一个。如果我们想配置额外的enqueue work process,这些进程需要跟原进程在同一个instance中,因为它们要使用同一个lock table

    常用事务代码:

    • 上一节的SM50和SM51,可用于查看work processes和intances
    • SM66可以查看当前系统所有instances运行的全局work process(或Tools->CCMS->Control/Monitoring->Global Process Overview)

    协助work processes的通讯服务:

    • message server (MS): 处理AS ABAP Dispatchers之间的通讯
    • gateway process (GW): 处理SAP系统间或SAP系统与第三方系统的通讯,每个Dispatcher只有一个gateway reader
    • Internet Communication Manager (ICM): 处理SAP系统间通过web protocols的通讯,每个application server最多一个ICM process

    5.3 Processing User Requests in AS ABAP(在AS ABAP中处理用户请求)

    一些对应关系:

    • 可分为数据层(DB),应用层(AS),展示层(SAP GUI)
    • 每个DB服务于一个主机(在System->Status里可以查看DB owner,即访问DB的用户名)
    • 每个主机host有多个实例instances,故这些instances共用一个DB
    • 每个instance有一个buffer和一个dispatcher,因为DB跟主机关联,buffer跟instance关联,所以缓存和数据库可能不一致
    • 每个dispatcher处理多个SAP GUI发来的requests

    ABAP Dispatcher的用途:

    • Manages the resources for the applications written in ABAP in coordination with the respective operating system(与操作系统协调,管理ABAP中的应用资源)
    • Distributes the requests among the work processes(向工作进程分发用户请求)
    • Integrates the presentation layer(集成显示层)
    • Organizes the communication activities(组织通讯活动)
    • Saves the processing requests in request queues and then process them according to the first in, first out principle(将用户请求存放在队列中,用先进先出的方式进行处理)

    Database Interface(数据库接口):

    • 可以将Open SQL ( structured query language ) 翻译成本地类型数据库的Native SQL,这有利于ABAP programs独立于database(Open SQL在SQL standard的基础上增强的)
    • Open SQL会进行算法优化,先去local buffer访问常用数据(包括ABAP programs, screens, ABAP dictionary information, business administration parameters),其它数据再去访问DB
    • Native SQL会直接访问DB(关键字EXEC SQL. ... END EXEC.

    Dialog Requests Processing(Dialog程序处理):

    • a program dialog step is assigned to one specific dialog work process, a dialog work process sequentially processes dialog steps for various users and programs(即dialog work process和dialog steps是一对多的关系
    • the individual dialog steps for a program consisting of several screens can be executed by various dialog work processes during program runtime(即dialog steps会分发给不同的dialog work process)
    • dynpros: consist of a screen image and the underlying flow logic, to realize user actions
    • screen flow logic: 由ABAP interpreter运行

      (1) Process Before Output (PBO),屏幕展示前运行的模块

      (2) Process After Input (PAI),用户完成输入后运行的模块

    Updates in AS ABAP(AS ABAP的更新操作)四大特性(ACID):

    • Atomic原子性,即要么成功要么失败,不能一半成功;
    • Consistent一致性,从business terms角度看更新状态是一致的;
    • Isolated隔离性,只有Commit以后其它进程才能发现更新后的结果;
    • Durable持久性,更新是永久性的。

    Database Transaction, Business Transaction and AS ABAP Transaction(这里的Transaction其实是LUW,即logic unit work):

    • Database Transaction

      (1) a work process can only changes to the database within one database transaction

      (2) a database transaction is a nondivisible sequence of database operations

      (3) Commit, defines the begin and end of a database transaction

      (4) Rollback, when a database transaction terminated

    • Business Transaction

      (1) group processing units to provide a specific function, the changes to the database are consistent and make sense in business terms(业务需求,比如创建一个订单数据同时也创建订单的物料数据)

    • ABAP Transaction

      (1) an AS ABAP transaction is defined as a nondivisible business process whose execution takes place completely or not at all

      (2) AS ABAP transactions are implemented as sequences of logically-related dialog steps

    大概可以理解成ABAP transaction代表一个程序,database transaction代表一次DB操作(或dialog step),故一个ABAP transaction里可以有很多database transaction。而Business transaction代表一个业务功能,故可以包含若干个ABAP transaction。

    Enqueue server: 即lock table,运行在instance的main memory里。

    Lock Modes(锁类型):

    • Write locks ( lock mode exclusive ),即只有当前用户可以写,同一个用户可以累加write lock(即cumulate操作);
    • Read locks ( lock mode shared ),即不同用户可以同时访问locked data,但此时写操作会被拒绝;
    • Enhanced write locks ( lock mode exclusive noncumulative ),即每次操作只加一次锁,且该次操作以外所有操作都被拒绝;
    • Optimistic locks (lock mode optimistic),这种锁通常用于在编辑状态查看数据,初始为read locks,但在用户做保存操作时会变成write locks,如果有其他人先定义了别的locks,此时保存就会失败。

    Removal of a Lock(解除锁的方法):

    • 事务代码SM04,可终止用户session(或Tools->Administration->Monitor->System Monitoring->User Overview)
    • 事务代码SM12,手动删除锁,前提是先用SM04确认该用户没有处于登录状态

    Asynchronous Updates(异步更新)步骤:

    • 用户通过enqueue work process锁住要修改的表,信息存放于lock table,如果已被他人锁住,则返回无法修改该表的信息;
    • 锁表成功,用户可以修改目标数据;
    • 如果程序调用了FUNCTION...INUPDATE TASK这种函数,更新数据会被临时存放在VB*表(一种存放要更新的数据的表,因为都是VB开头的,所以统称为VB*表)中;(表簇VBLOG,透明表VBHDR,VBDATA,VBMOD,VBERROR)
    • 操作结束时(比如"保存"),程序提交COMMIT WORK,update work process被激活;
    • update work process读取VB*表中的log records
    • update work process进行更新操作并等待database反馈,如果成功则删除VB*表中的临时数据,如果失败则保留VB*表中的临时数据并标注为defective(有缺陷的)
    • the lock entries in lock table are reset

    常用的VB*表:

    • VBHDR: update headers
    • VBMOD: update modules
    • VBDATA: update data
    • VBERROR: possible error information

    三种update types:

    • Time-critical, primary V1 updates,有时序要求有控制函数(用于更新主数据)
    • Non-time-critical, secondary V2 updates,无时序要求但依赖V1 updates(用于更新统计数据,如行数)
    • Non-time-critical updates,无时序要求,并行(collective run)

    常用事务代码:

    • 事务代码SM13(又叫update monitor)可以查看update操作。
    • 事务代码SA38可运行程序,选择程序VBTST300可测试update操作

    关于COMMIT WORK和COMMIT WORK AND WAIT:

    • COMMIT WORK,直接完成修改并往下运行,sy-subrc只考虑本次更新的成功与否;
    • COMMIT WORK AND WAIT,运行完成后要等待其他修改操作完成,然后再往下运行,sy-subrc要考虑所有更新操作的成功与否;
    • 因为SAP的update都是异步的,所以需要COMMIT WORK AND WAIT模仿同步更新;
    • 如果发现更新失败需要回滚,则使用ROLLBACK WORK。

    5.4 Using Additional Processes of an AS ABAP System(在AS ABAP系统使用附加进程)

    打印流程:

    • set up a printer
    • select a printer
    • create a spool request(包含了数据、数据格式等信息)
    • spool work process creates an output request, either locally or remotely

    常用事务代码:

    • 事务代码SP02,查看spool和output requests(或System->Own Spool Requests)
    • 事务代码SU3,维护用户参数,在Defaults页签有Spool Control section(或System->User Profile->Own Data)
    • 事务代码SM36,后台作业管理(或Tools->CCMS->Background Processing->Define Jobs)
    • 事务代码SM37,后台作业查询(或Tools->CCMS->Background Processing->Jobs->Overview and Administration)

    Unit6 Communication and Integration Technologies(通讯与集成技术)

    6.1 Describing Communication with Remote Function Call-Based (RFC) Technology(解释远程RFC)

    SAP常用集成技术:

    • ALE: Application Link Enabling(使用BAPI或RFC)
    • BAPI: Business Application Programming Interface(注意:BAPI只负责传输数据、请求数据、处理业务,不负责显示层工作)
    • CPI-C: Common Program Interface Communication
    • EDI: Electronic Data Interchange(IDOC就是EDI的一种)
    • HTTP(S): Hyper Text Transfer Protocol
    • LU 6.2: Logical Unit Type 6.2
    • RFC: Remote Function Call ( is an SAP interface protocol based on CPI-C and TCP/IP )
    • OLE: Object Linking and Embedding
    • SMTP: Simple Mail Transfer Protocol
    • SOAP: Simple Object Access Protocol
    • TCP/IP: Transmission Control Protocol / Internet Protocol
    • XML: Extensible Markup Language

    RFC函数:

    • RFC是bidirectional,所以第三方系统也可以通过RFC调用SAP系统的函数。
    • 事务代码SE37可用于定义RFC函数(或Tools->ABAP->Workbench->Development->Function Builder)
    • 事务代码SM59可用于定义RFC connections(或Communication and Integration Technologies->RFC Destinations(Display/Maintain))
    • Trusted RFC: 目标系统所有用户可以共享该RFC connection

    Business Object Repository (BOR) and Business Application Programming (BAPI):

    • BAPI是特殊的RFC,BAPI被定义在BOR中,相当于BOR的method(模仿object-oriented效果)
    • 事务代码SE37可用于定义BAPI
    • 事务代码SW01可用于创建Business Object(或Tools->ABAP Workbench->Development->Business Object Builder)
    • 事务代码BAPI可查看BOR及其BAPI

    实施ALE的过程:

    • Identify the business process and the objects involved
    • Identify the information to be transmitted
    • Specify the format for the data to be transferred
    • Decide the technology to be used for transfer
    • Decide the type of transfer
    • Specify the destination of the data transfer

    Types of Transfers

    • Synchronous
    • Asynchronous

    6.2 Describing the Basics of Web Services(描述Web Service)

    The following basic standards for Web Service are supported in SAP NetWeaver AS:

    • Extensible Markup Language (XML)
    • Simple Object Access Protocol (SOAP)
    • Web Services Description Language (WSDL)
    • Universal Description, Discovery, and Integration (UDDI)

    两种实现Web Service的方式:

    • Inside-out approach,即将已有的函数发布成Web Service
    • Outside-in approach,即利用已有的WSDL生成Web Service

    常用事务代码:

    • 事务代码SOAMANAGER,AS ABAP的Web Service配置
    • SAP NetWeaver Administrator->SOA,AS Java的Web Service配置

    6.3 ODATA

    OData( Open Data Protocol ): is an open web based protocol for querying and updating data. (OData is sometimes called "ODBC for the Web" )

    AtomPub( Atom Publishing Protocol ): one of the internet standards used by OData, which is built on top of the Atom Syndication Format( Atom ).

    Atom: is the XML format in which OData data is published and AtomPub is the protocol providing the operations of getting, creating, updating and deleting the data. To complement the XML-based AtomPub format, OData has defined an optional JSON representation of the protocol.

    REST( Representational State Transfer ): OData enables REST-based data services, which allow resources to be published and edited by Web clients using simple HTTP messages.

    URI( Uniform Resource Identifier ): OData service is defined in an abstract data model that is based on an entity and relationship model and is represented by a URI.

    OData for SAP: SAP has used the standard extensibility features found in OData to provide its own an notations called OData for SAP. The combination of OData's data format and the SAP Annotations make SAP business information self-describing and readable.

    SAP Gateway: offers development and generation tools to create consumption model structures exposed as REST-based via OData to various client development tools. SAP Gateway is the main approach to provide data for SAPUI5 based applications.

       

    Following are the characteristics of OData:

    URIs for resource identification

    Uniform operations, defined by HTTP ( GET, POST, PUT, PATCH, DELETE)

    Well known data formats

    AtomPub and JSON

    Query language: "ODBC for the Web"

    Schema information: Data model description

    Based on entity and relationship model

    Hypermedia design patterns

    Unit7 Flow of an ABAP Program(ABAP程序流)

    7.1 Describing the Processing of ABAP Programs(描述ABAP程序的处理过程)

    Architecture Layers(SAP系统三层架构):

    • Database layer数据库层
    • Application Server layer应用服务器层
    • Presentation Server layer展示服务器层

    Unit8 ABAP Workbench(ABAP工作台)

    8.1 Introducing the ABAP Workbench(ABAP工作台简介)

    Repository Objects(仓库对象的属性说明):

    • Repository consists of all system development objects: programs, function modules, definitions of database tables and so on(仓库对象包括了程序、函数模块、数据表定义等)
    • Repository contains objects delivered by SAP, defined by the customer(仓库对象包括系统标准对象和用户自定义对象)
    • Repository is in the database and is independent of the client(仓库对象存放在数据库中且与client无关)

    注意:数据库中也存放着application和customizing data,不过它们通常与client相关,所以不是repository objects。

    模块与包:

    • the system subdivides the Repository according to application components(模块,如MM、FI、PP等)
    • the application component consists of several packages(包) containing relevant objects for a more detailed logical subdivision
    • when a Repository object is created, it must be assigned to a package(所有的Repository object创建时都要分配一个包)
    • Repository objects可以嵌套或者引用

    常用事务代码:

    • 事务代码SE84,访问ABAP Repository Information System(或Tools->ABAP Workbench->Overview->Information System),用SE80也可以
    • 事务代码SE81,访问SAP Application Hierarchy(或Tools->ABAP Workbench->Overview->Application Hierarchy->SAP)

    ABAP Workbench Tools:

    • ABAP Editor(ABAP编辑器): is used for editing the source code
    • ABAP Dictionary(ABAP字典): is used for editing database table definitions, data types, and other entities
    • Screen Painter(屏幕绘制器): is used for configuring screens together with functions for user dialogs
    • Menu Painter(菜单绘制器): is used for designing user interface components ( menu bar, standard toolbar, application toolbar, function key settings )
    • Function Builder(函数构造器): is used for maintaining function modules
    • Class Builder(类构造器): is used for maintaining global classes and interfaces

    常用事务代码:

    • 事务代码SE38,ABAP Editor
    • 事务代码SE11,ABAP Dictionary ( display, change, create )
    • 事务代码SE12,ABAP Dictionary ( display only )
    • 事务代码SE51,Screen Painter
    • 事务代码SE41,Menu Painter
    • 事务代码SE37,Function Builder
    • 事务代码SE24,Class Builder

    Object Navigator Screen areas(SE80屏幕区域):

    • navigation area: display a hierarchical object list(可通过Fullscreen按钮隐藏或展示)
    • tool area: display tool(即ABAP Editor、Class Builder等)

    (这里介绍了一组按钮,在教材的201~203页)

    8.2 Organizing ABAP Development Projects(组织ABAP开发项目)

    Change request and task:

    • 做修改时,项目经理创建一个change request(后面还会有其它类型的request),下面分配有每个开发人员的task
    • 每个task里装着对应开发人员的所有开发更改

    注意:包是从逻辑和业务上划分Repository objects,但是change requests是从开发项目的角度划分对象且有时效性。比如一个程序一定属于某个包,但是在不同时期可能属于不同的change requests。

    常用事务代码:

    • 事务代码SE09,创建或查看change requests
    • 事务代码SE80,可用于创建包
    • 事务代码STMS,可用于定义Transport Layer(至少需要两个transport layers,以区分用户开发与直接修改SAP objects,通常用户开发用的transport layer以Z开头,修改标准对象的transport layer为SAP)

    Package Attributes包属性:

    • Application Component: 模块
    • Software Component: 通常值为HOME
    • Transport Layer: 决定了传输路径
    • Direct Superpackage: 允许包有层级结构
    • Package Type: 包类型

      (1) development package: can only contain Repository objects and other packages

      (2) main package: can only contain other packages

      (3) structure package: can only contain main packages

    • Flag for Package Encapsulation外部只能通过包接口访问内部对象

    8.3 Developing ABAP Programs(开发ABAP程序)

    ABAP Programming Language Features(ABAP编程语言特点):

    • It is typed
    • It enables multi-language applications
    • It enables SQL access
    • It is enhanced as an object-oriented language
    • It is platform-independent(虚拟机语言)
    • It is upward-compatible(向上兼容)

    Characteristics of ABAP Syntax:

    • ABAP programs consist of individual statements
    • The first word in a statement is called an ABAP keyword
    • Each statement ends with a period(句号)
    • A space must always separate two words
    • Statements can be indented(缩进)
    • The ABAP runtime system does not differentiate between upper and lowercase in keyword, additions and operands(运行时不区分大小写)

    Additional Features of ABAP Syntax:

    • Statements can extend beyond one line
    • Several statements can lie in a single line ( not recommended )
    • Lines that begin with an asterisk (*) in the first column are recognized as comment lines
    • A double quotation mark (") indicates that the rest of a line is a comment

    (注意: 虽然一句多行或多句一行都是可行的,但是不建议这样使用)

    Combination of Statements:

    • You can combine consecutive statements with an identical beginning into a chained statement

      (1) Write the identical beginning part of the statements, followed by a colon(冒号)

      (2) List the end parts of the statements, separated by commas(逗号)

      (3) Use blank spaces and line breaks before and after separators

    常用技巧:

    • Pretty Printer: Utilities->Settings->ABAP Editor->Pretty Printer(或直接用程序美化器按钮)
    • F1: 帮助文档
    • 配置ABAP编辑器: Utilities->Settings->ABAP Editor

      (1) 你可以选择用不同颜色表示不同对象

      (2) 你可以针对每个用户配置字体(font)和字体大小(size)

      (3) 你可以收起程序块(loop... endloop.、if... endif.程序块等)

      (4) 你可以定义书签(bookmark)

      (5) 你可以显示行数(lines)和层级数(current nesting)

      (6) 你可以开启关键字补完提示(suggested complete words)

      (7) 你可以开启光标提示信息(pop-up list)

    • F8: 创建temporary runtime objects运行非激活版本的代码(直接运行程序只能运行激活版本的代码,故激活版本代码和非激活版本代码都是可运行的

    关于激活:

    • 用户修改并保存后,系统会在Repository生成非激活版本,此时将同时有激活版本和非激活版本。
    • 一旦用户激活,非激活版本将变成新的激活版本。
    • 只有激活的对象可以被传输请求号传输。

    The activation of an object includes the following functions(激活的步骤):

    • Saving the object as an inactive version
    • Checking the syntax or consistency(一致性) of the inactive version
    • Overwriting the previously active version with the inactive version ( only after a successful check )
    • Generating the relevant runtime object for later execution, if the object is a program

    8.4 Finalizing ABAP Development Projects(ABAP开发项目定稿)

    常用事务代码:

    • 事务代码SE93,创建对象的事务代码
    • 事务代码SE80,找到目标程序点击右键,选择Create->Transaction,也可以给程序创建事务代码
    • 事务代码SE01,release请求号
    • 事务代码STMS,import请求号

    Unit9 Basic ABAP Language Elements(ABAP语言基本要素)

    9.1 Defining Elementary Data Objects(定义元素数据对象)

    DDIC Types and ABAP Types(数据字典类型和ABAP类型):

    • ABAP类型是基本数据类型,比如C字符型、N数字字符型、P精确浮点数型、X十六进制数型等
    • 数据字典类型是在ABAP类型基础上预置的逻辑类型,比如CHAR类型建立在C(n)基础上即字符,CURR(n, m)建立在P((n+1)/2)DECIMALm基础上即货币金额、INT4建立在X(4)即I类型基础上即四字节整型数、NUMC n建立在N(n)基础上即数字型字符串等(即数据字典类型有业务含义)

    ABAP Types有两类:

    • Complete(不需要额外参数的数据类型)

      (1)D, Type for date, format: YYYMMDD, length 8(fixed)

      (2)T, Type for time, format: HHMMSS, length 6(fixed)

      (3)I, INT8, Type for integer, for I length 4(fixed), for INT8 length 8(fixed)

      (4)F, Type for floating point number, length 8(fixed)

      (5)STRING, Type for dynamic length character string

      (6)XSTRING, Type for dynamic length byte sequence( HeXadecimal string )

      (7)DECFLOAT16, DECFLOAT34, Type for Decimal Floating point numbers, for DECFLOAT16 length 8 bytes with 16 decimal places(fixed), for DECFLOAT34 length 16 bytes with 34 decimal places(fixed)

    • Incomplete(需要额外参数的数据类型,比如长度、小数位等)

      (1)C, Type for character string, length is to be specified(需要用户给出长度参数)

      (2) N, Type for numerical character string, length is to be specified(需要用户给出长度参数)

      (3) X, Type for byte sequence, length is to be specified(需要用户给出长度参数)

      (4) P, Type for packed number, length is to be specified, number of decimal points is also to be specified(需要用户给出长度、小数位长度)

    利用standard data types,我们可以在程序中定义local data types:

    • TYPES tv_c_type TYPE c LENGTH 8.(创建8位字符数组类型)
    • TYPES tv_n_type TYPE n LENGTH 5.(创建5位数字字符数组类型)
    • TYPES tv_p_type p LENGTH 3 DECIMALS 2.(创建压缩浮点数类型,长度3,小数位2位)
    • TYPES tv_c_type(3) TYPE c.(创建3位字符数组类型)
    • TYPES tv_p_type(3) TYPE p DECIMALS 2.(创建压缩浮点数类型,长度3,小数位2位)

    注意:定义variable也像定义type一样可以有多种写法。

    我们也可以利用SE11在ABAP Dictionary中建立global data types。

    定义变量Variables Data Objects的三种方式:

    • Built-In 参照预定义类型
    • Local 参照本地类型
    • Global 参照全局类型

    几种常见前缀:

    • tv_: global type or local type
    • gv_: global variable
    • lv_: local variable
    • gc_: global constant

    Fixed Data Objects固定值:

    • Fixed Data with Label需要申明的固定值

      (1) Constants常量:例如CONSTANTS gc_myconst TYPE type_name VALUE { literal | IS INITIAL }.

    • Fixed Data without Label不需要申明的固定值

      (1)Literals文本:

      Numeric Literals数字字符文本:例如CALL SCREEN 0100.

      Text Literals 文字文本:例如String: 'Hello'.

    Text Symbols文本元素:

    • language-dependent,即文本元素根据用户登录语言选择不同版本的文本
    • used in the particular program to which it belongs,即文本元素属于特定的程序
    • 文本元素在Repository有单独的存放位置,有text pool存放不同版本的文本
    • 文本元素有两种定义方式:text-001'...'(002)(这里的'...'指原始语言的文本)

    Options for Defining Text Symbols for Programs定义文本元素的选项:

    • In the ABAP Editor, choose GOTO->Text Elements; tab Text Symbols.
    • Address the text symbol in your source code using the syntax TEXT-xxx: '...'(xxx) and double-click its ID ( forward navigation )
    • To translate the text symbols of your program, choose GOTO->Translation form the menu in the ABAP Editor

    9.2 Using Basic ABAP Statements(使用ABAP基本申明)

    Valid operators in ABAP programs合法的运算符:

    • +: Addition
    • -: Subtraction
    • *: Multiplication
    • /: Division
    • **: Exponentiation(幂,次方)
    • DIV: Integral division without remainder
    • MOD: Remainder after integral division

    Predefined Function预定义函数(部分例子):

    • gv_length = STRLEN( gd_cityfrom ).求字符串长度
    • LINES( itab[] ).求内表行数
    • ABS( gv_val1 ).求绝对值
    • SIGN正数返回1,0返回0,负数返回-1
    • CEIL向上取整
    • FlOOR向下取整
    • TRUNC取整数部分
    • TRAC取小数部分
    • COS(x)余弦函数
    • SIN(x)正弦函数
    • TAN(x)正切函数
    • ACOS(x)反余弦函数
    • ASIN(x)反正弦函数
    • ATAN(x)反正切函数

    其它关键字:

    • MOVE(也可以直接用=)
    • CLEAR(恢复initial value)
    • CASE. WHEN. ... ENDCASE.
    • IF. ... ELSE. ... ELSEIF. ... ENDIF.
    • NOT(取反)
    • DO. ... ENDDO.(Unconditional and index-controlled loops)
    • DO n TIMES. ... ENDDO.
    • WHILE <condition>. ... ENDWHILE.(Header-controlled loops)
    • SELECT ... FROM <dbtab> ... ENDSELECT.(Read loops)
    • LOOP AT <internal table>. ... EDNLOOP.(Read loops)
    • EXIT.

    (详情请参看教材259~264页)

    循环计算的几个注意事项:

    • 在嵌套循环中,sy-index只保存当前循环的次数
    • Read loops通过sy-tabix保存读取的index值
    • 循环太久会报Timeout错误,事务代码RZ10中可以定义Timeout的时间长度

    常用System Fields(SYST表可以查看这些字段):

    • sy-mandt: Logon Client
    • sy-uname: Logon Name of the User
    • sy-langu: Logon Language of the User
    • sy-datum: Local Date of the ABAP System
    • sy-uzeit: Local Time of the ABAP System
    • sy-tcode: Current Transaction Code
    • sy-repid: Name of the Current ABAP Program
    • sy-index: Loop Counter at DO and WHILE Loops
    • sy-tabix: index of Read action
    • sy-subrc: Return Code of an ABAP statement
    • sy-datar: 用户是否有输入动作,有则为X
    • sy-dynnr: 当前屏幕号
    • sy-cprog: 当前主程序名称
    • sy-ucomm: 当前指令

    Dialog Messages(MESSAGE Tnnn(message_class) [ WITH v1 [v2] [v3] [v4] ])。

    Message Statement定义三要素:(1)Message Type (2)Message Number (3)Message Class

    这里的T指Message Types:

    Type

    Meaning

    Dialog behavior

    Message appears in

    i

    Info Message

    Program continues after breakpoint

    Modal dialog box

    s

    Set Massage

    Program continues without breakpoint

    Status bar *) of next screen

    w

    Warning

    Context-dependent

    Status bar *)

    e

    Error

    Context-dependent

    Status bar *)

    a

    Termination

    Program terminated

    Modal dialog box

    x

    Short Dump

    Runtime error MESSAGE_TYPE_X is triggered

    Short dump

    (注意,此处的message_class是一组编号叫消息类,但我们也可以不用text object的写法,直接给字符串值在MESSAGE后面。)

    9.3 Analyzing Programs with the ABAP Debugger(使用ABAP调试器分析程序)

    进入debug的几种方法:

    • SE80在Repository中右键程序名,选择Execute->Debugging
    • 在command field输入/h
    • System->Utilities->Debugging ABAP ( or screen )
    • 无窗口时可将shortcut拖入界面进入debug状态(shortcut可在GUI未登录界面创建,这种方法很少见)

    名词解释:

    • single-step: execute the program statement-by-statement
    • Debugger->Switch: 该功能可以切换new ABAP debugger和classic ABAP debugger
    • 调试时双击变量,该变量将显示在右方的Variables 1页签中,我们可以修改它们的值
    • Second Session: debug时会打开额外的窗口,该窗口会写着(Exclusive)(注意,如果我们已经打开了6个窗口(sessions),再进行debug时会因为窗口已经达到最大数而进入classic ABAP debugger,且此时使用Switch无法进入new ABAP debugger
    • Breakpoints断点:

      (1) 在debug状态中,左键点击代码,可以设置临时breakpoint for current session

      (2) Breakpoints->Breakpoint at->Statement,可以为特定语句设置临时breakpoint for current session

      (3) 在debug状态中,按下Save按钮,可以把临时breakpoint变成持续性的breakpoint

    • Watchpoints监视点:

      (1) Watchpoints are breakpoints that depend on the field content

      (2) 如果你不给监视点指定运算(relational operator)和值(comparative value),那么目标字段值一旦改变就会触发这个监视点(注意,监视条件只支持少量预定义的条件,比如LINES( itab[] ) > 0这种)

      (3) 如果你给监视点设置了运算(relational operator)和值(comparative value),那么一旦满足条件就会触发这个监视点

      (4) 在classis ABAP debugger,我们最多设置10个watchpoints

      (5) 无论new ABAP debugger还是classic ABAP debugger,我们都可以用logic operator ( AND or OR )关联不同的watchpoints

    ABAP Debugger Additional Functions:

    • second session使得我们能同时观察程序界面和调试界面
    • Parallel display options through freely configurable display areas
    • Integration of the new ABAP Editor(右键选择转到源代码( Goto source code )可打开新窗口进入源代码)
    • Quick Info in the source code area for data object value display(双击即可在variable页签快速查看对应变量的变化)
    • Watchpoints for internal tables and object references
    • Value comparison of strings, structures, and internal tables(diff页签)
    • Enhanced table tool
    • Enhanced Web Dynpro tool

    Advanced Features of ABAP Debugger:

    • Software-layer-aware debugging (SLAD)
    • Automated debugging-debugger scripting
    • Memory consumption analysis

    Unit10 Modularization Techniques in ABAP

    10.1 Explain Modularization(解释模块化)

    Modularization定义

    • encapsulates a particular function封装特定的功能
    • improve the transparency增加可阅读性
    • makes it easier to maintain program增加可维护性

    模块化用途:

    • To provide a better overview of program layout易管理
    • To encapsulate a function that is required many times within a program for multiple use易复用
    • To implement the central maintainability of a function within a program易维护
    • To make a function available across the system易调用

    (注意: 模块化并不提升性能improve performance)

    Modularization常用技术:

    • Local Program Modularization

      (1) Subroutines( form routines )

      (2) Methods in local classes

    • Global Modularization

      (1) Function modules organized in function groups

      (2) Methods in global classes

    Criteria for Differentiating Parameters三种常见参数类型:

    • importing parameters: pass data to the modularization unit
    • exporting parameters: return data form the modularization unit to the caller
    • changing parameters: pass data to the modularization unit and return the data after it has been changed

    10.2 Defining and Calling Subroutines(定义和调用子例程)

    Subroutines的两种参数:

    • actual parameters: 实参,会改变传入的变量的值(subroutine允许用global variable进行计算,这些global variable就被称为一种实参)
    • format parameters: 形参,形参的计算不影响传入变量的值
    • parameter passing: the assignment of actual parameters to formal parameters

    Definition of Pass Types for Subroutines三种传参方式:

    • Call by value值传递: 将变量的值复制出来以value的形式传给subroutine,不改变变量的值(使用时要用USING value(f1) TYPE typename这种格式);
    • Callbyvalue and result有返回值的值传递: 将变量的值复制出来以value的形式传给subroutine,又将最终的value复制给变量(使用时要用CHANGING value(f2) TYPE typename这种格式,速度最慢);
    • Call by reference引用传递: 直接将实参给subroutine(直接使用USINGCHANGING,这种方法最快,但是跟内存地址有关,所以集成时不能用)

    (注意,有一种type叫TYPE ANY,代表任意类型,这类类型的详情可以参考TAW12教材的章节。)

    Subroutine的调试:

    • Execute: debugger将执行完subroutine并停在PERFORM语句的下一行代码(但如果FORM内部有断点,会在FORM内部变成单步模式);
    • Single Step: debugger将逐行调试;
    • Return: debugger将执行完subroutine并停在主程序下一个断点(忽略FORM的内部断点),如果没有下一个断点,会返回到程序开始的位置;
    • Continue: debugger将执行完所有代码并停在下一个断点,如果没有下一个断点,会直接运行完代码并显示结果。

    Call Stack: debugger中的一个工具,在Standard页签的右上方,可以看到subroutines被什么程序调用、被什么事件(比如START-OF-SELECTION)触发。

    10.3 Calling Function Modules(调用函数模块)

    Components of a Function Group函数组成员:

    • Data objects
    • Subroutines
    • Screens

    函数组中的data、subroutines、screens对于其中的函数都是可以访问的。(函数组其实是一个主程序(SAPL*开头),包含了很多include文件,其中的data、subroutines、screens都以全局变量的形式存放在include文件中。)

    Elements of the Interface of a Function Module函数模块接口参数:

    • Import parameter输入参数(可以设置为optional)
    • Export parameter输出参数(一定为optional)
    • Changing parameter输入并能收到返回值的参数
    • Exceptions异常

    注意:调用Functions时,输入参数用的是EXPORTING关键字,输出参数用的是IMPORTING关键字,修改参数用的是CHANGING关键字,异常用的是EXCEPTIONS关键字。

    (调用Functions的代码,请参考教材323~325页。)

    寻找Function modules的方法:

    • Application-related search: 通过Application Hierarchy寻找
    • Application-independent search: 通过Repository Information System寻找
    • Program-related search: 直接在源代码中搜索CALL FUNCTION关键字(如果我们看的是提供屏幕的Function,可以F1->Technical Information查看屏幕编号,然后通过Where-Used List查看屏幕被调用的位置)

    10.4 Creating Function Modules(创建函数模块)

    要点笔记:

    • 创建、修改、查看FM的事务代码是SE37;
    • 查看FM时,右下方有release on的是SAP标准FM;
    • 参数定义中,最右方的一栏是设置长文本的,比较少用;
    • 参数其它定义,如是否必输、是否有缺省值、是否用值传递,请参考其它资料;
    • 在SE37主界面menu goto->function group中可以创建、修改、显示、删除函数组(也可以SE80中在package中右键选择创建函数组)。

    10.5 Describing Business Application Programming Interfaces (BAPIs)(描述BAPI)

    BAPIs usually exist for the following functions of a business object type(BAPI针对业务对象提供的功能):

    • Create an object创建业务对象(生产订单、采购订单等)
    • Retrieving object attributes检索业务对象属性
    • Changing object attributes修改业务对象属性
    • Listing objects列出业务对象

    常用事务代码:

    • 事务代码BAPI,BAPI Explorer(或Tools->Business Framework->BAPI Explorer)

    BAPI的技术要求(technical requirements):

    • Naming convention: BAPI<business object name><method name>(三者用_连接)
    • Remote-enabled
    • No user dialogs or message
    • Name prefix for BAPI structures: BAPI(我们可以在ABAP Dictionary里创建BAPI_*开头的structure,其中的components就是我们要在BAPI中定义参数使用的types)
    • No changing parameters until Release 4.6
    • Raise no exceptions: Errors are reported to the user through the special export parameter RETURN(这是一个内表)

    10.6 Calling Methods of Global Classes(调用全局类的方法)

    本章内容请参考TAW12教材面向对象的部分。请注意动态属性/方法和静态属性/方法,普通异常和异常类的区别。

    10.7 Creating Global Classes and Static Methods(创建全局类和静态方法)

    创建全局类的途径:

    • 事务代码SE24
    • 事务代码SE80,右键选择Create->Class Library->Class

    查看类的源代码的方法:

    • 自定义的Class,可以在source code直接看到源代码
    • 标准Class,可以在菜单Goto中查看源代码

    本章内容请参考TAW12教材面向对象的部分。

    10.8 Using Local Classes(使用本地类)

    常用关键字:

    • INTERFACE...ENDINTERFACE.: 定义接口
    • CLASS...DEFINITION. ... ENDCLASS.: 定义类
    • CLASS...IMPLEMENTATION. ... ENDCLASS.: 实现类
    • METHODS: 定义动态方法
    • METHOD...ENDMETHOD.: 实现动态方法
    • CLASS-METHODS: 定义静态方法
    • METHOD...ENDMETHOD.: 实现静态方法(实现的关键字与动态方法相同)
    • DATA: 定义动态属性
    • CLASS-DATA: 定义静态属性
    • CONSTANTS: 定义常量属性
    • INTERFACES: 定义接口属性
    • METHOD...ENDMETHOD.: 实现接口(实现的关键字与动态方法相同)

    定义CLASS METHODS时可用的Signature:

    • IMPORTING输入参数,可使用OPTIONAL、DEFAULT等附加属性
    • EXPORTING输出参数
    • CHANGING可改变参数,可使用OPTIONAL、DEFAULT等附加属性
    • RETURNING value(...)返回值
    • EXCEPTIONS异常

    本章内容请参考TAW12教材面向对象的部分。

    Unit11 Complex Data Objects(复杂数据对象)

    11.1 Using Structured Data Objects(使用结构)

    Global Structure和Local Structure:

    • Global Structure: ABAP Dictionary中定义的Structure(常以ts_、gs_开头)
    • Local Structure: Program中定义的Structure(常以ts_、ls_开头)

      (1)定义的关键字:TYPES: BEGIN OF typename. ... END OF typename.

      (2)直接使用的关键字:DATA: BEGIN OF typename. ... END OF typename.

    MOVE和MOVE-CORRESPONDING:

    • MOVE ... TO ...: 传单个变量值
    • MOVE-CORRESPONDING ... TO ...: 传structures之间的值,此时同名的字段会传值,而不同名的字段保持原状

    调试时双击structure名称可以在variables 1页签看到该structure名称,再双击该名称就可以看到structure页签并能看到其中的值。

    11.2 Using Internal Tables(使用内表)

    Properties of an Internal Table内表基本属性:

    • Line type行类型
    • Primary key键值

      (1) unique keys: 该键值不可重复,每个键值对应一行

      (2) non-unique: 该键值可以重复,每个键值可以找到多于一行

    • Table kind表类型

      (1) Standard tables标准表: 可以通过index访问,也能通过keys访问,但只支持non-unique key

      (2) Sorted tables排序表: 可以通过index访问,也能通过keys访问,同时支持unique key和non-uniquekey

      (3) Hashed tables哈希表: 只能通过keys访问,且只支持unique key

    关于Table kinds的补充内容:

    • 当我们主要通过index访问内表数据时,请使用standard tables
    • Sorted tables会自动根据键值对数据进行ascending排序,如果我们主要通过key访问内表数据且希望数据自动排序的话请使用sorted tables(这种表用append语句增加行可能报错,用insert则不会)
    • 当我们只希望通过键值访问内表数据且内表数据量非常大时,请使用hashed tables
    • Standard tables和sorted tables又合称为index tables

    常用前缀:

    • tt_: 程序全局或局部内表
    • gt_: 程序全局内表
    • lt_: 局部内表

    完整的定义表的语句为:

    DATA gt_itab TYPE STANDARD/SORTED/HASHED TABLE OF <Structure Type> WITH NON-UNIQUE/UNIQUE KEY ... .

    特定情况下可以使用缺省值:

    • Table kind - standard ( default )
    • Uniqueness of key - non-unique ( only option for a standard table )
    • Table key - default key ( all non-numeric table fields are key fields )

    常用内表操作:

    • APPEND gs TO gt_itab.: 追加行(hashed tables禁止使用,sorted tables可能报错)
    • INSERT gs INTO TABLE gt_itab <condition>.: 插入行
    • READ TABLE gt_itab INTO gs <condition>.:读取行
    • MODIFY gt_itab FROM gs TRANSPORTING f1 f2 ... <condition>.: 修改多行
    • MODIFY TABLE gt_itab FROM gs <condition>.: 修改单行
    • DELETE gt_itab <condition>.: 删除多行
    • DELETE gt_itab INDEX i.: 删除单行
    • DELETE TABLE gt_itab FROM gs.: 删除单行
    • COLLECT: 累加所有数字型字段
    • LOOP AT gt_it INTO gs <condition>... ENDLOOP.: 循环
    • INSERT LINES OF gt_it1 <condition1> INTO gt_it2 <condition2>.: 插入多行
    • APPEND LINES OF gt_it1 <condition> TO gt_it2.: 追加多行
    • SORT gt_itab [STABLE] BY f1 DESCENDING [AS TEXT] f2 ASCENDING [AS TEXT].: 排序(如果希望按字母顺序排序,请使用AS TEXT附加属性,如果希望排序后不再变动,请使用STABLE附加属性)

    (更多细节请参考第三方资料。)

    三种删除内表数据的方法:

    • REFRESH: 清空内容,但是保留内表
    • CLEAR: 清空内容,但是保留内表(如果内表有同名的header line,则只清空header line)
    • FREE: 释放内存,会把内表及其内容都删除掉

    header line以及为何不推荐使用header line:

    • 与显式(explicit)工作区不同,header line是一种隐式(implicit)工作区,用WITH HEADER LINE关键字定义;
    • 如果使用了OCCURS关键字(跟随0值时表示内表空间自动扩展)时,该内表会默认定义header line
    • header line与内表同名会影响程序的阅读性(如果要区分两者,需要借助[]符号,比如itab1[]代表内表,而itab代表工作区);
    • 嵌套式内表中,禁止使用有header line的内表。

    Unit12 Data Modeling and Data Retrieval(数据建模与数据检索)

    12.1 Explaining Data Models(解释数据模型)

    Transparent tables(透明表): 与底层DB外观一致,但是不是底层DB。(在不涉及透明表概念的题中,会直接把透明表称为database tables。)

    Data Element和Domain的区别:

    • Data Element用于定义语义层属性,比如描述信息、search help等
    • Domain用于定义逻辑层属性,比如fixed values、value table、转换例程(Conversion Routine)等

    透明表常用设置:

    • Key: 设置透明表和database table的键值
    • Technical properties: 设置表格大小、访问频率、是否有secondary indexes、是否启用buffering
    • Indexes: 定义secondary indexes

    其它注意事项:

    • 如果用透明表作为类型定义内表,内表的键值与透明表的键值无关
    • 透明表不应被用于接口,因为这会建立unwanted dependency
    • 透明表没有structure型的字段,因为structure的字段可以直接定义;但是structure可以有table型的字段

    12.2 Retrieving Single Database Records(检索单行数据表数据)

    返查数据表的方法:

    • Search by application: 即在Application Hierarchy里查询
    • Search by program:
    1. Source code search: 在ABAP Editor查询SELECT关键字
    2. Function debugging: 用/h进入调式模式,然后在SELECT语句增加断点
    3. Screen field information: 使用F1 + Technical Information,找到data element,然后通过Where-Used List定位

    Types of Reuse Components that Encapsulate Database Access封装数据库访问的可复用组件:

    • Logical databases
    • Function modules
    • Business Application Programming Interfaces (BAPIs)
    • Methods of global class(注意: Methods of local class支持本地复用,故也可算作可复用)

    常用事务代码:

    • 事务代码SE36,逻辑数据库logical databases
    • 事务代码SE37,函数模块function modules
    • 事务代码BAPI,BAPI
    • 事务代码SE24,全局类global class

    SQL知识点:

    • 在SELECT后增加CLIENT SPECIFIED: 可指定当前client以外的client,此时要指定MANDT字段的值,不使用该关键字则将当前client默认为MANDT字段值
    • INTO CORRESPONDING FIELD OF:
    1. 目标structure不用与field list从左向右一致( left-justified )
    2. Easy to maintain(稳定但是速度慢)

    (其它SQL详细要点请参考第三方资料。)

    12.3 Retrieving Multiple Database Records(检索多行数据库数据)

    SELECT loop: 即用SELECT … FROM … INTO ls WHERE … ENDSELECT. 这种循环会每次读取一行存入到工作区中。

    Array Fetch: 即用INTO TABLE代替INTO。

    (另有INTO CORRESPONDING FIELD OF TABLE、APPEND TABLE等用法。其它SQL用法请参考第三方资料。)

    12.4 Describing Other Aspects of Database Access(描述其它数据库访问概念)

    Key fields: If access the table is restricted to all ,or at least the first few key fields, the database can quickly and effectively access the required data records.(通过键值搜索,即rapid access)

    Non-key fields: the internal ordering principle cannot be used for rapid access. In the worst-case scenario, the entire table, or at least a very large part of the table, has to be searched for the required entries.(通过非键值搜索,即此处sequential search的情况)

    Secondary index: 相当于另建一个索引表,查询快但是插入数据慢,因为需要额外的空间存放secondary index。如果不用HINT语句指定secondary index,则Database optimizer会自动寻找合适的secondary index.(详情可以参考HINT有关的第三方资料。)

    Table buffer: The buffer settings are defined in the transparent tables in the ABAP Dictionary ( Technical Settings button ), speed up access by a factor of between 10 and 100 compared to reading data from the database.

    Table Join Definition(定义join时需要定义哪些内容):

    • Join tables
    • Join conditions
    • Join columns

    12.5 Implementing Authorization Checks(实现权限检查)

    Authorization(权限)->Authorization Object(权限对象,事务代码SU21)

    Authorization Profile(权限设置,包括权限和权限对象设置)->Role(角色,事务代码PFCG)->User Master Record(用户主数据,事务代码SU01)

    权限对象检查代码示例:

    AUTHORITY-CHECK OBJECT 'S_CARRID'

    ID 'CARRID' FIELD iv_carrid

    ID 'ACTVT' FIELD '03'.

    IF sy-subrc = 0.

    ...

    ELSE.

    ...

    ENDIF.

    AUTHORITY-CHECK OBJECT 'S_CARRID'

    ID 'CARRID' DUMMY

    ID 'ACTVT' FIELD '02'.

    注意:第二个例子中的DUMMY表示该字段的检查被忽略。ID后面跟随的是权限字段,FIELD后面跟随的是字段值。

    (更多详情请参考第三方资料。)

    Unit13 Classic ABAP Reports(经典ABAP报表程序)

    List(一种过时的制表功能,目前更多用ALV):

    • 支持多语言
    • 支持不同的金钱显示方式(monetary values)

    List Output Options:

    • Screen
    • Printer
    • Internet or intranet
    • Save

    常用的菜单功能:

    • Menu Painter: 修改List interface即List的按钮
    • System->List->List Header: 定义List Header
    • Goto->Text ELements->tab List Header: 维护List Header
    • Goto->Translation: 翻译List Header

    13.2 Implementing Selection Screens(实现选择屏幕)

    The selection screen has the following standard functions选择屏幕标准功能:

    • Texts in several languages
    • Automatic type checking
    • Complex selections for intervals, comparative conditions, and patterns
    • Field documentation for input fields
    • Search help associated with Dictionary type
    • Saving of selection screens as variants

    定义SELECT-OPTIONS时有两个后缀值得注意:

    • NO INTERVAL单值
    • NO EXTENSION无右侧按钮(用于复杂选择的按钮)

    (其它SELECTION-SCREEN的语法请参考第三方资料。)

    13.3 Implementing Events of ABAP Reports(实现ABAP报表程序中的事件)

    报表程序事件的基本原则:

    • Introduced with an event keyword用关键字定义
    • Ends by beginning the next processing block下个事件开始则上个事件结束
    • Cannot be nested无法嵌套
    • Existence is not absolutely necessary可以不定义
    • Sequence of event blocks is unimportant不受代码顺序影响
    • Implicit standard event block in executable program: START-OF-SELECTION如果没有定义任何事件,则代码默认放在START-OF-SELECTION事件下

    常见的事件:

    • LOAD-OF-PROGRAM: 载入事件,该事件在可执行程序中不可见,但是在functions groups和module pools中可见(并且是所有程序加载时首先触发的),效果与INITIALIZATION类似
    • INITIALIZATION: 初始化事件,只在进入程序时运行一次,一般用于给输入参数初始值
    • AT SELECTION-SCREEN OUTPUT: 输出屏幕显示前触发,一般配合MODIF ID和LOOP AT SCREEN关键字做动态屏幕控制
    • AT SELECTION-SCREEN ON VALUE-REQUEST FOR parameter: F4菜单激活时触发,一般用于动态生成搜索帮助
    • AT SELECTION-SCREEN: 执行时先于START-OF-SELECTION触发,一般用于输入检查
    • START-OF-SELECTION: 执行事件,用于运行主程序
    • END-OF-SELECTION: 主程序结束后、输出界面开始前触发,一般用于做内存回收等工作

    (选择屏幕关键字详情请参考后面的教材内容。)

    Unit14 Program Analysis Tools(程序分析工具)

    14.1 Improving the Quality of ABAP Code with the Code Inspector(利用代码检查器改进代码)

    Typical Quality Issues with ABAP Code衡量ABAP代码质量的常用指标:

    • Typical Performance Issues:

      (1) 选择合适的index

      (2) 尽量不在循环中使用SELECT

    • Typical Security Issues:

      (1) 确认是否从当前client以外的client获取的数据

      (2) 确认SELECT语句是否有WHERE作为约束

    • Typical Semantic Errors
    • Is the sy-subrc field checked after each AUTHORITY-CHECK statement
    • Is a client actually specified for CLIENT SPECIFIED

    打开Code Inspector的方法:

    • SE80,右键选择Check->Code Inspector(或Function Module->Check->Code Inspector)
    • 从Program菜单中选择Check->Code Inspector

    其它知识点

    • Code Inspector中的pseudo comment可以用于在检查时忽略被注释的语句。
    • Code Inspector支持检查变式(check variant),事务代码SCI

    (具体用法请参考第三方资料。)

    Check Categories要检查的内容:

    • General Checks: 主要是数据格式检查
    • Performance Checks: 检查performance和resource usage
    • Security Checks: 检查critical statement(重要声明), cross-client queries, infufficient authority checks
    • Syntax Check and Generation: 语法检查、扩展代码检查、进程生成
    • Programming Conventions: 检查naming conventions(命名规定)
    • Search Functions: 检索源代码中的单词和语句

    (注意: Code Inspector不做formatting检查)

    Unit15 Program Calls and Memory Management(程序调用与内存管理)

    SUBMIT方式:

    • SUBMIT prog_name.: 看到显示界面后返回,直接回到被调用的程序
    • SUBMIT prog_name AND RETURN.: 看到显示界面后返回,直接返回到调用程序
    • SUBMIT prog_name VIA SELECTION-SCREEN AND RETURN.: 看到显示界面后返回,首先看到选择屏,回到被调用程序的选择屏,再返回时回到调用程序

    (SUBMIT详细语法请参考后续教材的内容。)

    几种Sessions的关系:

    • User Session: 代表一个用户正在使用
    • External Session: 代表一个窗口
    • Internal Session: 代表一个程序
    • 一个User Session可以包括多个External Sessions,一个External Session可以包括多个Internal Sessions

    Synchronous Transaction Calls(同步事务代码调用方式):

    • LEAVE TO TRANSACTION 'T_CODE' [AND SKIP FIRST SCREEN].: 跳入另一个程序,LEAVE PROGRAM.时跳出全部程序
    • CALL TRANSACTION 'T_CODE' [AND SKIP FIRS SCREEN].:跳入另一个程序,LEAVE PROGRAM.时回到调用程序

    (同步事务代码调用详情请参考后续教材的内容。)

    BDC技术:

    CALL TRANSACTION 'T_CODE'

    USING gt_bdcdata

    MODE mode

    MESSAGES INTO mssg.

    • USING后面的参数必须为BDCDATA型内表
    • MODE代表被调用程序的显示方式

      (1) A默认方式,单步

      (2) E报错时显示

      (3) N不显示

    • MESSAGES INTO会将返回信息存入BDCMSGCOLL结构对应的内表中

    (BDC技术详情请参考第三方资料。)

    BDCDATA的字段与示例(我们往往需要F1配合查找程序名、屏幕号等参数):

    Field Name

    Length

    Description

    Note When Filling

    program程序名

    40

    Program name

    Only in first record for screen

    dynpro屏幕号(如果输入栏在子屏幕上需要用子屏幕编号)

    4

    Screen number

    Only in first record for screen

    dynbegin是否为第一行

    1

    First record

    'X' for first record for screen, otherwise ''

    fnam字段名

    132

    Field name

    N/A

    fval字段值

    132

    Field value

    Case sensitive

    以下为BDCDATA实例:

    Program

    Dynpro

    Dynbegin

    Fnam

    Fval

    SAPBC402_CALD_CREATE_CUSTOMER

    0100

    X

       
         

    SCUSTOM-NAME

    <current_name>

         

    SCUSTOM-CITY

    <current_city>

         

    BDC_OKCODE

    SAVE

    15.2 Describing the ABAP Runtime and Memory Management(描述ABAP运行和内存管理)

    LOAD的概念:

    • LOAD是一个程序的runtime objects的集合
    • LOAD由很多C Functions组成
    • LOADS are saved in the database and buffered on the application server

    自动创建LOAD的途径:

    • 如果program被调用但是还没有对应LOAD存在
    • 如果LOAD在database或program buffer过期(obsolete)

      (1) developed version of the program is changed程序被修改了

      (2) an object of the program is changed in the ABAP Dictionary程序用的对象被修改了

    手动创建LOAD的途径

    • Program->Generate

    常用事务代码:

    • 事务代码SEGN,SAP LOAD generator(载入请求号后,强制生成新的LOAD,以避免第一次运行时性能受影响)

    激活object的步骤:

    • The object is saved, that is, a new inactive version is created. This is subject to a syntax check.
    • The system overwrites the current active version. The previously inactive version is now the active version, which means there is no longer an inactive version.
    • The system creates a new runtime version updates the LOAD.

    Parts of Program(在运行时可修改和不可修改的部分):

    • Non-modifiable parts of a program

      (1) Byte code for statements源代码

      (2) Values of constants and literals常量

      (3) Program texts文本

      (4) Screen definitions屏幕

    • Modifiable parts of a program

      (1) Data objects ( variables )变量

    External Session ( main session ):

    • 每个代表一个SAPGUI window,窗口共享SAP memory
    • 可以通过System->New Session或/o<t_code>打开
    • 每个User Session最多可以同时有16个窗口,但是默认值为6个(配置途径为rdisp/max_alt_modes)

    Internal Session:

    • 每个代表一个ABAP program,程序共享ABAP memory
    • 每个call(SUBMIT、CALL TRANSACTION等)创建一个internal session
    • 每个External Session最多可以同时有9个进程,且它们必须被放在同一个call stack

    其它有关加载的知识点:

    • 如果program1和program2都调用了同一个function group,那么它们并不共享global data objects,而是分别load对应的function group
    • 如果internal session中有多个进程(比如主程序又调用了某个function group),而这些进程都调用了某个function group,此时可能产生异常
    • 如果program1调用了program2的subroutines,系统不会为program2创建program group,相反它会把program2放入program1的program group

      (1) within a program group, all programs share the interface work areas ( TABLES, NODES, COMMON PART )

      (2) within a program group, CALL SCREEN can only be used to call screens of the main program

    常用的传参技术:

    • Using the interface of the called program ( screen or selection screen )
    • ABAP memory ( EXPORT/IMPORT配合MEMORY ID使用 )
    • SAP memory( SET/GET配合MEMORY ID/PARAMETER ID使用 )(F1设置时用PARAMETER ID,代码定义时用MEMORY ID)
    • Database tables
    • Local files on the presentation server

    (EXPORT/IMPORT方法和SET/GET方法的详情请参考第三方资料。)

    (我们可以通过F1技术属性设置PARAMETER ID,可以通过代码设置MEMORY ID。)

    Memory Management内存管理:

    • for Flat Data Objects:

      (1) Flat Data(比如flat structure),其内存空间是固定的,故值会直接存入内存空间

      (2) internal session结束时才释放占用的内存

    • for Strings:

      (1) 首先会在static memory创建8 bytes的reference

      (2) reference会指向header内存区,header则指向data堆内存区,data的大小取决于硬件通常为100 bytes

      (3) 若data不够用,则allocate更多的堆内存区,但是不能默认不能超过2 GB(可用参数文件ztta/max_memreq_MB配置)

      (4) CLEAR或者FREE语句会清空data,但是会保留reference和header

    • for Internal Tables:

      (1) 首先会在static memory创建8 bytes的reference

      (2) 当有值时reference会指向header内存区,而一个header内存区可能指向多个data堆内存区(所以内表的header内存区往往比较大)

      (3) CLEAR和REFRESH只清空data,但是会保留reference和header

      (4) FREE会清空data和header

      (5) 在定义内表时如果使用INITIAL SIZE n语句(n表示行数),可以设定初始访问时开辟的内存区,后续内存不足时系统会扩展内存

      (6) 不声明INITIAL SIZE时系统默认INITIAL SIZE 0,即系统根据需求自动分配内存区域

    Memory Optimization内存优化:

    gv_string1 = gv_string2.

    当两个引用变量的值相等的时候,它们会共享同一个内存区域。

    gv_string1 = gv_string2.

    CONCATENATE gv_string1 'ghi' INTO gv_string1.

    当如果相等的引用变量不再相等,则系统会开辟新内存区存放新值。

    字符串或内表均遵循该优化原则。

    Unit16 ABAP Open SQL(ABAP Open SQL)

    16.1 Processing and Aggregating Datasets on the Database(处理与聚合数据库中的数据集)

    ORDER BY PRIMARY KEY按主键排序:

    • the FROM clause contains a single database table ( no views or joins )
    • the field list after SELECT contains all the table's key fields ( including the client )(注意: 不一定必须使用select *)

    ORDER BY按某些字段排序:

    • you cannot sort pooled tables and cluster tables simply by any field
    • you can only sort by columns that appear after the SELECT statement
    • you cannot sort by fields with type LCHAR, LRAW, STRING, or RAWSTRING

    SELECT DISTINCT选取不重复数据:

    • the field list cannot contain any column with type LCHAR, LRAW, STRING, or RAWSTRING
    • you must use SELECT DISTINCT * to access pooled tables and cluster tables

    Aggregate Expressions聚合表达:

    • MIN( col ): 求结果集中最小的值
    • MAX( col ): 求结果集中最大的值
    • SUM( col ): 求某列之和,该列必须为numeric型
    • AVG( col ): 求某列平均值,该列必须为numeric型
    • COUNT( * ): 求结果集的行数

    (上述关键字可以配合DISTINCT和GROUP BY使用。)

    跟sy-subrc有关的特殊情况:

    • 如果SQL表达式所有字段都是aggregate functions,此时即使没找到任何数据,sy-subrc = 0且sy-dbcnt = 1(一般情况下找不到数据sy-subrc = 4)
    • 如果SQL表达式只有COUNT表达式,此时没找到任何数据时sy-subrc = 4,找到至少一行数据时sy-subrc = 0

      (1) COUNT特殊是因为COUNT常用来判断数据是否存在,很多非SAP系统会用COUNT( 1 )判断是否有目标数据存在

      (2) SAP系统中为了效率考虑,一般用SELECT ... UP TO 1 ROWS WHERE ...来做存在判断

    GROUP BY分组(配合聚合表达式使用):

    • individual columns are listed after SELECT ( SELECT * is not allowed )
    • No pooled tables or cluster tables
    • the fields after GROUP BY cannot have type STRING or RAWSTRING
    • 可以配合HAVING关键字对各组数据进行筛选

    (更多OPEN SQL细节请参考第三方资料和后续教材内容。)

    16.2 Implementing Complex WHERE Conditions and Special INTO Clauses(实现复杂的WHERE条件和特殊的INTO语句)

    Operators in WHERE Conditions(WHERE条件操作符):

    Operator

    含义

    注意事项

    =, <, >, <= , >=, <>

    EQ, LT, GT, LE, GE, NE

    比较符

     

    IN ( dobj1, dobj2, ... )

    与单值的列表进行IN比较

     

    BETWEEN dobj1 AND dobj2

    居间计算

    对于字符型变量,比较结果受到database code page影响

    LIKE dobj

    通配符计算

    _单值通配符

    %多值通配符

    ESCAPE x忽略某通配符

    IN seltab

    与selection table进行IN比较

    比如select-options,ranges等

    IS [NOT] NULL

    与空值进行比较

    如果透明表勾选了initial value选项,则空值都会被填充,此时用NULL进行比较会找不到对应值

    AND, OR

    与或逻辑

     

    NOT

    非逻辑

     

    注意:

    • ABAP代码中,用+代表单值通配符,*代表多值通配符,且比较用的关键字是CP
    • LIKE '%!_%' ESCAPE '!',这里"!"会让后面的"_"不再被认为是通配符,故这个条件的意思是找到含有"_"的字符串

    AS关键字:

    • 表示取别名(因为AS关键字,一个表可以和自己做join计算)。

    三种SELECT的比较:

    Statement

    Result-Set

    Target Area

    SELECT SINGLE ...

    single-line

    single-line

    SELECT ... INTO TABLE ...

    multiline

    multiline

    SELECT ... ENDSELECT.

    multiline

    single-line

    PACKAGE SIZE关键字:

    • SELECT * FROM sbook INTO TABLE gt_book PACKAGE SIZE gv_number: 这里会每次读取gv_number行数据并覆盖gt_book的数据
    • SELECT * FROM sbook APPEND TABLE gt_book PACKAGE SIZE gv_number: 这里会每次读取gv_number行数据并追加在gt_book后面

    16.3 Using the Features of the New Open SQL Syntax(使用新的Open SQL语法)

    字符拼接的优化:

    传统Open SQL

    新Open SQL

    SELECT id name form

    FROM scustom

    INTO gs_customer.

    gs_customer-full_name = gs_customer-form &&

    ' ' &&

    gs_customer-name.

    APPEND gs_customer TO gt_customer.

    ENDSELECT.

    SELECT id,

    name,

    form,

    form && ' ' && name AS full_name

    FROM scustom

    INTO TABLE @gt_customer.

    注:@在New Open SQL中表示Open SQL中出现了ABAP代码,这里是内表定义。

    SAP NetWeaver 7.50提供的字符串操作函数:

    • length();
    • replace();
    • substring();
    • concat();

    &&与concat()的比较:

     

    Operator &&

    Function concat()

    Number of Operands

    More than two

    Exactly 2 operands

    Maximum Length of Result

    255 characters

    1333 characters

    Type of Operands

    Only elementary, character-like fields

    Character-like fields, String expressions, String functions

    Handling of Trailing Blanks

    Kept in constants and literals, ignored in all other fields

    No special handling

    代数运算的优化:

    传统Open SQL

    新Open SQL

    SELECT carrid connid fldate seatsmax seatsocc

    FROM sflight INTO gs_flight.

    gs_flight-seatsfree = gs_flight-seatsmax -

    gs_flight-seatsocc.

    APPEND gt_flight TO gt_flights.

    ENDSELECT.

    SELECT carrid,

    connid,

    fldate,

    seatsmax,

    seatsocc,

    seatsmax - seatsocc AS seatsfree

    FROM sflight

    INTO TABLE @gt_flights.

    其它常用代数运算包括:

    • +, -, *, /
    • ABS, CEIL, FLOOR, DIV, MOD
    • ROUND

    CAST运算的优化:

    传统Open SQL

    新Open SQL

    SELECT carrid connid fldate seatsmax seatsocc

    FROM sflight INTO gs_flight1.

    gs_flight-percentage = gs_flight1-seatsocc /

    gs_flight1-seatsmax *

    100.

    APPEND gs_flight TO gt_flgiths.

    ENDSELECT.

    SELECT carrid, connid, fldate, seatsmax, seatsocc,

    CAST( seatsocc AS FLTP ) /

    CAST( seatsmax AS FLTP ) *

    CAST( 100 AS FLTP ) AS percentage

    FROM sflight

    INTO TABLE @gt_flights2.

    注:AS后面跟的type,请参考F1 help

    存在性检查优化:

    传统Open SQL

    新Open SQL

    DATA gt_scarr TYPE TABLE OF scarr.

    SELECT * UP TO 1 ROWS

    FROM scarr INTO gt_scarr

    WHERE carrid = 'LH'.

    IF sy-subrc = 0.

    ...

    ELSE.

    ...

    ENDIF.

    DATA gv_check TYPE i.

    SELECT SINGLE 1

    FROM scarr INTO @gv_check

    WHERE carrid = 'LH'.

    IF gv_check = 1.

    ...

    ELSE.

    ...

    ENDIF.

    CASE运算的优化:

    传统Open SQL

    新Open SQL

    SELECT id name custtype FROM scustom INTO gs_customer.

    CASE gs_customer-custtype.

    WHEN 'B'.

    gs_customer-type_text = 'Business'.

    WHEN 'P'.

    gs_customer-type_text = 'Private'.

    WHEN OTHERS.

    gs_customer-type_text = gs_customer-custtype.

    ENDCASE.

    APPEND gs_customer TO gt_customers.

    ENDSELECT.

    SELECT id, name, custtype,

    CASE custtype

    WHEN 'B' THEN 'Business'

    WHEN 'P' THEN 'Private'

    ELSE custtype

    END AS type_text

    FROM scustom

    INTO TABLE @gt_customers.

    SELECT ... seatsmax seatsocc

    FROM sflight INTO gs_flight ...

    IF gs_flight-seatsocc > gs_filght-seatmax.

    gs_flight-overbooked = 'X'.

    ELSE.

    gs_flight-overbooked = ''.

    ENDIF.

    APPEND gs_flight TO gt_flights.

    ENDSELECT.

    SELECT ... seatsmax, seatsocc,

    CASE WHEN seatsmax > seatsocc THEN 'X'

    ELSE ' '

    END AS overbooked

    FROM sflight

    INTO TABLE @gt_flights ... .

    注:我们可以用CASE跟字段名的方法,也可以用CASE WHEN跟逻辑表达式的方法。

  • 相关阅读:
    好文!悟透JavaScript
    关于“四舍六入五成双/四舍六入五留双/四舍六入五单双”等口诀的实例研究
    第四个:怎么应付在背地里说你坏话的人
    为什么日全食时开始下雨,10分钟后雨又停了。初中物理知识。
    吃萝卜去口气(口臭)
    今天12点34分56秒是一个神奇的时刻
    sharepoint2010人性化的地方员工离职AD账号禁用(个人网站自动提醒上级经理功能)
    指定为添加到网站中的项目显示“新”图标的天数。
    解决sharepoint2010的多行文本框的插入图片—【从sharepoint】的disabled问题
    sharepoint2010的IE6不支持的解决方法
  • 原文地址:https://www.cnblogs.com/Intercalaryland/p/10522428.html
Copyright © 2011-2022 走看看