Returning data from Ejb
Here i am creating a J2ee application. In this we accessing BAPIs in stateless session bean using JCO.Now the BAPI is returning the return Table and return Structure to the EJB.
I am coding the following code in one of the Ejb Method as follows:
<b>JCO.Table returnTable = null;
JCO.Structure returnStructure = null;
JCO.ParameterList paramList = siteBAPI.getExportParameterList();
JCO.ParameterList paramList2 = siteBAPI.getTableParameterList();
returnTable = paramList2.getTable("SITE_SUBSITE_INSTL");
returnStructure = paramList.getStructure("BAPIRET2");</b>
Now i want to sent this data( returnTable & returnStructure) to front end application where front end developer accessing this returned data using Jsp.
My scenario is that , first i want to convert this returnTable & returnStructure in a single collection and then return this collection.
My aim is that at the front end the application should not receive the Data, using JCO.table Variable but as Collection
I am using NWDI-2004s sps10.
i need urgent help on this issue and i would really appreciate if somebody can put the answer with some sample code.
As you are trying to pass the Table and the Structure in the form of collection to the JSP page, you can create a javabean with the structure similar to that of the table/Structure.
Lets assume you have a table called Employee with Emp_Name, Emp_Age, Emp_Sal as three columns, create a java class by name Employee which implements Serializable and attributes as Emp_Name, Emp_Age and Emp_Sal. Generate the setters and getters for the same. In your EJB code, create an instance of this Employee class and set the attributes and save it in a HashMap in the form of key value pair, Value being your Employee class instance and key be your Employee Name. Return the HashMap in your EJB code.
Use the HashMap in your JSP. Get the Iterator for the HashMap and Loop through the keys to get the values.
Hope this helps.