cancel
Showing results for 
Search instead for 
Did you mean: 

Passing table, structure in method

Former Member
0 Kudos

Hello,

How to pass a table and structure in a method.

joseph

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use collections in java.util package and using this u can pass structures.

Is this wat u want?

If yes ...go to parameters of method and select a java native type java.util.* ..whatever chooses ur requirement?

IF this does not suit u requirement ,please elobarate the scenario..

Regards

Bharathwaj

Former Member
0 Kudos

If you need to pass table or structure to RFC or BAPI refer the following link

Former Member
0 Kudos

if u want to pass a table to a method, one way of achieving it is thru a LinkedHashMap.

Give the type of the parameter as LinkedHashMap

private LinkedHashMap map = new LinkedHashMap(linkedHashSize);

int hashKeyInt = 1;

for(loop thru the table)

{

<Table Class> tableObj = new <Table Class>;

tableObj .set<attribute1>(<value>);

.

.

map.put(String.valueOf(hashKeyInt), tableObj);

hashKeyInt++;

}

When calling the method, pass 'map' as the parameter.

<method>(map);

At the other end(inside the called method), the values can be retrieved thru an Iterator.

Iterator iteratorHashMap = map.values().iterator();

while (iteratorHashMap.hasNext() == true)

{

<Table Class> = (<Table Class>)iteratorHashMap.next();

}

Former Member
0 Kudos

Ok,

So let assum that I'm in my <b>view</b> and got this code:

Bapif4B bapiSelection = new Bapif4B();

ArrayList selection=new ArrayList();

for ...{

bapiSelection.setSelect_Fld(<Value1>)

bapiSelection.setLow(<Value2>);

bapiSelection.setSign("I");

bapiSelection.setOption("EQ");

selection.add(bapiSelection);

}

Now in My controller I got a method that accept parameter of type ArrayList.

public void getValWithSelection( java.util.ArrayList <b>selection</b> )

{

//@@begin getValWithSelection()

Bapi_Helpvalues_Get_Input input = new Bapi_Helpvalues_Get_Input();

wdContext.nodeBapi_Get_Shlp_Val_input().bind(input);

now what I'm doing with the parameter <b>selection</b>?

I want to pass the parameter <b>selection</b> to input.addSelection_For_Helpvalues().

Hope that's clear

Thank you

Joseph

Former Member
0 Kudos

Hi Joseph,

What is the type of your parameter in input.addSelection_For_Helpvalues()?

Is it requires Abstractlist or any structure?

Let me know.

Regards,

Bhavik

Former Member
0 Kudos

for(loop thru the arraylist until arraylist.size())

{

Bapif4B obj = (Bapif4B)arraylist.get(index);

input.addSelection_For_Helpvalues(obj);

}

Hope this helps

Former Member
0 Kudos

hi Bhavik,

input.addSelection_For_Helpvalues() required a structure Bapif4b.

Thank you

Former Member
0 Kudos

thank you it works...but...

when i add value to my array list and loop after on this list, i retreive only the last item... this is how i initialize the array list:

Bapif4B bapiSelection = new Bapif4B();

ArrayList selection=new ArrayList();

for...{

bapiSelection.setLow(valueToSearch);

bapiSelection.setSign("I");

bapiSelection.setOption("EQ");

selection.add(bapiSelection);

}

there is a problem?

Former Member
0 Kudos

I Think Bapi Selection shuld be instantiated inside the for loop

Former Member
0 Kudos

Hi Joseph,

Did you checked what is the size of the arraylist in for loop for retrieving values.

Make change in your code as follows:

ArrayList selection=new ArrayList();

for...{

Bapif4B bapiSelection = new Bapif4B();

bapiSelection.setLow(valueToSearch);

bapiSelection.setSign("I");

bapiSelection.setOption("EQ");

selection.add(bapiSelection);

}

initialize your object in the for loop.

Let me know.

Regards,

Bhavik

Former Member
0 Kudos

hi Bhavik,

it's working.

(Sorry i can't give you more than 2 points)

joseph

Answers (0)