cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in using the RFC model in webdynpro aplication

Former Member
0 Kudos

Hi,

I am trying to access FM CRIF_GET_EMPLOYEE_FOR_USER from the backend system in webdynpro application in two different ways

1.By using JCO classes in a java class

IRepository repository;

public int getPernr(String user)

{

int ret = 0;

String user = "SRESP5";

double pool = Math.random()*100000000;

// the repository we gonna be using

try{

// Add a connection pool for the specified system

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+pool);

JCO.addClientPool(

"DE1", //alias for this pool

100,

// max. number of connections

"540", //SAP client

"", //userid

"", //password

"EN", //language

"sapde1ci.zrh.swissre.com", //host name

"10" //system number

);

// Create a new repository

repository = JCO.createRepository(

"MYRepository", "DE1");

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"ExceptionwwwwwwxSS");

}

catch(JCO.Exception ex) {

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"Exceptionwwwwwwx"+ex.getMessage());

}

//

JCO.Client client =

null;

try{

// Get a function template from the repository

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"SSS");

// wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("ExceptWWWW");

JCO.Function function = repository.getFunctionTemplate(

"Z_CRIF_GET_EMPLOYEE_FOR_USER").getFunction();

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"ddd"+function);

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("ExceptioWWW");

// Fill in input parameters

JCO.ParameterList input = function.getImportParameterList();

input.setValue(user,

"USER_NAME" );

// input.setValue(String.valueOf(new Date()), "BEGINDATE" );

// input.setValue(String.valueOf(new Date()), "ENDDATE" );

// Get a client from the pool

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("ExceptionQQ");

client = JCO.getClient(

"DE1");

// wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Exception");

// Execute function the remote system

try{

client.execute(function);

}catch(Exception e){

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("dd"+e.getMessage());

}

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"Exceptionw");

// Print return message

ret=function.getExportParameterList().getInt(

"EMPLOYEENUMBER");

System.out.println(

"3");

System.out.println(

"RETURN MESSAGE: " + ret);

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(

"SSSWSS");

}

catch(Exception ex) {

System.out.println(

"Caught an exception333: " + ex);

}

finally{

// Always release client !!!

//JCO.releaseClient(client);

JCO.removeClientPool("DE1");

}

// try

return ret;

}

it is returning the PERNR of the username passed as an input parameter.

2.But when I am trying to use an adaptive RFC model and it is giving NO_EMPLOYEENUMBER_FOUND

here is the code

in view

public void wdDoInit()

{

//@@begin wdDoInit()

wdThis.wdGetTestAppController().executeBapi();

//@@end

}

In Controller

public void wdDoInit()

{

//@@begin wdDoInit()

Z_Crif_Get_Employee_For_User_Input input = new Z_Crif_Get_Employee_For_User_Input();

wdContext.nodeZ_cr().bind(input);

input.setUser_Name("SRESP5");

//@@end

}

public void executeBapi( )

{

//@@begin executeBapi()

try{

wdContext.currentZ_crElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

}catch(Exception e){

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("User111:"+e.getMessage());

}

//@@end

}

please help me in solving this issue.points will be awarded for sure for the helpful answer.

Bala

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Change this line of code:

wdContext.nodeZ_cr().bind(input);

to

wdContext.nodeZ_Crif_Get_Employee_For_User_Input().bind(input);

Try executing your application now.

Regards,

Murtuza

Former Member
0 Kudos

i solved it myself.there were some problems with the JCO connections.i fixed them and it fixed the problem

Answers (0)