cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Model with a structure in import parameter

Former Member
0 Kudos

Hi all,

I need to execute a RFC model which has a structure as an import parameter. How can I populate this structure in WD? The fact is that I have some input fields on my WD View, their values must populate the structure so that at the end I have some rows in my structure. This structure is the input parameter of RFC model (a bapi in ABAP).

Can you help me?

Thank you very much,

Antonio

Accepted Solutions (0)

Answers (2)

Answers (2)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Antonio,

parameters in AdaptiveRFC can be either scalar, structures, or tables. If e.g. an import parameter is a structure, then a getter/setter Method will be provided on the parent class allowing setting the parameter. If the structure itself contains structured fields, these can also be accessed by further setter/getter meth-ods.

<b>NOTE:</b>

<i>Most application developers initially attempt to set the structured parameters in the Web Dynpro context. This IS NOT a successful approach. The problem is, that adding an element to a ModelNode will not fully update the modelObject's parent in the underlying RFC Layer, if the ModelNode has a parentNode.

Simply speaking, don't use the context to set complex input parameters (structures or tables) of RFC objects.</i>

Here is a short example:

<u>Context:</u>

Bapi_Flight_Getlist_Input (Independent node, Cardinality 1:1; ModelClass: Bapi_Flight_Getlist_Input)

Date_Range (dependent node, Cardinality 1:N; ModelClass: Bapisfldra)

Destination_From (dependent node, Cardinality 1:1; ModelClass: Bapisfldst)

Output (dependent node, Cardinality 1:1; ModelClass: Bapi_Flight_Getlist_Output)

<u>Code snippet:</u>

 ...
Bapi_Flight_Getlist_Input input = 
  wdContext.currentBapi_Flight_Getlist_InputElement().modelObject();
Bapisfldra dateRange   = new Bapisfldra();
Bapisfldst destination = new Bapisfldst();

/* DON'T DO IT LIKE THIS

wdContext.nodeDate_Range().addElement(
  wdContext.createDate_RangeElement(dateRange));
wdContext.nodeDestination_From().addElement(
  wdContext.createDestination_FromElement(destination)); */
		
/* DO IT LIKE THIS */ 
input.addDate_Range(dateRange);
input.setDestination_From(destination);
/* this is necessary to resynch the context with the model: */
wdContext.nodeDate_Range().invalidate(); 
/* this is necessary to resynch the context with the model: */
wdContext.nodeDestination().invalidate();
... 

After having done the above, all UIElements bound to the above context will automatically display the data in the modelObjects, and changes in the UI will automatically be transported into the above modelObjects. Therefore, when executing the RFC with the following code, all the above input parame-ters will also be included in the RFC call:

...
try {
  wdContext.currentBapi_Flight_Getlist_InputElement().modelObject().execute();
  wdcontext.nodeOutput().invalidate(); /*this is necessary to resynch the context */
}
catch (WDDynamicRFCExecuteException ex)
{
    /* Error handling... */
}
... 

Regards, Bertram

Former Member
0 Kudos

Hi Antonio,

When u import a RFC model there will be a class which contains the structure along with the input rfc and the output rfc classes.You can declare an object the class containing the structure and set the values to that and bind the object to the input object of the model. You can go through the following link which contains an example:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/web dynpro tutorial and sample applications.faq#q-4

Hope this helps

Regards

Prakash