cancel
Showing results for 
Search instead for 
Did you mean: 

RFC_ERROR_INTERNAL (when trying to set values on my remote function)

duarte_melim
Explorer
0 Kudos

Hi everyone,

I've been playing with JCo for a few days now, and I got it to work to a certain point, that being, I am able to query my sap tables and add records to them.

My problem is:

I've set a function with two import parameters, let's say USERNAME and PASSWORD, both LIKE two other fields from one of my tables, and an export parameter called return with type C, which is supposed to be 0 or 1. (user good or not)

I ran this remote function in standalone mode and everything works out like I want it to, so guess no problems here.

<i>For clarity sake, i should say i'm not trying to build an authentication remote function like them standard BAPI's so please don't point me in that direction. I don't have R/3 access for the time being, so this is being done on MBS, which, while limited, should be more than enough to fulfill my purposes.

</i>

Unfortunatelly when i try to execute this function from a simple java test app i get the following exception thrown:

[code]com.sap.mw.jco.JCO$Exception: (108) RFC_ERROR_INTERNAL: Internal error: rec->cdata == NULL

[/code]

And this is how i'm trying to do it in Java:

[code]public boolean checkPassword(String username, String password) {

JCO.Function function = getFunction("Z_RFC_CHECK_LOGIN");

JCO.ParameterList listParams = function.getImportParameterList();

listParams.setValue(username, "USERNAME");

listParams.setValue(password,"PASSWORD");

try

{

aConnection.execute(function); // <<<------Exception points here when debugging!

}

catch(Exception e)

{

System.out.println("ERROR -" +e);

//e.printStackTrace();

}

JCO.ParameterList resultParams = function.getExportParameterList();

JCO.Field field = resultParams.getField("RETURN");

String reply = field.getString();

System.out.println("REPLY: "+reply);

if (reply.equals("0"))

return true;

else

return false;

}[/code]

So basically I can't seem to send out values to my RF, and for that matter, nor can i get a return value.

I can, however make the following code work successfully:

[code]JCO.ParameterList stParams = function.getImportParameterList();

JCO.Structure est_clientes = stParams.getStructure("WA_PEOPLE");

est_clientes.setValue("1","PERSON_CODE");

est_clientes.setValue("Duarte", "NAME");

est_clientes.setValue("Porto","ADDRESS");

aConnection.execute(function);[/code]

But, on my <i>problematic</i> previous example, still won't work if I try for example:

[code] JCO.Field p_code = params.getField("PERSON_CODE"); [/code]

and then setting the value with:

[code] p_code.setValue("Duarte"); [/code]

I know the code is kinda junky right now but like i said it's just for testing my skills with JCo for now. Any help on this would be apreciated, thank you in advance for any replies.

Best Regards,

Duarte

Accepted Solutions (1)

Accepted Solutions (1)

prashil
Advisor
Advisor
0 Kudos

Hi Duarte,

I think to call a FM/RFC you first need to create a client of the Backend System.

While creating the client you need to specify the details like Backend system hostname, username and password (used to login to the backend)

This you have to implement before calling a FM/RFC. Once this is created you rest of the code you have written will work fine.

Rgds,

Prashil

duarte_melim
Explorer
0 Kudos

Thanks for replying,

It's working now, it turned out I was wrong about the problem being with my java code.

I basically forgot to set the Remote-Enabled option on my FM attributes.

Imagine how i felt after a full day of head banging on this matter, i guess the joke was on me for today

Anyway sorry if i wasted anyone's time with this, I genuinelly thought i had it all figured out.

Regards,

Duarte

Answers (0)