cancel
Showing results for 
Search instead for 
Did you mean: 

Passing the return type to the context

Former Member
0 Kudos

Hi All ,

i have one method whose return type is String [] and i want to pass this value to the context's model attribute whose type is String.

Please tell me the way to do it.

Thanks

Sonal

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

HI Sonal,

I assume that the model attribute type is String[] (You have mentioned String)

Let this model attribute name be "A" and it is an import parameter.

You can set the value to this attribute by the following code, before executing the rfc

<RFCName>_Input input=new <RFCName>_Input();

wdContext.node<RFCName>_Input().bind(input);

input.setA(<String array>);

input.execute();//EXECUTES THE RFC

wdContext.nodeOutput().invalidate();

If yo want to pass Array of String (Say arr[]) to a model attribute of type String, then that attribute must be table parameter in RFC, so that, it can accept more than one values (ie. values from String array). This table parameter appear as a model node with one attribute (Say A), where the value will be set.

The value can be added to this from String array by the following code

for(int i=0;i<arr.length;i++)

{

<TableParameteType> t=new <TableParameteType> ();

t.setA(arr<i>);

input.add<TableParameteType>(t);

}

input.execute();

Here u can see <TableParameteType> by checking Right CLick->Properties->Modelclass Property of the node

Hope this helps.

Regards,

Fahad Hamsa

amolgupta
Active Contributor
0 Kudos

hi Sonal,

you can use a Vector or ArrayList for it.

Vector is a collection of objects.

you can put multiple String objects in one Vector object.

google on Vector class to know more about it.

or take up any Java book.... read the collections framework chapter.

regards,

-Amol Gupta