SAP ABAP Advanced Cookbook
上QQ阅读APP看书,第一时间看更新

Introduction

This chapter explores recipes related to the ALV displays. We will start with a simple requirement with basic ALV displays. We will then enhance the basic ALV program by hiding few columns from display as well as from the initial layout. We will then see a recipe showing how to save user-specific layouts. Adding buttons to standard ALV toolbars will be shown, along with checkboxes and hotspots displayed within ALV columns.

For this chapter, I assume that the reader has basic knowledge of the ABAP objects, the ALV object model, and is familiar with basic ALV creation using CL_SALV_TABLE. Also, the reader should have knowledge of creating and changing of GUI status, and should have knowledge of Ranges and Select-Options.

For the sake of this chapter, we will make a simple example that will display data into an ALV format. This will be used in all the recipes mentioned in this chapter.

Introduction

In this example, we declared a data structure type containing simple important fields of table PA0008. We then declared an internal table and a work area based on this type.

We selected 15 rows from the table PA0008 and stored them in the internal table.

The factory method is then called of the class CL_SALV_TABLE for instantiating the ALV object. The GET_COLUMNS method is called in order to get the columns object of the ALV. The SET_OPTIMIZE method of the columns object is used to optimize the column width.

Likewise, the GET_FUNCTIONS method provides access to the ALV's functions' objects. We then set all the functions using SET_ALL method. Finally, ALV is displayed using the DISPLAY method.

Introduction

Note that until this point, the ALV toolbar does not have a layout save button. No fields are defined as keys (no blue colour). The Amount column displays 0.00 and not blank in case the value is initial. No hotspots or checkboxes are enabled in the columns. In the next set of recipes, we will see systematically how each of these options may be added.