Skip to Content
avatar image
Former Member

Returning data from Ejb

Hi,

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 17, 2007 at 12:51 PM

    Hi Bimalendu,

    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.

    Regards,

    Rekha Malavathu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I agree to Rekha, but to generalize this we can implement a table model with JCO.Table as parameter to the constructor. Retrieve the columns using table.fields() method, column values using table.getString(field), store the details in a Vector and pass to the front end.

      Hope this helps.

      Regards,

      Sunil.

  • avatar image
    Former Member
    Aug 20, 2007 at 04:12 AM

    Hi Bimalendu,

    I assume that the JCO.Table and the JCO.Structure is not a single instance. If that was the case then we would have gone for a Javabean. As it is a table with multiple instances it will be good if we use HashMap. With a single instance of HashMap you may loop through and get the entire list of data.

    Regards,

    Rekha Malavathu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I agree with Rekha.

      if there can be multiple instance of employees at any point of time then the options is to return the collection else passing on the employee class instance.

      Regards,

      Nitin