cancel
Showing results for 
Search instead for 
Did you mean: 

Freely-programmed value help for a single ALV cell

Former Member
0 Kudos

Greetings everyone,

I have a freely-programmed value help that works beautifully when attached to the context element of a single field, but now I'm needing to use it in an ALV for a specific cell. Is there a way to shut off the dropdown for all of the rows (cells) in the column where I don't need it? Or, is there an appropriate workaround that can deliver the same results?

I've found several posts that address similar issues, but nothing for this exact problem.

Thanks,

Jason Block

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I take it from reading your description what you want is a little more complicated than just controlling the read-only property on the input field. If I read you properly you still want to have all the cells in a column to be open for input, just on some of them you want to disable the value help. Is that correct? See these screen shots for clarification:

If you focus on the the input field in the first row, you get the value help:

http://www.flickr.com/photos/tjung/2714133068/

However if you go to the second row and focus on the same input field in this column, you don't get the value help:

http://www.flickr.com/photos/tjung/2714133094/

If this is what you want, then buckel up because this was a challenging one. The problem is that the value help specification is not done at the UI element level, but instead at the context attribute level. Therefore it can't be as simple as controlling a property on the inputField itself. What you will need to do is extend the context node that you have bound to the ALV. You need to add a second version of the attribute that is bound to your input field. In this second version you can set the value help specification to Disabled:

http://www.flickr.com/photos/tjung/2713320505

Notice from the screen shot that I also added another attirbute called CVAR (type STRING). We will need that later. It will be used to store which cell variant show be used on a particular row.

Now we must go to the place in your code where you fill the context node with data. You will need to copy the data from your primary attribute to your secondary one. In my case I was copying the values from CARRID to CARRID2. Of course for update, you would need to merge the data back together before saving it back to the database. I also set a simple odd/even pattern of controller in the cell variant. I assume you will have some actual business logic that controls this:

data odd type boolean value abap_true.
   loop at lt_f_r_sflight[] assigning <ls_f_r_sflight>.
    clear ls_c_r_sflight.
    move-corresponding <ls_f_r_sflight> to ls_c_r_sflight.
    move <ls_f_r_sflight>-carrid to ls_c_r_sflight-carrid2.
    if odd = abap_true.
      odd = abap_false.
    else.
      odd = abap_true.
      ls_c_r_sflight-cvar = 'NOVH'.
    endif.
    insert ls_c_r_sflight into table lt_c_r_sflight[].
  endloop.
  lo_r_sflight->bind_table( lt_c_r_sflight[] ).

Next is the logic in the initialization of the ALV. We will need to create two input fields - each bound to the different context attributes. We will make the one the primary cell editor. The other will become the cell editor of the cell variant. We then tell the column where it can get its cell variant value from:

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
  lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

  DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
  l_salv_wd_table = wd_this->wd_cpifc_alv( ).
  DATA l_table TYPE REF TO cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).
  l_table->if_salv_wd_table_settings~set_read_only( abap_false ).


  DATA input1 TYPE REF TO cl_salv_wd_uie_input_field.
  DATA l_column TYPE REF TO cl_salv_wd_column.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'CARRID' ).
  CREATE OBJECT input1
    EXPORTING
      value_fieldname = 'CARRID'.
  l_column->set_cell_editor( input1 ).

  DATA input2 TYPE REF TO cl_salv_wd_uie_input_field.
  CREATE OBJECT input2
    EXPORTING
      value_fieldname = 'CARRID2'.

  DATA l_cv TYPE REF TO cl_salv_wd_cv_standard.
  CREATE OBJECT l_cv.
  l_cv->set_key( 'NOVH' ).
  l_cv->set_editor(  input2 ).
  l_column->add_cell_variant( l_cv ).
  l_column->set_sel_cell_variant_fieldname( 'CVAR' ).

Former Member
0 Kudos

Hi Thomas,

The above example is very helpful.

Can we have two UI element in the same ALV cell. (For example  dropdown and Link).

Thanks

Vivek

Answers (2)

Answers (2)

Former Member
0 Kudos

Yes - this is exactly what I need.

Thanks a bunch for the info - it'll save me a lot of time.

Regards,

- Jason

abhimanyu_lagishetti7
Active Contributor
0 Kudos

You can use Freely programmed help in ALV

first you have to make the column to Input Field

data: lr_column type ref to CL_SALV_WD_COLUMN.

data: lr_input type ref to CL_SALV_WD_UIE_INPUT_FIELD.

create object lr_input exporting VALUE_FIELDNAME = 'CARRID'.

lr_column =

l_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'CARRID' ).

lr_column->set_cell_editor( lr_input ).

and set the ALV to Ready Only to False

l_value->if_salv_wd_table_settings~set_read_only( abap_false ).

l_value is the model of the ALV

Abhi

Former Member
0 Kudos

Thanks for the response. I already have this same code in the application, however. What I need to do is prevent the search help from being triggered when clicking on certain cells in the ALV. Basically what I'm doing is displaying material characteristics and their associated values in a two-column ALV. The search help is attached to the value column's context element in the standard way, but what I need is for it to be deactivated for everything except the cell containing the value for manufacturer name. In other words, I need the search help only for manufacturer name - none of the other cells should have it.

Is something like this even possible in WDA, or will I have to resort to a hack of some kind?