Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Parameter in Function Module

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

4 REPLIES 4

former_member156446
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

Thanks Nicolas....

You solved my issue.

Thanks again

Mark