on 06-01-2005 3:35 PM
Hello,
How to pass a table and structure in a method.
joseph
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
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
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?
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
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.