Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lecture15 abap on line

1,191 views

Published on

Published in: Technology
  • Be the first to comment

Lecture15 abap on line

  1. 1. Lecture 15 ALV Grid Control BCO5647 Applications Programming Techniques (ABAP)
  2. 2. Readings & Objectives <ul><li>Readings </li></ul><ul><li>An Easy Reference for ALV Grid Control (PDF file on WebCT) </li></ul><ul><li>Objectives This lecture will </li></ul><ul><li>Outline the history of the List Viewer in SAP </li></ul><ul><li>Introduce the basic features of the List Viewer </li></ul><ul><li>Review ABAP Objects in preparation to using ALV Grid </li></ul><ul><li>Introduce the features of ALV Grid Control </li></ul><ul><li>Explain how to build a ALV Grid Control application </li></ul>
  3. 3. Key Outcomes <ul><ul><li>To use standard functions in your program that are encapsulated in global classes. </li></ul></ul><ul><ul><li>To learn some basic object-oriented syntax elements of ABAP Objects using the SAP List Viewer as an example. In this context, references to instances of the standard classes CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID are created. The instance of the SAP List Viewer calls the method SET_TABLE_FOR_FIRST_DISPLAY to display a formatted internal table in the SAP List Viewer. </li></ul></ul>
  4. 4. Working with Methods Classes and Objects
  5. 5. Creating Objects and Calling Methods
  6. 6. Application Example: ALV Grid Control
  7. 7. Program with ALV Grid Control
  8. 8. Objects and Classes for ALV Grid Control To call the custom container controls and the ALV Grid Control, the following global classes (object types) are available in the Class Builder : CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID
  9. 9. ALV Grid Control: Important Methods <ul><li>The global class CL_GUI_ALV_GRID contains a large number of methods. To display the contents of an internal table with an ALV Grid Control, all you need to do is to use the following three methods: </li></ul><ul><ul><li>CONSTRUCTOR - the pointer to the container control instance must be passed to the constructor (not used in next example). </li></ul></ul><ul><ul><li>SET_TABLE_FOR_FIRST_DISPLAY - the internal table with the data to be displayed must be passed to the parameter IT_OUTTAB. This must be a standard table so that the user can make use of the sort functions. Furthermore, technical information is required for editing the grid columns. The easiest approach is to use a flat structure or a transparent table, that is, a global type such as the line type for the internal table. In this case, you need only pass the name of this line type to the I_STRUCTURE_NAME parameter. </li></ul></ul><ul><ul><li>REFRESH_TABLE_DISPLAY - you only need to call this method if you have changed the contents of the internal table after the first display. </li></ul></ul>
  10. 10. Display the contents of an internal table on a Screen with ALV Grid Control REPORT sapmz_hf_alv_grid . TABLES: sflight. *-------------------------------------------------- * G L O B A L I N T E R N A L T A B L E S *-------------------------------------------------- DATA: gi_sflight TYPE TABLE OF sflight. *-------------------------------------------------- * G L O B A L D A T A *-------------------------------------------------- DATA: g_wa_sflight LIKE sflight. * Declare reference variables to the ALV grid and the container DATA: go_grid TYPE REF TO cl_gui_alv_grid, go_custom_container TYPE REF TO cl_gui_custom_container. START-OF-SELECTION. SET SCREEN '101'. *&------------------------------------------------* *& Module USER_COMMAND_0101 INPUT *&------------------------------------------------* MODULE user_command_0101 INPUT. CASE sy-ucomm. WHEN 'EXIT'. LEAVE TO SCREEN 0. ENDCASE. ENDMODULE. &quot; USER_COMMAND_0101 INPUT
  11. 11. Display the contents of an internal table on a Screen with ALV Grid Control *& Module STATUS_0101 OUTPUT *&------------------------------------------------* MODULE status_0101 OUTPUT. set pf-status 'GRID'. * Create objects IF go_custom_container IS INITIAL. CREATE OBJECT go_custom_container EXPORTING container_name = 'CONTAINER_1'. CREATE OBJECT go_grid EXPORTING i_parent = go_custom_container. PERFORM load_data_into_grid. ENDIF. ENDMODULE. &quot; STATUS_0101 OUTPUT *&------------------------------------------------* *& Form load_data_into_grid *&------------------------------------------------* FORM load_data_into_grid. * Read data from table SFLIGHT SELECT * FROM sflight INTO TABLE gi_sflight. * Load data into the grid and display them CALL METHOD go_grid->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = gi_sflight. ENDFORM. &quot; load_data_into_grid

×