cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent : Use of WDCopyService for passing table parameters

Former Member
0 Kudos

Hi Experts

I have 2 tables on my Iview which have data as below

1) Task table containing task id & checkbox. This is a table parameter of RFC A

2) Resource table containing resourceid & checkbox. This is a table parameter of RFC B

I want to pass these 2 tables as table parameters to RFC C for updating the task allocations in the backend - for the tasks selected in task table & resources selected in resource table. The code written till now was containing for loops on both table to fill the table parameter of RFC C - this is taking lot of time.

Alternatively WDCopyservice can be used to copy the nodes. The code written till now is as below

Z_Nits_Task_Freeresources_Input objallocfin = null;

try

{

WDCopyService.copyElements(wdContext.nodeZ_Nits_Resource_Task_Prtasks_Input().nodeOutputT().nodeT_TasksOIT(),wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_TasksFI());

WDCopyService.copyElements(wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeOutputF().nodeT_ResourcesFO(),wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_ResourcesFI());

int Size = wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_ResourcesFI().size();

int Size1 = wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_TasksFI().size();

wdContext.currentContextElement().setErrtext("res table size is"+Size);

wdContext.currentContextElement().setErrtext2("task table size is"+Size1);

objallocfin = new Z_Nits_Task_Freeresources_Input();

I am getting the correct sizes in the 2 fields displayed on the iview after the copy statements.

My problem is I am not sure how to bind the copied nodes to the object and execute the RFC.

Before I used to use .add for adding the data row-by-row into the table parameter of the RFC C and then bind it to the object objallocfin.

I am not sure how to do the bindings when WDCopyservice is used.

Please suggest.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Maksim for your reply. I will certainly try that out.

But I would still like to avoid the use of for loop.

How do I link the copied nodes to the model for execution of the RFC.

Do let me know if you have any ideas

former_member182372
Active Contributor
0 Kudos

Hi Sanjay,

As far as I understood you requirements you need to pass only selected items. So, anyway you need to iterate through model nodes to filter only selected elements. With my approach you just re-assign instance of model object to another node.

BTW, WDCopyService implicitly iterates through node lements.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

I need to pass a structure as a table parameter to the RFC.

This structure needs to hold multiple rows.

Currently I am using the below mentioned LOC.

<b>wdContext.currentZesstest1_InputElement().modelObject().addZpernr1(objESSTable);</b>

However the above code works when the structure objESSTable has single of data.

For setting multiple rows of data I tried to use the below code:

<b>wdContext.nodeZesstest1_Input().nodeZpernr1().bind(objVector);</b>

Here objVector is object of Vector class holding multiple rows of the sturcture objESSTable.

But this is not working.

Please help!!

former_member182372
Active Contributor
0 Kudos

Hi Sanjay,

Try this:


IWDNode node = wdContext.nodeZ_Nits_Resource_Task_Prtasks_Input().nodeOutputT().nodeT_TasksOIT();
int size = node.size();
int leadSelection = node.getLeadSelection();

final Collection modelObjects = new ArrayList(size);
for (int i = 0; i< size; i++)
{
	final IWDNodeElement element = node.getElementAt( i );
	final int idx = element.index();
	if( leadSelection == idx || node.isMultiSelected( idx ) )  {
		final Object model = element.model();
		modelObjects.add(model);
	}
}

wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_TasksFI( modelObjects );

node = wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeOutputF().nodeT_ResourcesFO();
size = node.size();
leadSelection = node.getLeadSelection();

modelObjects = new ArrayList(size);
for (int i = 0; i< size; i++)
{
	final IWDNodeElement element = node.getElementAt( i );
	final int idx = element.index();
	if( leadSelection == idx || node.isMultiSelected( idx ) )  {
		final Object model = element.model();
		modelObjects.add(model);
	}
}

wdContext.nodeZ_Nits_Task_Freeresources_Input().nodeT_ResourcesFI( modelObjects );

Best regards, Maksim Rashchynski.