cancel
Showing results for 
Search instead for 
Did you mean: 

How to give input parameter to Bapi when executing a method.

Former Member
0 Kudos

Hi All,

I have 1 input field and 1 button.I've defined a model node and inside that model attribute in my view.If I enter something in the Input field the value should go to the particular model attribute I defined.How to pass that input parameter.I have a action like this....

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

{

//@@begin onActionGetDateDetails(ServerEvent)

wdThis.wdGetGetDateDetailsCustController().execute_Bapi_Get_Date_Details("");

// while executing the above method I have to pass the input parameter typed in the input field.

Structure of my context :

Bapi_Date_Details

-


>Network List(Model Node)

|

-->Network (Model Attribute)

//@@end

}

Help me to solve this.

Thankx in advance.

Regards,

Karthick.K.E

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Karthick,

Have you bound your input field with model attribute?

If no then do it. If yes, and still giving problem then check your code with following.

Bapi_Get_Date_Details model = new Bapi_Get_Date_Details();

model.set<Network List>(new <type of Network List>); // This step is missing in your case i guess.

ipublic<component>.iBapi_Get_Date_Detailselement ele = wdcontext.createBapi_Get_Date_DetailsElement(model);

wdcontext.nodeBapi_Get_Date_Details().bind(ele);

You also have to assign memory/instantiate object for your node located inside main node.

Regards,

Bhavik

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

The input field is disabled because there is no storage area to recieve the user input.

So create a element as Noufal suggested and it will work.

By the way why you are passing parameter through the execute_Bapi_Get_Date_Details method.

Hope this helps.

Regards,

Vijith

Former Member
0 Kudos

Hi Vijith,

I want to make the input field as mandatory.So while calling the execute_Bapi_Get_Date_Details method I want to get the entered value in the input field and I want to pass it to check Mandatory method.How to do that?help me plz.Now I implemented thegiven ideas and those are working fine.But without entering anything in the input field if the user tries to click the button I want to give the error message.

Regards,

Karthick

Former Member
0 Kudos

Hi,

If you have input field bound to your model node try this

wdContext.current<Modelname>element().get<attribute name>();

The above code will give you the value in the input field.Check whether this is empty and print out a message using message manager like wdComponentAPI.getMessageManager().reportException("Message to be printed",true);

Hope this helps

Regards,

Vijith

Former Member
0 Kudos

Hi Karthick,

You can associate an input field's value to a BAPI in two ways:

1) binding the input UI element's 'value' directly to the BAPI's input attribute that you want to set. This is the methos Noufal suggested. In this method, make sure you initialize the attribute through the following lines of code in the doInit() method, else, the input field will be disabled.

<b><Bapi_name>Input input = new <Bapi_name>Input();

input.set<Attribute_name>(new <dataType>);</b>

2) The second method is settting the input's 'value' to some other attribute(say 'abc') and giving this value to the input parameter just before calling the RFC.

input.set<Attribute_name>(wdContext.currentContextElement.getAbc());

Hope this helps,

Best Regards,

Nibu

Former Member
0 Kudos

Hi Nibu,

As you told I tried

input.set<Attribute_name>

(wdContext.currentContextElement.getAbc());

But for me the "abc" -is not a value attribute.Its a model attribute which is under modelnode and the model node is under another model node.How to get that model attributes value?

Other ideas given by you are working fine.

Regards,

Karthick

Former Member
0 Kudos

Hi,

How to get the value of the input given.But the input is binded with the model attribute which is under model node.

Can anyone help me in this.

Regards,

karthick

Former Member
0 Kudos

Bind the inputField to the model attribute to which you need the value inserted.

In the WDDoInit() of the component controller write the following code.

BAPI<name> inp=new BAPI<name>();

wdContext.nodeBAPI<name>().bind(inp);

inp.set<attribute>(new <dataType>());// for eg. new String()

Now on click of the button call the method you have defined.

in the method

try{

wdContext.currentBAPI<name>element().modelObject().execute();

}catch(Exception e){

}

wdContext.nodeOutput().invalidate();

Former Member
0 Kudos

Hi Noufal,

Onclick of the button,how to get the input entered in the input field.My Input field is disabled.

Regards,

Karthick