cancel
Showing results for 
Search instead for 
Did you mean: 

Sap JCO with Servlet

Former Member
0 Kudos

Hi All,

Trying to fetch data from sap server using JCO,Below is the Code, and i am giving correct username, password and hostaddress.

i am unable to fetch the data from Sap server.

Function module ---ZLBSFUNCTION

Table name---- ZLBS_EMMOBILE

Name,Plotnum,City,State,Citycode,Country are the Field of the table...

Function Module is as Below

FUNCTION-pool ZLBSFUNCTION .

*"----


""Local Interface:

*" IMPORTING

*" VALUE(NAME) LIKE ZLBS_EMMOBILE-NAME

*" TABLES

*" ITAB STRUCTURE ZLBSEM

*"----


FUNCTION ZLBSFUNCTION.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(NAME) LIKE ZLBS_EMMOBILE-NAME

*" TABLES

*" ITAB STRUCTURE ZLBSEM

*"----


SELECT NAME PLOTNUM STATE CITY CITYCODE COUNTRY FROM ZLBS_EMMOBILE into TABLE ITAB .

ENDFUNCTION.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Servlet code is as Below

IRepository repository;

try

{

// add a connection pool to the sap system

JCO.addClientPool(LBS,10,"100","USERName","Passwd","EN","Host name","00");

repository = JCO.createRepository("myRepository",LBS);// new repository

IFunctionTemplate ftemplate = repository.getFunctionTemplate("ZLBSFUNCTION");

JCO.Function function = new JCO.Function(ftemplate);

JCO.Client client = JCO.getClient(LBS);

JCO.ParameterList input = function.getImportParameterList();

client.execute(function);

JCO.Table dataTable = function.getTableParameterList().getTable("ZLBS_EMMOBILE");

for(int i=0;i<dataTable.getNumRows();i++){

dataTable.setRow(i);

if(dataTable.getString("Name")=="star"){

out.println(dataTable.getString("Name"));

out.println(dataTable.getString("Plotnum"));

out.println(dataTable.getString("City"));

out.println(dataTable.getString("State"));

out.println(dataTable.getString("Citycode"));

out.println(dataTable.getString("Country"));

} //end of if.

} //end of for

} //end of try

Would like to know anything Wrong with this Code,,, or anything Else That we need to code.........

Please help us....

Thanks and Regards

Preethi

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Preethi,

Can i know what is the error you are getting from the servlet.

Are you able to get the data from the Backend to Client.

Cheers,

Karthick

Former Member
0 Kudos

Hi all.........

Thanks for your reply........

I resolved it on my own. yes i am getting the data from backend to client.

there was a problem in my function module.

Regards

Preethi

Former Member
0 Kudos

hi,

which type of error it is giving

regards

Guru