Skip to Content
0
Former Member
Jan 28, 2008 at 03:37 PM

Help with Parameter in Function Module

226 Views

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.