cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass Hardcoded values from Form to Function Module

Former Member
0 Kudos

Hi All,

I am creating a form which will fetch the Material Details (Material Number and Material Desc) for a given Material Group ()eg. COMPNB,COMPSFT) etc.

I have imported the model and created a Custom Controller.

In the view I have created a DropDownByKey for Material Group. This has been binded to a Simple Type (Local Dictionary) which contains the Material Group code and Desc as key value pair eg COMPNB-->Computer Notebook.

Also, the plant has been hardcoded as 0002 in the View.

Now the thing is, how should I pass these parameters (Material Group and Plant) to the funtion module.

Please let me know.

Regards

Nikhil Bansal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Firstly get the value that has been selected from the dropdown by using the code

String matcode = wdContext.currentMaterialNode.getMaterialgrpCode();

String matdesc = wdContext.currentMaterialNode.getMaterialDesc();

next create an instance

fun_module_name_Input model = new fun_module_name_Input();

then create an element of this

IPrivateview_name.I_fn_module_name_InputElement element = wdContext.node_fun_module_name_Input.create__fun_module_name_InputElement(model);

then bind it

wdContext.node_fun_module_name_Input.bind(element);

now set the value of the element to pass it to function module and execute it

element.setMaterialcode(matcode);

element.setMaterialDesc(matdesc);

For hard code value u can write

element.setMaterialcode("COMP");

wdContext.node__fun_module_name_Input().current___fun_module_name_InputElement().modelObject().execute();

the values will be passed to the function module as input and the FM will be executed.

Regards,

Prasy

Message was edited by:

prasy p

Former Member
0 Kudos

Hi Prasy,

Thanks for the reply. It solved my problem.

Ok, I need a little more help from you. When the user selects the Material Group, the data is fetched in a ItemListBox.

I have two buttons

1. Add

2. Remove

The user can select Item from the ItemListBox and Add to the TextEdit. Also the user can deselect the Items from the TextEdit.

Can you provide some help in this regard.

Also I want that when user has not selected any Material Group (i.e. there is no data in the ItemListBox) then the buttons (Add and Remove) should be disabled.

When data is fetched then only the buttons should be activated.

Regards

Nikhil Bansal

Answers (1)

Answers (1)

former_member189631
Active Contributor
0 Kudos

Hi Nikhil,

You can use setXXX("0002");

This can be placed after your bind code for ur model.

Eg:

Bapi_Material_SaveData_Input input = new Bapi_Material_SaveData_Input ();

wdcontext.nodeBapi_Material_SaveData_Input.bind(input);

input.setMaterial("1000");

Regards,

Ramganesan K.