Skip to Content
0
Aug 03, 2016 at 06:34 PM

Method redefinition with differen Returning (Exporting) Parameters

121 Views

Hi all,

please cut me some slack, if this is really basic and I'm missing out on something.

I have a requirement to generate a security code (actually a voucher ID like on a gift card).

For gift card type A the ID should look like this: XXXX-XXXX-XXXX-XXXX-XXXX

For gift card type B the ID should look like this: XXXXX-XXXXX-XXXXX-XXXXX

Now I want to tackle this with ABAP OO. I was thinking of an (abstract?) super class "ZCL_SEC_CODE" with two subclasses "ZCL_SEC_CODE_A" and "ZCL_SEC_CODE_B". There should be a method "get_voucher_id" which should return Voucher Type A when called from "ZCL_SEC_CODE_A" and Voucher Type B when called from "ZCL_SEC_CODE_B".

I know (not saying to be an expert) about facade, factory and the like, but am still having problems with this:

ABAP OO doesn't allow me to create the methods with a different signature for "ZCL_SEC_CODE_A" and "ZCL_SEC_CODE_B". But I actually want (from a client perspective) the methods to be returning say a Char24 for Type A and a Char23 for Type B. Of course I could just use a Char24 for both and write the shorter Type B into that, but that's not my point.

Thanks and cheers

Jens