ALV入门最近教程,一步一步教你开始你的第一个ALV,参数写的很详细,可入门,查询用An Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKTable of contentsC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKIntroductionHere is the definition for aLV from SAPHelpThe ALv Grid control is a flexible tool for displaying lists. The tool provides common list operations asgeneric functions and can be enhanced by self-defined optionsThe ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As acontrol, it is a component that is installed on the local PcThe ALV Grid control provides typical list functions as sorting, filtering, summing, etc. while alsogives the opportunity to develop user functions where needed. It presents numerous interfaces like ExcelInplace and Crystal Reports.The wrapper class implemented to encapsulate ALV Grid functionality is CL GUI ALV GRidThere is another way to display lists with ALV utilizing"REUSE_ ALV.. " functions. However, that way isnot comprised in this tutorialBuilding BlocksWhile preparing a list to be displayed via an alv grid control, we have some basic components toprepare. These areList data: Obviously, this is the data in an internal table to be listed. Standard aLv functions exceptsorting makes just read access to the list data. However, sorting changes state of the internal table. Theinternal table holding list data may be of any flat type. deep types are only allowed when set for somefunctionalities of alv gridField Catalog: We use another internal table to define specifications on how the fields of our list will bedisplayed. This internal table is called the field catalog". The field catalog must comprise some technicaland additional information about display options for each column to be displayed. There are threeprocedures to generate the field catalog asThe internal table for the field catalog must be referenced to the dictionary type. ayout Structure: We fill a structure to specify general layout options for the grid. With this structure wecan set general display options, grid customizing totals options, color adjustments etc. The layoutstructure must be of typeEvent Handler: We should define and implement an event handler class if we want to handle eventstriggered by the ALV Grid instance. After creating ALV Grid instance, we must register an instance of thisevent handler class to handle alv grid eventsAdditional Data: To trigger some additional features of alv grid we can have some additional data topass as parameters. For example, initial sorting criteria, buttons to be deactivated, etcGeneral schemeNow, we can figure out a primitive scheme to prepare our ALV Grid. As a control object, ALV Gridinstance requires a contain 4 is used for this purpose. Instances of some other container classes suchto be linked to the screen Generally, an instance of the classasmay also be used. In ourexample we take a custom container. To create a custom container instance, we need a custom controlarea on the screenStep 1, Add a custom control on the screen which will be related to the custom container. Lets giveit the nameStep 2> declare global variables to be used for alv gridC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKCode part 1- global data definitions for alvStep 3,Declare your internal table which is supposed to hold the list data. Let's name it"gt listHere is an example declaration.Code Part 2Step 4, Somewhere in your program before calling list display, fill your list data as you want. Hereit is not our concern what the data are. We assume the internal table is filled reasonably. We will use thedata of tableas our list dataStep 5> Call the screen which comprises the ALV Grid control. At PBO of this screen we will dealwith creating the ALV Grid instanceCode part 3Code Part 4-C 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKStep 6> Now, it is high time we wrote something to play. So, this piece will be the one we will dealmainly. What we do is, checking whether an instance of the container (or ALV Grid)exists. If it existsrefreshing it, and if not, creating and setting alv for the first displayFORM display alvC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORKCode Part 5From abap objects, we are familiar withstatement which instantiate classes. Inthis snippet of code, we used two instance methods ofFirst iswhose name implies for what it is used. After creating the ALV Gridinstance we call this method to make our list displayed. We pass list data table, field catalog table, layoutstructure and additional information. Here are parameter definitions taken from SAP LibraryC 2005 SAP AGAn Easy Reference for ALv Grid ControlSAPDEUELOPER NETWORK"global saving onlyuser-specitic saving onlyAcorresponds to X andUSPACE: no savingDefault layouts allowed(default setting)SPACE: Default layouts not allowedAssign a constant attribute of the classwith prefixo this field todetermine the changes to be made to the graphic. Use theattributeexample, to refer to the title of the diagramThe value of the relevant topic, for example, 'My TitleC 2005 SAP AG