cancel
Showing results for 
Search instead for 
Did you mean: 

Initial event context in onEnter action

cyclingfisch_
Active Contributor
0 Kudos

Hi,


I have a WebDynpro ABAP View where I added a container and an input field during runtime. I added the onEnter event to the input field.

On enter the corresponding action method is called, but if I try to get the data entered by the user that fails.

If call

lo_context_element = wdevent->get_context_element('CONTEXT_ELEMENT').

this fails because context elements are initial:

Debugger view on lo_context_element: CONTEXT_ELEMENT      ->->{O:initial}


Do you have any ideas what I missed?


Thanks for any hints!


Cheers

Martin

Accepted Solutions (1)

Accepted Solutions (1)

cyclingfisch_
Active Contributor

I analysed the issue deeper now. The context element is still initial when the on_enter action method is called.

As I already said, I added the input fields dynamically at runtime. I tried to add this input fields to a static defined context with cardinality 0:1.

At runtime there are three instances of the context node. How do I have to reference the <fieldA> of third instance of my context node?

          lo_input = cl_wd_input_field=>new_input_field(
            id   = 'Inputfield1'
            read_only = abap_true
            bind_value = NODE3.ATTRIBUTE1
            length = 10
          ).

This seems to be wrong. Do you have any idea what? Is the "3" after "NODE" wrong?

Former Member
0 Kudos

Hi Martin,

hope that I get you right: You have a context node (called NODE) with at least 3 elements. One attribute of this element is called ATTRIBUTE1.

If you like to bind the field to element 3 of the node, you need to set the lead selection to this element.

Method NEW_INPUT_FIELD() requires for parameter VALUE the absolute path of the context attribute as string. You cannot reference a special element of the context node within this string. It is using the lead selection.

Kind regards, Anja

cyclingfisch_
Active Contributor
0 Kudos

Hi Anja,

Thank you very much for your answer! That was the right solution. I set the lead selection and got the path of that element for the binding. It's cool to get advise from old team mates 🙂 good old times!

I also found the reason why the context element is initial in the event context.

provided here

coding for a workaround.

It would be cool, if that could be added to the SAP documentation of the on_enter event.

Cheers,

Martin

Answers (1)

Answers (1)

cyclingfisch_
Active Contributor
0 Kudos

Some times writing about an issue helps. As I realized that the ID of wdevent is filled with the UI element name , the reason might be that the context binding is missing. Or do you see any other reasons for that behaviour?

harsha_jalakam
Active Contributor
0 Kudos

Hi Martin,

just to confirm did you add the spaces between the braces ().

lo_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

Regards,

Harsha

cyclingfisch_
Active Contributor
0 Kudos

Hi Harsha,

yes I did. I didn't copy the code from there, so that's just a typo in SCN.

Thanks & Cheers,

Martin