ABAP UNIT by example

I’m reading Ken Beck’s “Test-Driven Development by example” (a review when I’ll finish it) and I tried to find if there’s a way to adapt it to ABAP.

Yes, it does. Mainly because SAP launched ABAP Unit, a test environment appliable to both programs and classes.

In programs is easy to implement: you must just define a local class FOR TESTING and go on.

In classes… it’s the same, but a bit trickier: take a look at this link from SAP

Let’s try it.
Continue reading

Advertisements

CL_ABAP_BROWSER

Great class to show your HTML strings via dialog box or within a custom container.

Just a trick: if you will use both options within the same program, it will fail if you don’t reset your browser AND the custom container.

It means that you must create a global (sigh) variable for the custom container:

DATA: browser TYPE REF TO cl_gui_custom_container.

And before the call to the dialog version you must free it:

  TRY .
       cl_abap_browser=>close_browser).
       IF browser IS BOUND.
         CALL METHOD browser->free
           EXCEPTIONS
             OTHERS 0"nasty
       ENDIF.
     CATCH cx_root.
       "Nothing
   ENDTRY.

The nasty thing here is the cleansing of SY-SUBRC even when errors occured. You can find a way to make it cleaner, I bet.

But it’s up to you to do it.

Queries about queries (pun intended)

Sometimes shit happens. One receives a work request that seems idiotically simple but the tools provided by the system makes it a living hell.

Something like that happened me these days, because the way someone planned the queries system in SAP.

Because that, I decided to write my troubles and their solutions here, to keep track of them and to have a place to go where I’ll need to manage queries again.

Continue reading