Skip to Content
0
Former Member
Oct 25, 2005 at 04:47 PM

ABAP OO: methods as method params, method chains

132 Views

Hello all,

I am currently developing quite much ABAP OO and wonder if this is possible, because I got compilation errors.

a) Methods as method params w/o temp vars:

I have a method whose parameter shall be the return value (let s say a string) shall be the parameter:

document->set_owner( owner = person->get_name( ) ).

This throws an error and I have to code this instead ๐Ÿ˜”

data: owner type String.
ownerString = person->get_owner( ).
document->set_owner( owner = ownerString ).

... so I have always a temp variable which is getting MUCH overhead when having such stuff often...

Am I doing wrong or is this impossible in ABAP OO? ...am used to do such things in all other languages I know... mean, that methods can be params of other methods.

b) "chaining of methods"

Is this possible somehow?:

data: tmp type String.
tmp = employee->get_orgUnit( )->get_name( ).

Calling one level (the get_OrgUnit() method) works fine, but an immediate call to the second level ( get_name() method) fails and I have to code this:

data: tmp     type String,
      orgUnit type ZOrgUnit.
orgUnit = employee->get_orgUnit( ).
tmp = orgUnit->get_name( ).

This also very annoying to have so much temporary help variables on the way.

Is there any help for me? ๐Ÿ˜Š

Thank you for any hints and reagrds,

Timo