‎2008 Jan 28 3:37 PM
Friends,
I'm developing a Function, where i have the follwoing code for encrypting a field value
***********************************************************************************************************************
*"----
""Local Interface:
*" IMPORTING
*" REFERENCE(INPUT)
*" EXPORTING
*" REFERENCE(OUTPUT)
*"----
DATA: o_encryptor TYPE REF TO cl_hard_wired_encryptor,
o_cx_encrypt_error TYPE REF TO cx_encrypt_error.
DATA: v_ac_string TYPE string ,
v_ac_xstring TYPE xstring,
v_en_string TYPE string,
v_en_xstring TYPE xstring,
v_de_string TYPE string,
v_de_xstring TYPE string,
v_error_msg TYPE string.
______________________________________________________________________________
v_ac_string = INPUT.
TRY.
CALL METHOD o_encryptor->encrypt_string2string
EXPORTING
the_string = v_ac_string
RECEIVING
result = v_en_string.
CATCH cx_encrypt_error INTO o_cx_encrypt_error.
CALL METHOD o_cx_encrypt_error->if_message~get_text
RECEIVING
result = v_error_msg.
MESSAGE v_error_msg TYPE 'E'.
ENDTRY.
*******************************************************************************************************************
Function module is free from any syntax error, but When i execute the function, i get the following message
*********************************************************************
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught in
procedure "CONVERSION_EXIT_TEST3_INPUT" "(FUNCTION)", nor was it propagated by
a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: "O_ENCRYPTOR").
An object reference must point to an object (an instance of a class)
before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the
CLEAR statement.
**********************************************************************
Now my question is how should i declare the INPUT Parameter, meaning what TYPE or TYPE REF TO
Kinldy try this code and pass on some solutions.
Solutions will be rewarded
Mark.
‎2008 Jan 28 4:11 PM
Thanks for the reply.
But if i use the same code in se38, its working fine. But my requirement is to use the code in a function.
Right now i have not defined any TYPE or TYPE REF TO in the Importing Parameter INPUT . Looks like the System looks for it to be referenced to some thing.
So what should i Rererence the parameter INPUT to
Try using the code,,,,, you will get the issue.
Thanks in advance.
‎2008 Jan 28 3:40 PM
Hi Mark
I am away from my system.. but looking at ur req .. Its feels like you are not handling the exception in some of the FM or the method you are calling.. handle the exception your issue will be resolved.
‎2008 Jan 28 4:11 PM
Thanks for the reply.
But if i use the same code in se38, its working fine. But my requirement is to use the code in a function.
Right now i have not defined any TYPE or TYPE REF TO in the Importing Parameter INPUT . Looks like the System looks for it to be referenced to some thing.
So what should i Rererence the parameter INPUT to
Try using the code,,,,, you will get the issue.
Thanks in advance.
‎2008 Jan 28 4:37 PM
Hi,
I think your problem does not come from FM parameters but from the fact you are calling a method on an object (o_encryptor) that you never created before that !
You delcared the data but never used the CREATE OBJECT statement...
Regards,
Nicolas.
‎2008 Jan 28 4:42 PM