ABAP 7.40新的关键字BASE的用法

简介: ABAP 7.40新的关键字BASE的用法

*&---------------------------------------------------------------------*

*& Report ZMOVE_CORRESPONDING

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT ZBASE.

DATA:

 BEGIN OF struct1,

   col1 TYPE i VALUE 11,

   col2 TYPE i VALUE 12,

 END OF struct1.

DATA:

 BEGIN OF struct2,

   col2 TYPE i VALUE 22,

   col3 TYPE i VALUE 23,

 END OF struct2.

*This is not the same as

*MOVE-CORRESPONDING struct2 TO struct1.

*Since the RHS does not know anything of the LHS, component col3 of struct2 does not

*keep its former value but is initialized.

" struct2 = CORRESPONDING #( struct1 ).

*Of course, it is a common use case to add new values to existing values. Therefore,

*with Release 740, SP08 there is a new addition BASE for constructor expressions NEW, VALUE

*and CORRESPONDING that allows you to give the expressions a start value.  Very

*often, this means to make the LHS known to a RHS. For the examples shown above,

*  this simply will look as follows:

*

*The result of the expression is initialized with struct2 and then the evaluation takes place.

* Now it works like MOVE-CORRESPONDING, col3 of struct2 keeps its former value.

struct2 = CORRESPONDING #( BASE ( struct2 ) struct1 ).

BREAK-POINT.

DATA itab TYPE TABLE OF i.

itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).

itab = VALUE #( BASE itab ( 4 ) ( 5 ) ( 6 ) ).

"You can als construct structures using BASE:

struct2 = VALUE #( BASE struct1  col3 = 33 ).

"First, all components are taken over from struct1, then the columns specified are overwritten.

BREAK-POINT.

相关文章
|
1天前
|
数据处理 开发者
ABAP AT NEW 关键字的用法
ABAP AT NEW 关键字的用法
29 0
|
1天前
|
存储 自然语言处理 BI
ABAP 关键字 READ TEXTPOOL 的用法介绍
ABAP 关键字 READ TEXTPOOL 的用法介绍
28 0
|
1天前
|
SQL Java 数据库
ABAP 7.40 新语法介绍系列之四 - ABAP Table Expression 内表表达式的用法试读版
ABAP 7.40 新语法介绍系列之四 - ABAP Table Expression 内表表达式的用法试读版
19 0
|
7月前
|
XML 存储 中间件
根据指定关键字搜索指定时间范围内的 SAP CRM 中间件 BDOC 的 ABAP 小工具分享
根据指定关键字搜索指定时间范围内的 SAP CRM 中间件 BDOC 的 ABAP 小工具分享
56 0
|
7月前
|
数据处理
SAP ABAP 里 FILTER 关键字的用法举例
SAP ABAP 里 FILTER 关键字的用法举例
72 0
|
7月前
|
数据库
ABAP MESSAGE 关键字的使用方法
ABAP MESSAGE 关键字的使用方法
44 0
|
8月前
|
数据库
ABAP include structure 的一个具体用法
ABAP include structure 的一个具体用法
92 0
|
1天前
|
前端开发 开发工具 Android开发
小技巧分享 - 使用 Visual Studio Code 查看和修改 ABAP 代码试读版
小技巧分享 - 使用 Visual Studio Code 查看和修改 ABAP 代码试读版
18 0
小技巧分享 - 使用 Visual Studio Code 查看和修改 ABAP 代码试读版
|
1天前
|
开发者 供应链 BI
SAP ABAP CALL SUBSCREEN 代码解析
SAP ABAP CALL SUBSCREEN 代码解析
64 0
|
1天前
|
BI
工具分享 - 将一个 ABAP Function Group 内所有 Function Module 按照代码行数从高到低排序并显示
工具分享 - 将一个 ABAP Function Group 内所有 Function Module 按照代码行数从高到低排序并显示
22 0
工具分享 - 将一个 ABAP Function Group 内所有 Function Module 按照代码行数从高到低排序并显示