cancel
Showing results for 
Search instead for 
Did you mean: 

initializing AbstractList Model in Custom Controller

Former Member
0 Kudos

Hi,

My Requirement is Calling ZBapi.I have created

an instance of the input element and binded then while setting the input parameters of Model node ,one of the structure has AbstractList type has input parameter.It is showing package com.sap.aii.proxy.framework.core for AbstractList.

ex:-

req.setPartner(new com.sap.aii.proxy.framework.core.AbstractList();

I am not able to Initialize the Node Element of AbstractList Type,It is giving Error "AbstractList cannot be instantiated ".

I don't see other methods for setPartner with Complex Datatypes.

Is there any way ,i can overcome my Problem.

Thanks & Regards

Madhan

Accepted Solutions (1)

Accepted Solutions (1)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Madhan,

model classes with a n:1 relation to an associating class have an <b>inner</b> class named <model class name>_List. This inner class extends com.sap.aii.proxy.framework.core.AbstractList() and can be instantiated.

<u><b>Example:</b></u>

The model class <b>Bapi_Flight_Getlist_Output</b> has a 1:n relation to the Model Class <b>Babisfldat</b>. The name of this relation is Flight_List (target role 0..n).

The signature of the <i>Bapi_Flight_Getlist_Output.setFlight_List()</i> method is

public void setFlight_List(com.sap.aii.proxy.framework.core.AbstractList list)

When looking at the "target class" <i>Bapisfldat</i> we see an <u>inner</u> class named <i>Bapisfldat_List</i>.

To pass a list of Bapisfldat objects to the Bapi_Flight_Getlist_Output object you must implement something like this

AbstractList flightList = new Bapisfldat.Bapisfldat_List();
    Bapisfldat flight = new Bapisfldat();
    flight.setAirline("LH");
    ... 
    flightList.add(flight);
    Bapi_Flight_Getlist_Output flightOutput =
      new Bapi_Flight_Getlist_Output();
    flightOutput.setFlight_List(flightList);

Allthough this should solve your problem <u>I would recommend another approach</u>. Instead of passing a complete list of target objects to the source object I would better repeatedly add a single object to it. With this approach you do not have to know about this inner class but you can just instantiate single target objects. With this approach the above code looks like this:

   Bapi_Flight_Getlist_Output flightOutput = new Bapi_Flight_Getlist_Output();
    Bapisfldat flight = new Bapisfldat();
    flight.setAirline("LH");
    flightOutput.addFlight_List(flight);
    flight = new Bapisfldat();
    flight.setAirline("UA");
    flightOutput.addFlight_List(flight);

Regards, Bertram

Answers (1)

Answers (1)

Former Member
0 Kudos

AbstractList cannot be isntanden because is abstract type (it must be extends).

Try put some subclasses of AbstractList like Vector or ArrayList.