cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic fill of Inputfield2 when Inputfield1 is filled manually

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

I need your help for an issue I'm not able to manage.

This is the scenario: in srm7, an header custom table is used in web dynpro /SAPSRM/WDC_DODC_CT (view V_DODC_CT) and the user can fill 5 values in it.

In particular, some fields depend on the value filled in another field: consider, for example, the couple:

ZVENDOR and ZVENDOR_DESCRIPTION (names say it all).

Actually I associated an OVS search help to ZVENDOR, so that when the user select a Vendor code from the OVS list, then:

ZVENDOR is filled with that code and

ZVENDOR_DESCRIPTION is filled too, on the basis of the selection table entry which has been chosen.

That's the stuff that works... Now, the trouble: the user could also introduce a value for ZVENDOR manually and press ENTER. This doens't trigger obviously the OVS search help for the field; as a consequence ZVENDOR_DESCRIPTION is not populated.

I'm looking then for a way to replicate the OVS behaviour also for manual insertion, but...

- the logic on which the selection list in OVS is build is quite complex... is it possible to reuse the OVS behaviour or should I replicate the logic in a separate method?

- I was thinking to introduce a sketch of code like the following in WDDOMODIFYVIEW (note that the table is binded dinamically):

DATA: vendor_value TYPE BBP_BAPI_PABEZ_PI.
DATA: vendor_desc_value TYPE ZR7_PROLE_DESC.

CALL METHOD lo_tabnode->get_attribute
  EXPORTING
*    index  = USE_LEAD_SELECTION
    name   = 'ZVENDOR'
  IMPORTING
    value  = vendor_value.

CALL METHOD lo_tabnode->get_attribute
  EXPORTING
*    index  = USE_LEAD_SELECTION
    name   = 'ZVENDOR_DESCRIPTION'
  IMPORTING
    value  = vendor_desc_value.

*if vendor_value is filled and vendor_desc_value not, then:
* 1) calculate the corresponding description (is it possible to use OVS?)
* 2) lo_tabnode->set_attribute for ZVENDOR_DESCRIPTION with the retrieved value.

Don't know if there's a better way to do that; if this could be a fine solution, could you please help me defining point 1) ?

Thanks again.

M.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

As per my suggestion you need to replicate the logic in a separate method.

The best place will be the 'ON_ENTER' method for field 'ZVENDOR'.

I hope it helps.

Regards,

Sumit Oberoi

matteo_montalto
Contributor
0 Kudos

Thanks for your help, I will try to follow your approach.

I'm probably missing something of a bit technical; given that I'm working with dynamic structures for the view, I know that:

DATA: lo_tabnode        TYPE REF TO if_wd_context_node.
  lo_tabnode = wd_context->get_child_node( name = 'THCUS' ).

is the way to access to the table node.

Now, since I have to "reach" a field called ZVENDOR of that table in order to associate an ON_ENTER behaviour, I should get:

DATA: zvendor_input_field  type ref to cl_wd_input_field.
zvendor_input_field->set_on_enter( `REFRESH` ).

How to pass from lo_tabnode to zvendor_input_field? Please forgive the noobyness, I'm quite new to this WD world.

Thanks in advance

Former Member
0 Kudos

Hi,

In order to achieve what I suggested you need to follow these steps:

1) Create an action 'Z_UPDATE_DESCRIPTION'.

2) Set the action for ZVENDOR's input field in 'Postexit' of WDDOINIT. Since it is a dynamic field we have to do tjis using below code:

Data : zvendor_input_field type ref to cl_wd_input_field,
          lr_contaner type ref to cl_wd_uielement_container.

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
zvendor_input_field ?= lr_container->get_element( 'ZVENDOR' ).        "{You should put the name of your input field here}

zvendor_input_field->set_on_enter( 'Z_UPDATE_DESCRIPTION' ).

3) In the ONACTIONZ_UPDATE_DESCRIPTION method ( This method will be auto created once u create an action) add the below code:


Data : lo_tabnode type ref to if_wd_context_node,
          lo_tabelem type ref to if_wd_context_element,
          lv_zvendor type zvendor,
         lv_zvendor_desc type zvendor_description.

lo_tabnode = wd_context->get_child_node( 'THCUS' ).
lo_tabelem = lo_tabnode->get_element( ).

lo_tabelem->get_attribute( EXPORTING name = 'ZVENDOR'
                                             IMPORTING value = lv_zvendor).

IF lv_zvendor IS NOT INITIAL

lo_tabelem->set_attribute( EXPORTING name = 'ZVENDOR_DESCRIPTION' value = lv_zvendor_desc).

ENDIF.

I hope this helps.

Please revert back in case of issues.

Regards,

Sumit

matteo_montalto
Contributor
0 Kudos

Hello Sumit and thanks for these precious info... I'm going to ask again for help since I'm having troubles in what concerns the implementation (the logic sounds good to me).

Here are the doubts:

- on your point 2) you said to implement the code in WDDOINIT method. Unfortunately, I don't have any VIEW parameter in it and as far as I've seen searching in SDN, there's no way to get a ref in the DOINIT method. Anyway, I switched temporarily to WDDOMODIFYVIEW to try.

- by now I've seen that

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

returns correctly a reference to the rootUiElementContainer, while

zvendor_input_field ?= lr_container->get_element( 'ZVENDOR' ).

seems not to be correct because cl_wd_uielement_container doesn't have a method "get_element". I've seen IF_WD_VIEW has it, so i tried directly:

