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

How to understand C language and ABAP

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to understand C language and ABAP". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

For example, the sc_km_check_feature_2 decorated with kernel module like the following figure, and each ABAP keyword, the C language implementation code of each keyword can be seen in the Netweaver system within SAP, but on the customer system, it is stored in the form of binary object files, and the source code cannot be viewed.

The purpose of this article is to deepen ABAP consultants' understanding of the language through some introduction to the C language and the ABAP compilation process.

Write a Hello World program in C language and save it as study.c:

Compile with the command line gcc. / study.c-- verbose, and the parameter verbose allows us to view the compilation details. The above command line produces a long string of output on my Ubuntu system:

We can analyze it step by step. First, use the parameter-E to view the target file study.i generated by preprocessing:

Gcc-E study.c-o study.i

You can see that the source code file is only 78 bytes, and the output file generated after compilation preprocessing is 17116 bytes.

Why did it swell so much? The reason is that in the first line of my source code file, # include is replaced by the preprocessor with the actual content of stdio.h, and if there is a declaration of # include other files in stdio.h, the replacement process is performed recursively. So we can't see the part of the source code written in study.i until the end of the study.c.

The first line of the statement # include in the source code file study.c, please remember that ABAP will be mentioned later.

With the command line gcc-S, you can view the assembly code generated after study.c compilation:

Seeing these pushq, popq,% rbp,Jerry, I can't help thinking of the time when my other brothers and I sat in the last row of the classroom reading Sports Weekly in the undergraduate assembler programming class.

After working for more than ten years, Jerry has to admit that the computer courses offered by undergraduates at that time, such as data structure, operating system, computer composition principles, compilation principles, assembly programming, computer graphics, are all useful. After work, the company can no longer give you time to learn these basic theories.

Although Jerry didn't study assembler programming well at first, at least I kept the textbook properly in case the company's work schedule required me to pick up what I learned in school more than a decade ago.

Let's talk about ABAP.

SAP note 1230076 "Generation of ABAP loads: Tips for the analysis" introduces a tool program: RSDEPEND. This note mentions that even the simplest ABAP Hello World report actually depends on many standard Repository objects, which we hypothetically call AMagi BMagee C. Suppose any of the changes have been made in AMagol BBQ C. for example, An is an include program that uses a DDIC structure. At some point, the system imports a transfer request (Transport Request) that contains changes to the DDIC structure. Then the load of the simplest Hello World report becomes the obsolete state. Before re-executing the report, ABAP Runtime (translated into ABAP runtime) automatically does a load invalidation operation to generate the latest version of load.

What is ABAP load? Look at the official definition in ABAP help:

"In the ABAP environment, a load describes a binary representation of a repository object which is optimized for fast access, in the memory or on the database."

ABAP load is a binary representation of Repository objects, specially optimized for fast access to the ABAP environment, and can be stored in database tables or loaded in memory.

Let's use a practical example to understand what happens when ABAP reports are activated and run.

Create a very simple transparent table ZLOADTEST:

Write a simple report named ZTESTLOAD. The source code for the report is stored in the DATA field of the table REPOSRC in a compressed format.

The source code of the test report is very simple, reading all the data in the table:

Activate this simple report (yes, in the ABAP world, we used to say activate, not compile). The ABAP load generated after activation is stored in the fields LDATA and QDATA in the table REPOLOAD.

The contents of these two fields are stored in the form of ABAP load stored in the database table mentioned earlier by ABAP help.

Menu Goto- > Navigate to- > Switch to Classic Debugger:

Goto- > System Areas- > Internal Information:

Type CONT in the System Area field and you can see the instructions contained in ABAP load in the NAME column of the figure below. Of course, unlike the open source JVM, the JVM bytecode instruction set can be found online, and these ABAP load instructions are SAP internal, so they cannot be explained here.

Then execute the tool report RSDEPEND mentioned earlier, enter the parameter program name = ZTESTLOAD, and get the result, where the ABAP Load timestamp of the test report is 07:21:02, and the standard Include that this report depends on is:

DB__SSEL

As you can see, every standard ABAP report automatically contains these include. If the developer explicitly includes any of them, he will encounter a syntax error: Module% _ PF_STATUS is already defined as an OUTPUT module.

Do you think this is very similar to the # include mentioned in the C language section above?

Let's do a few more rounds of tests.

Test 1

Modify the description of the transparent table, and then reactivate the transparent table.

When you execute RSDEPEND, you can see that only the Last Changed field of the transparent table has changed, and both ABAP Time Stamp and Screen Time Stamp remain the same, which is what we expect, because we have only modified the description of the transparent table, not the structure.

Execute the test report ZTESTLOAD again, and check with RSDEPEND, and find that the ABAP Load timestamp of the test report has not changed, which shows that even if the description information of the dependent transparent table changes, the ABAP report using the transparent table does not need to be recompiled, because the transparent table description information does not need to be used during the report execution period.

Test 2

Add a new column to the transparent table and activate it again.

At this point, through RSDEPEND, it is found that all three timestamps of the transparent table have changed, as shown in the blue rectangle shown below. However, the timestamp of the test report ABAP Load itself remains the same, which is reasonable, because the test report has not been executed after we have added new columns to the transparent table.

After executing ZTESTLOAD again, it is found that its ABAP Load has been automatically invalidate, and the timestamp has changed from 07:21:02 to 07:36:02.

This also explains a phenomenon: some friends have observed that when the system is just upgraded, or after a batch of new transmission requests are imported into the system, the response speed of the system is very slow when the SAP application is used for the first time. In fact, the reason has been explained by the previous two tests: the system takes the time to do the relevant ABAP Load invalidation. The system cannot respond to user requests until the Load invalidation on which the application depends is completed.

To prevent users from waiting for a long time when using the application for the first time, you can use the transaction code SGEN to Load invalidation in advance.

This is the end of "how to understand C language and ABAP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report