14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10

ALV SALV Reporting Framework

Note

Section 10.3 and Section 10.4 of this chapter discusses souping up this method to make

it do “impossible” things, but for now you’ve got the basics.

10.2.3 Report Flow Step 3: Making Application-Specific Changes

(Specific)

You now come to the part of the progra m that will vary wi th each and every

report: the application-specif ic changes. For incredibly simple reports that only

display a read-only representation of every column of an internal table, you may

well have to do nothing here; however, it’slikely that sooner or later the business

users are going to demand something extr a. You achieve this by calling one or

more methods to do things like optimi ze the column widths, change various

aspects of the columns of data, or sort and subtotal the data in a specific way.

Since you are pretty much always going to have to make application-specific

changes, there needs to be a method to do this. Good news; there is! There is a

definition of an APPLICATION_SPECIFIC_CHANGES method in the interface that is

an abstract method in the concrete ZCL_BC_VIEW_SALV_TABLE class; that is, the

method is always redefined by the calling program. Therefore, in the calling program,

you will have code like that in Listing 10.8.

In this code, first the column widths ar e optimized to make them look pretty.

Then, the column definitions are changed in various ways to satisfy various common

business requirements. Next, the code specifies how the data is to be sorted.

Finally, there’s a bucket load of error handling.

CLASS lcl_view IMPLEMENTATION.

METHOD application_specific_changes.

* Local Variables

DATA: lo_error TYPE REF TO cx_salv_msg,

lo_not_found TYPE REF TO cx_salv_not_found,

lo_data_error TYPE REF TO cx_salv_data_error,

ls_message TYPE bal_s_msg.

TRY.

lo_view->optimise_column_width( ).

lo_view->set_column_attributes( :

id_field_name = 'MANDT'

424

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!