‎2013 Oct 30 6:53 PM
Hi, i know my question seems weird but what i am asking about is NOT how to create function modules i know how to do that, the functions i mean are the ones like STRLEN() and TRUNC() functions that can be called directly without "CALL FUNCTION EXPORTING something" can somebody tell me how to create functions like that in SAP?
‎2013 Oct 31 1:05 PM
An alternative could be to create static functional methods in a class, like z=>strlen( ).
‎2013 Oct 30 7:08 PM
You might consider using macro's?
But if things fail, you might add up with lot's of code which you can't debug.
So next best thing is to make a class with methods containing the commong functions you need. Or you might apply to SAP Labs to develop some new functionality :-).
Good luck!
‎2013 Oct 30 7:12 PM
Before I forget, you can also create global macro's within table TRMAC. But this is very very very dangerous, since it's able to mess up existing code which might change in how it works when regenerate (variables which contain parts of the global macros when activating them etc. etc.) If you have a real good idea for such a function, you better contact SAP.
As well as in the source code of a program, you can also store macros in the database table TRMAC, where they can be used by any program. The system first searches in the current program for a macro, and then in the table TRMAC. Do not define your own macros in TRMAC. One example of a macro in TRMAC is break, which sets a breakpoint in the system field sy-uname, depending on the current user name.
‎2013 Oct 31 1:05 PM
An alternative could be to create static functional methods in a class, like z=>strlen( ).
‎2013 Oct 31 1:12 PM
‎2013 Oct 31 1:28 PM
This is what I meant to say:
Create global class with a short name, like Z.
Create functional method, that has receiving parameter. Something like cl_abap_typedescr=>describe_by_data( ).
If your class named Z has static function method named strlen( ) that accepts string and returns length, it can be invoked using lv_len = z=>strlen( lv_str ). This is close to
lv_len = strlen( lv_str ).
‎2013 Nov 03 8:28 AM
Its not exactly what i was looking for but it is as close as it gets and its much more code friendly than full function module calls specially if it is being used multiple times throughout the code, Thanks.