07-20-2009 11:26 AM
Hi everybody,
that sounds trivial but i am struggeling.... which is the most elegant way to do a implicit "To-String" Conversion in ABAP Objects...
I have e.g.
data lok_string type string.
lok_string = wa.
m_object->addline( lok_string ).
which is working fine but is not elegant comaring with java.
i want
m_object->addline( wa ).
but this don't go when "wa" is a structured workarea with many "type c"s in it (and only these).
but since the explicit assignment "lok_string = wa." is working well, there could be a elegant implicit one?
(m_object->addline expects a string variable.)
Thank is aprreciated.
Regards
Hartmut
07-20-2009 11:54 AM
07-20-2009 11:54 AM
07-20-2009 2:24 PM
sorry, I am getting more clear now, i am searching a conversion method which converts data from a character-structured workarea to a string, and which i can use as a functional method (say as part of an expression), for that i can ommit the help variables in the example above.
Regards
Hartmut
07-20-2009 2:42 PM
something like that ?
class lcl_xxx definition.
public SECTION.
class-methods addline IMPORTING charlike TYPE clike RETURNING VALUE(string) TYPE string.
endclass.
class lcl_xxx IMPLEMENTATION.
method addline.
string = charlike.
endmethod.
endclass.
start-of-SELECTION.
data a type bapireturn.
data b type string.
b = lcl_xxx=>addline( charlike = a ).
07-20-2009 3:07 PM
Hi Sandra,
this is the right direction.... but i would like to have it as an nested expression... (since implicit conversion seams to be impossible)
like...
m_object->addline( lcl_xxx=>tostring( wa_head ) )
but this line above is not an valid abap objects syntax, unfortunatelly
... having:
class lcl_xxx definition.
public section.
class-methods tostring importing charlike type clike returning value(string) type string.
endclass.
class lcl_xxx implementation.
method tostring.
string = charlike.
endmethod.
endclass.
Best regards
Hartmut
07-20-2009 3:13 PM
Unfortunately, we must define intermediate variables. Be patient, nested functions will be available from release 7.10 (or 7.0 from unknown EHP)
07-20-2009 3:18 PM
That is ok for me, i am looking forward having this feature some day
Thanks for your help.
Best regards
Hartmut