Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What variable names are supported by the ABAP development environment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "which variable names are supported by ABAP development environment". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian to study and learn "which variable names are supported by ABAP development environment" together.

Jerry entered SAP Chengdu Research Institute, has been using C/C++ development, so just contact ABAP, for her case sensitive in some syntax environment, some environment insensitive characteristics are very uncomfortable. Jerry was nostalgic for the hump and Hungarian nomenclature he had followed in C/C++ programming.

Hump nomenclature: Each logical breakpoint in the function name is marked with an upper case letter. Method and variable names are usually lowercase, which is called small hump nomenclature, such as printEmployee Paychecks. Class names are usually capitalized, which is called big hump nomenclature, such as Employee BonusPlanManager.

Hungarian nomenclature: variable name = type + description. A type is usually prefixed with one or more lowercase letters followed by one or more words describing the purpose of the variable.

Suppose there is a simple ABAP code that reads data from a CDS view named I_Product into an internal table lt_table via OPEN SQL.

ABAP variable names are case-independent. The red underscore lt_table in the figure below is an example of "Hungarian nomenclature + underscore nomenclature." lt is an abbreviation for local table, indicating that this variable is a local table variable.

Usually we expect variable names in ABAP to be uniformly lowercase. To do this, just open the Pretty Printer configuration page in ABAP Editor settings of SAP GUI and check Keyword Uppercase.

In this way, when we use the Pretty Printer provided in the IDE, that is, the code beautification function, even if there is a mixed case in the ABAP variable, it will be automatically converted to lowercase.

However, this behavior of Pretty Printer causes a small problem. If the code accesses a CDS view, such as I_Product in the example, because it is not an ABAP keyword, it will also be converted to a combination of all lowercase letters: i_product.

At the time we weren't happy with this behavior, because according to our internal development specifications, the first letter of CDS view and the first letter after underscore must be capitalized. The expected result is that when Pretty Printer executes, the CDS view name in the code will still be I_Product, instead of the current i_product.

Jerry then came up with a way to modify Pretty Printer's processing logic: if the word scanned in the code represents a CDS view, let Pretty Printer hold back and do nothing with the word.

I shared this approach with the SAP community:

Bypass CDS view name case conversion in ABAP source code pretty printer

Test results: ABAP variable names underlined in red are automatically formatted to all lowercase, while the CDS view name I_Product remains unchanged. This is exactly what we expected.

Two years passed. Today, there is an elegant solution to this problem: to use hump nomenclature, simply check the box in front of Keep Camel Case Identifiers in the ABAP Development Tool.

You can compare the effect of this tick if it is not marked:

This means that ABAP developers who prefer hump nomenclature can now write ABAP code with IDE support.

ABAP developers on the SAP community claim this is a feature they've been waiting for:

Note: This feature is currently only available in S/4HANA and SAP Cloud Platform ABAP programming environments.

Thank you for reading, the above is "ABAP development environment supports which variable names" content, after the study of this article, I believe we have a deeper understanding of what variable names ABAP development environment supports, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report