Skip to Content
avatar image
Former Member

Getting values from a function module called in a WDA method

Friends,

I am trying to execute a function module from WDA.

I have created a service call for the function module. The function module takes values from the user, looks up the corresponding values of another field and returns the values in an internal table.

I am using the "Method Call in Used Controller" of WD Code wizard to call the function module.

When the event handler method containing the call to the function module is executed, nothing happens.

I am not sure how to pass values to the function module and to get the return values from the function module.

I am new to using function modules from WDA. Please help me out.

Thanks and Regards.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 10, 2008 at 05:32 AM

    Lets see, I think you're mixing a few things up.

    Using function modules from WDA is no different that normal ABAP.

    First, when you went through the service call wizard you specified a function module...in there, you were given the option to choose whether the function parameters should be either a) context attributes b) controller attributes or c) method parameters.

    From the coding you posted I can assume a few things: You either chose options a) or b), and chose the COMPONENTCONTROLLER as the controller to hold the service call.

    So, you should go to the COMPONENTCONTROLLER and look for the FN_MODULE_NAME method coding, where the actual function module call should be. In the same controller you should have either some Context nodes or controller Attributes for each corresponding function parameters.

    So, the calling order is:

    Event handler -> Component controller's Method ("service call") -> Function module

    What you may be lacking, is the mapping of the COMPONENTCONTROLLER's context to the VIEW with the event you're calling the service from, that way there's no need to pass parameters as they flow from the view context (what the user has on screen) to the controller's context.

    You could also add parameters yourself to method FN_MODULE_NAME and then specify them in the calling.

    Whoa, wrote a bit. I hope you got it.

    You have this tutorial also which does a service call:

    https://www.sdn.sap.com/irj/sdn/nw-development?rid=/library/uuid/9cb5d345-0801-0010-6a8e-fc57c23fd600

    Regards

    Edited by: Alejandro Bindi on Oct 10, 2008 2:32 AM

    Add comment
    10|10000 characters needed characters exceeded

    • With method IF_WD_CONTEXT_NODEBIND_TABLE you're binding a set of entries in an internal table to a node with multiple cardinality. So, with method IF_WD_CONTEXT_NODEGET_STATIC_ATTRIBUTES_TABLE you can do the opposite: retrieve that set of values into an internal table. You can then loop that table, which will have all the node attributes including the one you want the values from...is that what you need?

      Edited by: Alejandro Bindi on Oct 14, 2008 3:24 PM

  • avatar image
    Former Member
    Oct 15, 2008 at 06:49 PM

    Friends,

    I am trying to pass input value back to the function module as its input parameter.

    The context node is mapped to the component controller node from where i get a table of values and am able to read the values using get_static_attributes_table method.

    Since the input parameter is defined as a context node, i am setting the value to the context attribute using set_attribute method.

    But the input value is not getting passed from view context to component controller context.

    Let me know what is missing.

    Thanks and Regards.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I get you now.

      You need not do anything towards 'setting' the value in the context node attribute corresponding to the input.

      The moment you bind the context node attrubute to value of the UI Element , as soon as the user inputs a value in this UI Element in the form, the same is automatically set/captured in the context element attribute. Now your task is just to read the value thats associated with the context element attribute and pass it on as the importing parameter to the function module.

      Just before you call the Function Module in the Component Controller method, do this:

      lo_nd = wd_context->get_child_node( name = wd_this-><<context node corresponding attribute bound to the UI Element>> ).
      lo_el = lo_nd->get_element(  ).
      
        lo_el->get_attribute(
          EXPORTING
            name =  `<<attribute name bound to the UI Element>>`
          IMPORTING
            value = lv_value).
      

      Pass the lv_value to the importing parameter of the Function Module .

  • avatar image
    Former Member
    Oct 09, 2008 at 07:28 PM

    This is the code to call the function module from the event handler method:

    DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .

    lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).

    lo_componentcontroller->fn_module_name(

    ).

    Thanks and Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 05, 2008 at 06:44 AM

    Resolved

    Add comment
    10|10000 characters needed characters exceeded