Saturday 18 June 2016

ALV using cl_salv_table class

This approach of displaying ALV is way simpler when compared to the earlier approach where we use container and ALV grid classes. We need not to be bothered about creating field catalog or screen container. All we have to follow is few steps mentioned below.
   
1. Use the method “cl_salv_table=>factory”. Pass the internal table in it and it will pass us a reference of type “cl_salv_table”.

2. Further we will get the columns reference (of type “cl_salv_columns_table”) using method “get_columns” of class “cl_salv_table”. This reference we will use if we want to play with the column settings or its display.
Like we can use the “set_optimize” method of class “cl_salv_columns_table” in order to ensure the width of the columns be exactly the size of the longest text to be displayed. No less no more.

3. Also if we want to overwrite the columns header (which otherwise comes as the field label of the dictionary data element), we can do so by first getting the reference of the particular column (this will be of type “cl_salv_column”) using method “get_column” of class “cl_salv_columns_table”, and then use the method “SET_LONG_TEXT” of class “cl_salv_column”.

 In the same way we can modify each and every property of the columns by exploring the methods of the class “cl_salv_column”

4. At last we will use the method “display” of class “cl_salv_table” in order to display the ALV.

5. Now if you test the report, you can see that though ALV is coming, none of the toolbar buttons are coming. For them to come we have to first use the method “get_functions” of class “cl_salv_table”, which will return you the reference of type “cl_salv_functions_list” and then we have to call the “set_all” method of this class.


Result:

Happy learning :)

OOPs ALV using custom container

This tutorial is about creating ALV with Oops methodology. We have to use the container in our screen and that container object will work as the parent object further. Below mentioned steps will be followed.

  1. Call the screen and in MODULE status_<screen_number> OUTPUT we will do all the coding.
  2. Set the PF status
  3. Create a custom controller.
  4. Create an ALV grid object making Custom controller as the parent object.
  5. Prepare the output table and field catalog.
  6. Use method set_table_for_first_display to finally display the table
Start by creating a screen in report and in that screen create a container and give it a name. We can create container by using the “Custom Control” element.


Now do the coding like below.






Execute the code and below is the output.
 

Happy Learning :)