ABAP report Design

Source: Internet
Author: User
The ABAP report is sap add-on. Program Most of the logic is implemented using report. After more than two years of SAP, I have found myself a "shanzhai". Although there is no limit between abaper and consultant in the company, everyone is doing everything. However, since it feels professional, although I think abaper has no "money. To put it bluntly, we should start with improving program readability.
Include is a good way to improve the readability of the program. Article . Pai_^

(From http://blog.sina.com.cn/s/blog_5116d3ba0100efx2.html)

 Let's talk about the report development ideas. Through recent studies, I still have some ideas.

 The main logic of self-developed reports is to rely on the selection of on-screen fields, that is, to provide users with the selection criteria for their desired results. Among them, the most important is the required field, because the required field is the essence of the number logic, it can be cleverly limited by many unnecessary situations, reduceCodeThe developer's Development volume also allows users to get the most direct and quick presentation results related to the actual business.

 For writing the code of a report program, there are usually several include. (X represents any custom letter)

 Report zxxxxxx.

 IncludeZxxxx_init.

 IncludeZxxxx_f01.

 IncludeZxxxx_block.

Many of them are personal habits, but there are some habits that allow others to read or modify your programs quickly and follow the rules.

Include zxxxxx_block.

There are just the following parts

Initialization. (initialization. The event blocks that run only once before all the following event blocks are run)

At SELECTTION-SCREEN output. (PBO event block)

At Selection-Screen On Value-RequestFor Select a field name. (Custom Search Help event block)

At selection-screen. (PAI event block)

Start-of-selection. (program running event block)

PS (my personal opinion): There are many types of programs in SAP. in particular, there are two types of reporting programs: executable programs (beginning with report) and module pool (beginning with progarm.

So what are their differences? There are teaching materials to explain that sap's ABAP development is event-driven development. This is similar to VB. However, it is precisely this sentence that explains the inevitable structure of the SAP program. For event-driven, the SAP program must be triggered by events to execute the program. When we use se38 to create a type 1 executable program (starting with eport) we can directly debug such a program. We will find that this program is executed in sequence according to the sequence of the event blocks I have written. The sequence of event blocks is specified. So we can run the f8. When we create a module pool, we cannot execute it because it needs to use tcode to specify the runtime entry. Generally, screen is created in the module pool. there will be two event blocks in a screen, PbO and Pai. we use a large number of screens, tablecontrol controls, or subscreen range controls to nest various subscreens, all of which require the connection between PAI and PBO, in the pai of a screen, there must be a call screen or call subscreen... nvidig .... command to call another screen or sub-screen, and then the other screen first runs PbO, there is an operation on the screen, the operation is executed by the screen Pai. I personally feel that this kind of flexible writing method makes it impossible for programs of this type (module pool) to directly F8 and the compiler to get where the program starts, tcode specifies the screen from which to start.

My predecessors are generally used to the following habits.

 1. IncludeZxxxx_init.

 Enter the first include of the program.

PS (personal opinion): What is include? (Cr: The generated request number. It can also be understood as the code version of a program. All sap programs are in the D system and then passed to Q (test) the system is tested by a consultant without interfering with the program running of the production system. Then, it is uploaded to the P (production) system, overwriting the original code and changing the code logic.) Well, I think it is an encapsulated idea. I will study that it produces Cr independently, but it is not associated with its main program. This is also inevitable, because include is a global declaration of the whole system. Once you get a name, other people can also reference it, as a result, its Cr modification is generated independently.

 

Here we define various structures that only take effect in this program, such as types definition types. Data .. type can be used only after the type defined by types is used.(The types type). Data is used to define the structure. We can only use like to define a structure similar to that of data....Like (data structure ).

Then there is the definition of select-screen.

 

2. Use perfrom to encapsulate code, get meaningful names, and then drop all forms

 IncludeZxxxx_f01.

3. In start-of-selection, we usually write the following performs,

 Preform sub_get_data. (number logic)

 Perform sub_data_process. (process the Retrieved Data and display it in the desired format)

 Perform sub_build_alv. (create ALV display format)

 Perform sub_show_alv. (call the ALV function)

 

So far, the framework of a report program has come out. Of course, pay attention to using macros and other small places to save the number of lines of code.

Try to reuse code as much as possible. Note that the variables defined in form will be released by the system and the memory space will be reclaimed after the form is left.

In particular, it should be noted that the luw concept in bc414 (database update rollback, if multiple screen operations lead to implicit commit of database statements, this leads to a deviation from the nothing or all principle and failure to perform full data rollback. perorm is also used... on commit and other methods can be used to temporarily stop the implicit dB commit). It is very interesting to interlock with the database tables used by standard programs (Approval Procedures) (the concept of SAP locks .) (This explains the advantages of the DB commit option in BDC. Instead of terminating the current screen recording operation, the Commit-like controls will be skipped .) (Bc414 fully explains the sap work framework and some basic load balancing concepts.

SAP program optimization is the scope of bc490. It has been busy recently and has not been studied yet. bc414 is the basis.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.