Skip to Content

ABAP News for 7.40, SP08 – Optional Interface Methods

This will be my shortest blog ever (but c’mon its only 10 points worth anyway).

You can make the implementation of interface methods optional now.

METHODS meth DEFAULT IGNORE|FAIL …

All you need to know is documented, what should I write more  😎 .

5 Comments
You must be Logged on to comment or reply to a post.
  • Horst,

    with all of the new functions that are being added to the ABAP language, would it be possible to also introduce an IS INSTANCE OF operator? This could be very handy:

    IF lr_object IS INSTANCE OF if_printable.

      lr_printable ?= lr_object.

      lr_printable->print( ).

    ELSE.

      lr_generic_printer->print( lr_object ).

    ENDIF.

    At the moment, we have to rely on RTTI (cumbersome to write) or TRY-CAST-CATCH-CRASH-implementations which are not really clean either.

    Thanks

      Volker

    • Hi Volker,

      You asked that  before and before 😕 .

      In the moment, the shortest way to write it is:

      DATA oref TYPE REF TO object.

      oref = NEW some_class( ).

      IF CAST cl_abap_classdescr(
           cl_abap_typedescr=>describe_by_name( ‘some_class’ )
             )->applies_to( oref ) = ‘X’.
        ...
      ENDIF.

      I’d like to have an INSTANCE OF too.  I’m not in a position to demand it but I’ll ask for it again 😉 .

      Best

      Horst