cancel
Showing results for 
Search instead for 
Did you mean: 

Question on value help

Former Member
0 Kudos

I want to create a value help for populating the cost center when creating a requisition. I am trying to derive the cost center list from a bapi Bapi_Costcenter_Getlist.

This is what I did so far. In the custom controller wdDoInit method, I have the following code:

Bapi_Costcenter_Getlist_Input inputCC = new Bapi_Costcenter_Getlist_Input();

wdContext.nodeBapi_Costcenter_Getlist_Input().bind(inputCC);

wdThis.executeBapi_CostCenterList();

In the executeBapi_CostCenterList() method I have the following code:

wdContext.currentBapi_Costcenter_Getlist_InputElement().modelObject().execute();

In the view controller, I created a value node (Test) under which I created a value attribute (CostCenter). I am then binding this value attribute to input field UI element corresponding to the cost center.

The code I have in the wdDoInit method of the view controller is

ITestElement newElement = wdContext.createTestElement();

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("Test.CostCenter");

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

ICostcenter_ListElement thisl1;

int cnt = wdContext.nodeCostcenter_List().size();

for (int i = 0; i < cnt; i++) {

thisl1 = wdContext.nodeCostcenter_List().getCostcenter_ListElementAt(i);

String costcenter = thisl1.getCostcenter();

values.put("Key_" + i, costcenter);

}

values.put("TestKey", "TestValue");

wdContext.nodeTest().addElement(newElement);

wdContext.currentTestElement().setCostCenter("Key_0");

The wdContext.nodeCostcenter_List().size() is 0.

What am I doing wrong?

Please help

Sriram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Well here is the code of how you can put a extended value selector for list of Countries from the backend.

Scenario is I have a Inputfield UI Element. I have context attribute in my view called "ctryattribute1" which is of type String.

I am using a standard RFC to get the Country list.I am displaying it using Extended value selector.

Code :

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("ctryattribute1");
    ISimpleTypeModifiable ctryType = attributeInfo.getModifiableSimpleType();  
    ctryType.setFieldLabel("Country");
    IModifiableSimpleValueSet valueSet = ctryType.getSVServices().getModifiableSimpleValueSet();  
	Isa_Get_Country_List_Input input = new Isa_Get_Country_List_Input();
	wdContext.nodeIsa_Get_Country_List_Input().bind(input);
	input.setLangu("EN");
	try
	{ 
		wdContext.currentIsa_Get_Country_List_InputElement().modelObject().execute();
		int s = wdContext.nodeCountrylistout().size();
	    for(int i=0; i < s; ++i)
	    {
	   valueSet.put(wdContext.nodeCountrylistout().getCountrylistoutElementAt(i).getLandx(),wdContext.nodeCountrylistout().getCountrylistoutElementAt(i).getLand1());
	    }
	    wdContext.currentContextElement().setCtryattribute1("Select Country");
		wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("List of Countries fetched");      
	}
	catch(Exception e)
	{
		wdThis.wdGetAPI().getComponent().getMessageManager().raiseException("Could not load",false);
	}

Hope that helps you. I am sorry that i couldnt give you code as per your requirement. But i guess this should give you an idea as to what you may be doing wrong.

Let me know if you require any other clarifications.

regards

ravi

Former Member
0 Kudos

Hi Ravi / Naufal:

Thanks for your suggestions.

Naufal: I had the piece of code that you wanted me to add but did not mention it in my posting.

Ravi: If you look at my posting you will see that I had a similar piece of code but in the custom controller and not in the view controller. When I implemented your suggestion I was still getting back no cost centers. So, I created a separate application to retrieve the cost centers and that worked fine.

This basically prompted me to look at my mappings one more time. The note by "Naufal" prompted me to look at the Output node.

Thats where the problem was - I initially mapped the cost center list directly under Bapi_Costcenter_Getlist_Input. I deleted that mapping and remapped the cost center list under the output node. This resolved the problem.

Thanks a ton for your suggestions. May I ask you one more question - if I create component "A" within my application to retrieve the cost centers, how can I use this component "A" for value help in a view under component "B" within the same application. Does my question make sense to you? If not I will try to re-phrase it.

Once again thanks to both of you.

Sriram

Former Member
0 Kudos

I think the document at the following location talks about my question:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/us... server-side eventing in web dynpro components.pdf

Thanks

Sriram

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Is your node Costcenter_List under the Output node in your context? If yes then after the execute code try

wdContext.nodeOutput().invalidate();

Hope that would be of help.

Regards

Noufal