Skip to Content
0
Sep 12, 2005 at 12:28 AM

Calling an RFC a second time using the same data

40 Views

Hi,

I have a simple adaptive RFC model that accepts a small table ITAB with 2 fields Personnel Number and Name as well as two importing attributes FCODE and INDEX.

The RFC is written so that if ITAB,FCODE and INDEX are initial it will fill the table with Pernr's. The RFC will then be called a second time with the populated ITAB, a function code "TEST" in FCODE and a line number in INDEX - it will then insert the name of the Pernr located at position INDEX into the Name field of ITAB.

I call the model the first time and it shows the list of Pernr's correctly, I then have some code to populate the model attrubutes FCODE and INDEX when a line is selected and a toolbar button action is triggered. In the RFC I can see that FCODE is set to TEST and INDEX is set to the Lead Selection. But the internal table ITAB is blank even though I haven't refreshed the context model node.

I then guessed that I have to copy the table entries from the Output node to the "input" Node. I copied the entries by using

WDCopyService.copyElements(wdContext.nodeItab_Output(), wdContext.nodeItab());

after the model is called the first time. This did not work and the RFC is still passed a blank ITAB. This must be a pretty common request - to pass the output from a RFC back into the same RFC. How do you do this ?

Here is the code I am using - I use the wdDoInit to call the RFC the first time and then I use the onActionTestAction to call it the second time once the button has triggered the action:

public void wdDoInit()

{

//@@begin wdDoInit()

Z_Wd_Testlist_Input input = new Z_Wd_Testlist_Input();

wdContext.nodeTestRFC().bind(input);

try{

wdContext.currentTestRFCElement().modelObject().execute();

}catch (Exception ex){

wdComponentAPI.getMessageManager().reportException(ex.toString(),false);

}

wdContext.nodeOutput().invalidate();

WDCopyService.copyElements(wdContext.nodeItab_Output(), wdContext.nodeItab());

//@@end

}

public void onActionTestAction(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionTestAction(ServerEvent)

int i = wdContext.nodeItab_Output().getLeadSelection();

wdContext.currentTestRFCElement().modelObject().setFcode("TEST");

wdContext.currentTestRFCElement().modelObject().setIndex(i);

try{

wdContext.currentTestRFCElement().modelObject().execute();

}catch (Exception ex){

wdComponentAPI.getMessageManager().reportException(ex.toString(),false);

}

wdContext.nodeOutput().invalidate();

//@@end