14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tips and Tricks 11.3

However, it works for you, so you want to keep it. What do you do? You do just

what you would if you had “repaired” a standard SAP program. You use the

Enhancement framework to isolate your change, as described in Chapter 6, and

then when the update happens your change is magically still there.

In this example, go to the standard ABAP2XLSX class ZCL_EXCEL_WOKSHEET in display

mode, and click the Enhancement icon (which looks like a seashell), or press

(Shift) + (F4). Then, right-click the method you want to replace—in this case,

Calculate Column Width—and choose the Insert Over Write Method option

from the resulting context menu, which on ce again is a mix of English and German.

The result is a new column, as seen in Figure 11.16.

Figure 11.16 Adding an Overwrite Exit Method via the Enhancement Framework

Clicking the icon in the overwrite column takes you to a source code editor, in

which you can write some code to to tally replace the standard method. The

replacement method will naturally have the same signature. Delegate the method

call to your own EXTENDER class, which is wher e you can store all your

ABAP2XLSX extension code. The code for this is shown in Listing 11.34.

METHOD iow_zei_excel_extensions~calculate_cell_width.

*"--------------------------------------------------------------*

*" Declaration of Overwrite-method, do not insert any comments here please!

*"

*"methods CALCULATE_CELL_WIDTH

*" importing

*" !IP_COLUMN type SIMPLE

*" !IP_ROW type ZEXCEL_CELL_ROW

*" !IP_CURRENT_MAX type FLOAT optional

*" returning

*" value(EP_WIDTH) type I

*" raising

*" ZCX_EXCEL .

*"--------------------------------------------------------------*

zcl_excel_extender=>calculate_cell_width(

503

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

Saved successfully!

Ooh no, something went wrong!