cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set multiple values in structure model

Former Member
0 Kudos

Hi,

I'm new in web dynpro for java development and I have a problem to save data using RFC model. This RFC can save multiple values (is structure type table). I tested my RFC in SAP and works fine but when I execute the RFC in web dynpro app the values are not saved. The sample code used in wdDoModifyView is:

...

IWDInputField inputField_name = (IWDInputField)view.getElement("inputName");

IWDInputField inputfield_surn = (IWDInputField)view.getElement("inputSurn");


wdContext.currentAuthorElement().setName(inputField_name.getValue().toString().trim());

  wdContext.currentAuthorElement().setSurn(inputfield_surn.getValue().toString().trim());

//
try{
wdThis.wdGetTestCompController().executeZrfc_Bbvpricauthor_Input();
}

    catch(Exception ex){

ex.printStackTrace();

    }

...

I know that with this code only one entry could be saved and I hope that I've to use a circle to save multiple data (Authors).

Can someone help me!

Regards

Edy

Accepted Solutions (1)

Accepted Solutions (1)

vijay_kumar49
Active Contributor
0 Kudos

Hello,

Hello,

I don’t know at what scenario you wrote the code in doModify View method.  It seems are you going create UI elements dynamically or what

Is it requires to create ui elements dynamically.

If Yes:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0b8dd16-5d78-2c10-6f82-c88fe4a7c...

Dynamic UI Generation - Web Dynpro Java - SCN Wiki

If no:

Follow these steps:

  1. Get the Functional module into the Model in WDJ Application
  2. Through context mapping will you map the all node/value attributes to Component Controller and mapped to View’s
  3. Then create UI elements through data binding
  4. Then under the action will execute the function module

Write Below Code in Custom Controller

public void wdDoInit()

{

//@@begin wdDoInit()

//Create a new element in node

//BAPI_QUOTATION_CREATEFROMDATA2_Input

BAPI_QUOTATION_CREATEFROMDATA2_Input  input =

new BAPI_QUOTATION_CREATEFROMDATA2_Input  ();

  1. wdContext.BAPI_QUOTATION_CREATEFROMDATA2_Input

.bind(input);

//@@end

}

public void execute_BAPI_QUOTATION_CREATEFROMDATA2( )

{

//@@begin execute_BAPI_QUOTATION_CREATEFROMDATA2()

IWDMessageManager manager = wdComponentAPI.getMessageManager();

try

{

  1. wdContext.current_BAPI_QUOTATION_CREATEFROMDATA2Element().modelObject().execute();
  2. wdContext.nodeOutput().invalidate();

}

catch(WDDynamicRFCExecuteException e)

{

  1. manager.reportException(e.getMessage(), false);

}

//@@end

}

Regards

Vijay

Former Member
0 Kudos

Thanks Vijay contribution,

I'm not using dynamic UI Element and the steps followed are:

1. Import the RFC model. The import parameter is a table and the cardinality of the node is 0..n ;

2. Through context mapping I map the all node/value attributes to Component Controller and mapped to View

3. Created UI elements through data binding

4. Create an action button with the code described above

5. Implemented the same code as the one you provided in the custom controller

Following this steps I've no problem when the RFC import parameter is sample fields and not table.

I appreciated your help and thanks again for that but I still have problem

Regards

Edy

Former Member
0 Kudos

Thanks Vijay, the problem is solved!

Answers (0)