‎2007 Jun 15 1:35 PM
Dear All,
I have developed a function module that would convert any '#' in a supplied string to '_'. I have defined the import and export parameters as 'string'.
This function module is getting called only if we call it exporting a variable of datatype 'string' and does not get called if we export a variable whose data type is different from 'string' (say Char20).
One work around is to define another variable with data type 'string' and pass this variable to the function module (after taking the contents of the variable with a different data type into this 'string' variable). But, isn't there a better solution like the SAP standard function module 'string_length' which can be called by exporting a variable of any data type (like char20, char10, num, string etc).
I want this function module to be used in Transformation (in BI) while loading data into an InfoProvider. I may want to remove '#' in 0MATERIAL or 0CUSTOMER or ZCUSTOMER which may have different datatypes and I do not want the user to do the workaround while calling this function module (by creating a variable with 'String') each time.
Please help.
Thanks,
Bajrang
Message was edited by:
Sriram Bajrang Bulusu
‎2007 Jun 15 2:02 PM
Sure, all you need to do is not assign a type to the importing and/or exporting parameters, this makes them generic and they will take the type of what is being pass to it.
So here is a funcitno module, notice there is no type in the signature.
function z_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(I_STR)
*" EXPORTING
*" REFERENCE(E_STR)
*"----------------------------------------------------------------------
e_str = i_str.
translate e_str using '#_'.
endfunction.
So when you call this, you can pass a string, a character field, what ever.
Regards,
RIch Heilman
‎2007 Jun 15 2:02 PM
Sure, all you need to do is not assign a type to the importing and/or exporting parameters, this makes them generic and they will take the type of what is being pass to it.
So here is a funcitno module, notice there is no type in the signature.
function z_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(I_STR)
*" EXPORTING
*" REFERENCE(E_STR)
*"----------------------------------------------------------------------
e_str = i_str.
translate e_str using '#_'.
endfunction.
So when you call this, you can pass a string, a character field, what ever.
Regards,
RIch Heilman
‎2007 Jun 15 2:03 PM