‎2008 Jan 21 12:06 PM
Hi,
I need to create a Logging system to trace input parameters for function modules.
The log functionality could be done by developing a class method or a function module (For example 'write_log'), and calling it within each function module that I want to log. The 'write_log' code should be independent from the interface of the Function Module that I want to log.
For example, I'd like to write a function/class method that can log both these functions modules:
Function DummyA
Input parameters: A1 type char10, A2 type char10.
Function DummyB
Input parameters: B1 type char20, B2 type char20, B3 type char20, B4 type Z_MYSTRUCTURE
Now the questions...
- Is there a "standard SAP" function that provide this functionality?
- If not, is there a system variable in which I can access runtime all parameters name, type and value for a particular function module?
- If not, how can I loop at Input parameters in a way that is independent from the function module interface?
Thank you in advance for helping!
‎2008 Jan 21 12:39 PM
with the FM call the FM FUNCTION_IMPORT_INTERFACE to get the interface signature details of your function , and then using the parameter names, you can get the value from the rutime and log it.
(i am sure there should be a better way - something like system variable giving these info, will look for it and if i find will update)
Regards
Raja
‎2008 Jan 21 12:18 PM
‎2008 Jan 21 1:41 PM
Hi Vikas,
cheers for replying.
Using the SLG1 function group is not essential.
‎2008 Jan 21 12:25 PM
hi tronci,
CONVERSION_EXIT_ALPHA_INPUT
converts any number into a string fill with zeroes, with the number at the extreme right
Example:
input = 123
output = 0000000000000...000000000000123
CONVERSION_EXIT_ALPHA_OUTPUT
converts any number with zeroes right into a simple integer
Example:
input = 00000000000123
output = 123
try.....if it is helpfull please reward me some points
‎2008 Jan 21 12:39 PM
with the FM call the FM FUNCTION_IMPORT_INTERFACE to get the interface signature details of your function , and then using the parameter names, you can get the value from the rutime and log it.
(i am sure there should be a better way - something like system variable giving these info, will look for it and if i find will update)
Regards
Raja
‎2008 Jan 21 1:49 PM
Hi Durairaj,
seems that FUNCTION_IMPORT_INTERFACE provides a way to solve the problem!
I'm going to try this function, and see if I can get all the information I need.
Thank you very much
‎2008 Jan 21 2:44 PM
Using FUNCTION_IMPORT_INTERFACE I'm able to retrieve all the parameters and their type.
Now how can I access the runtime environment to retrieve the value?
‎2008 Jan 22 7:14 AM
check this sample code. here i am capturing only parameters (import) values. you can extend this to capture tables, changin, etc.
FUNCTION y_test_fm.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(PARAM1) TYPE CHAR10
*" REFERENCE(PARAM2) TYPE CHAR10
*" REFERENCE(PARAM3) TYPE CHAR10
*"----------------------------------------------------------------------
DATA: ep TYPE STANDARD TABLE OF rsexp ,
ip TYPE STANDARD TABLE OF rsimp ,
tp TYPE STANDARD TABLE OF rstbl ,
el TYPE STANDARD TABLE OF rsexc ,
vals TYPE tihttpnvp ,
wa_vals TYPE ihttpnvp ,
wa_ip TYPE rsimp .
FIELD-SYMBOLS: <temp> TYPE ANY .
CALL FUNCTION 'FUNCTION_IMPORT_INTERFACE'
EXPORTING
funcname = 'Y_TEST_FM'
* INACTIVE_VERSION = ' '
* WITH_ENHANCEMENTS = 'X'
* IGNORE_SWITCHES = ' '
* IMPORTING
* GLOBAL_FLAG =
* REMOTE_CALL =
* UPDATE_TASK =
* EXCEPTION_CLASSES =
TABLES
exception_list = el
export_parameter = ep
import_parameter = ip
* CHANGING_PARAMETER =
tables_parameter = tp
* P_DOCU =
* ENHA_EXP_PARAMETER =
* ENHA_IMP_PARAMETER =
* ENHA_CHA_PARAMETER =
* ENHA_TBL_PARAMETER =
* ENHA_DOCU =
EXCEPTIONS
error_message = 1
function_not_found = 2
invalid_name = 3
OTHERS = 4
.
IF sy-subrc = 0.
LOOP AT ip INTO wa_ip .
MOVE: wa_ip-parameter TO wa_vals-name .
ASSIGN (wa_vals-name) TO <temp> .
IF <temp> IS ASSIGNED .
wa_vals-value = <temp> .
ENDIF .
APPEND wa_vals TO vals .
ENDLOOP .
ENDIF.
ENDFUNCTION.
‎2008 Jan 22 9:40 AM
Hi Durairaj,
this is exactly what I was looking for, thank you for the help!
Cheers