zvendor_input_field ?= view->get_element( 'ZVENDOR' ).

but it doesn't work (zvendor_input_field is initial).

I know it's rather difficult to provide a sketch of code since you can't see the code ; moreover, I'm quite new to WD world so I'm not that skilled.

However, just for completeness, I'm working in SRM 7, component /wd interface /SAPSRM/WDC_DODC_CT, view V_DODC_CT.

This (standard) view embeds the header's custom table extension, dinamically (layout section appears empty, and all the stuff is coded in WDDOMODIFYVIEW method, I could use pastebin to give an idea, let me know in case).

Waiting for your help, thanks again.

Former Member
0 Kudos

Hi,

You should be coding in Post-exit of WDDOMODIFYVIEW, I wrote WDDOINIT by mistake.

zvendor_input_field ?= lr_container->get_element( 'ZVENDOR' ).

seems not to be correct because cl_wd_uielement_container doesn't have a method "get_element". I've seen IF_WD_VIEW has it, so i tried directly:

Sorry once again you should use the mehtod :


lr_container->get_child( EXPORTING id = 'ZVENDOR' 
                                             IMPORTING the_child = zvendor_input_field ).

I have an SRM system in out landscape and I checked this component.

Above suggestion might solve your problem.

Revert back in case of issues.

Regards,

Sumit

matteo_montalto
Contributor
0 Kudos

Hi Sumit, sorry to bother again, that sketch of code doesn't work in my WDDOMODIFYVIEW: In particular:

CALL METHOD lr_container->get_child
  EXPORTING
    id        = 'ZVENDOR'
*    index     =
  receiving
    the_child = zvendor_UI_element.

which should return a reference to a CL_WD_UIELEMENT objects ... returns a blank (initial value).

Two notes:

- I surfed a bit lr_container using the debug tool... there's no reference in children section having an ID that corresponds to a field in the table;

- I enhanced the original WDDOMODIFYVIEW (by overwriting) by adding a routine that associates some of the field in the table to an Object Value Selector (OVS); that's the snip of code:

* insert: Object Value Selector for ZZ_PROLE_R3 and ZZ_LIFNR_R3
  DATA: lo_tabnode        TYPE REF TO if_wd_context_node.
  DATA: lo_tabnode_info   TYPE REF TO if_wd_context_node_info.
  DATA: tab_value         TYPE wdr_context_attr_value_list,
        wa_value          TYPE wdr_context_attr_value.

  lo_tabnode = wd_context->get_child_node( name = 'THCUS' ). "the custom table node
  lo_tabnode_info = lo_tabnode->get_node_info( ).
  CALL METHOD lo_tabnode_info->set_attribute_value_help
    EXPORTING
      name            = 'ZZ_PROLE_R3'
      value_help_mode = 131 "ovs mode
      value_help      = 'OVS'.
  CALL METHOD lo_tabnode_info->set_attribute_value_help
    EXPORTING
      name            = 'ZZ_LIFNR_R3'
      value_help_mode = 131 "ovs mode
      value_help      = 'OVS'.

Maybe this could help understanding a bit more on the structure; it seems that fields of the table are considered as attributes. But then, how to get from the attribute (say, ZZ_PROLE_R3) to the corresponding input field to use a SET_ON_ENTER method on it?

Thanks again for your help, support and patience.

Former Member
0 Kudos

Hi,

I have gone through the code of WDDOMODIFY of the component.

Suggestions:

Create Post exit instead of Overwrite exit.

Get the column ZVENDOR in the Post exit :

DATA : lr_table type ref to cl_wd_table,

lr_column type ref to cl_wd_table_column,

lr_input_field type ref to cl_wd_input_field,

lr_editor type ref to cl_wd_uielement.

lr_table->get_column( EXPORTING ID = 'ZVENDOR' RECEIVING the_column = lr_column ).

call method lr_column->get_table_cell_editor RECEIVING the_table_cell_editor = lr_input_field

" IF the above method call gives error.then use below code

call method lr_column->get_table_cell_editor RECEIVING the_table_cell_editor = lr_input_field

lr_input_field = lr_editor.

After this, you can treat the lr_input_field as normal input field and use the code in previous mails to set the ON_ENTER .

I hope this helps.

Regards,

Sumit

matteo_montalto
Contributor
0 Kudos

Thanks Sumit, issue resolved with your help.

Just for completeness, since sintax is a bit different from what you posted, I did as follows in the post-exit for WDDOMODIFYVIEW:

DATA : lr_table type ref to cl_wd_table,
       lr_column type ref to cl_wd_table_column,
       lr_input_field type ref to cl_wd_input_field,
       lr_editor type ref to cl_wd_uielement,
       lr_cell_editor TYPE ref to IF_WD_TABLE_CELL_EDITOR.

lr_table ?= view->get_element( 'THCUS' ).

lr_table->get_column( EXPORTING ID = 'THCUS_CZVENDOR' RECEIVING the_column = lr_column ).
call method lr_column->get_table_cell_editor RECEIVING the_table_cell_editor = lr_cell_editor.
lr_input_field ?= lr_cell_editor.
lr_input_field->set_on_enter('UPDATE_VENDOR_DESC').

There are just two differences:

- dynamic cast for lr_input_field, required to use the set_on_enter method;;

- the correct column ID I got in debug mode, which seems to be a concatenation of table ID and field name.

Again, thank you very much for your support and patience.

Best regards,

M.

Answers (0)