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.

11

ABAP2XLSX

runtime type identification works out what type of object is being passed in and

creates an appropriate CONVERTER object (if one exists for that class). This means

that if a new UI technology comes along you only have to create a new subclass

for the purposes of conversion to Excel.

In your custom report program, the four steps to spreadsheet heaven are as follows:

1. Create your report object (SALV/CL_GUI_ALV_GRID), and choose your formatting

options for displaying this within SAP.

2. Convert the report object into an Excel object by using the built-in CONVERTER

class.

3. Use the ABAP2XLSX methods to add further spreadsheet-specific formatting

options, such as print settings, conditional formatting, and the like.

4. Download the spre adsheet, email it out, or op en the spreadsheet in place

within the SAP GUI.

11.2.2 Changing Number and Text Formats

I have a horrible confession to make. For the first seven years of my career, I had

nothing to do with IT; I was—dramatic pause—an accountant. I did bank reconciliations,

looked after fixed assets, and administrated the payroll for truck drivers,

and my working life revolved around month end.

Although I much prefer programming, my experience with accounting enables

me to empathize with business users who are themselves accountants. The first

thing an accountant will usually do with a spreadsheet he has generated from out

of SAP will be to change the formatting so that negative numbers are (a) red and

(b) surrounded by brackets. Zero values have to be replaced by dashes. The currency

sign needs to be added for values relating to money. Only then is the report

fit to be looked upon by human eyes.

In Section 11.2.1, you converted your SA LV report into an Excel object. Now,

you’ll start making application-specific changes—in this case, changing all the currency

amounts into the format that acco untants like. First, you need a bunch of

data declarations; these ar en’t very exciting, but th ey are presented in Listing

11.6 for completeness.

468

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

Saved successfully!

Ooh no, something went wrong!