cancel
Showing results for 
Search instead for 
Did you mean: 

Input Field <-> Link to URL in an ALV

Former Member
0 Kudos

Hi Experts

I have an ALV table in with one of columns as URL which is an input field basically.

I would like to know whether we can have the link to url for the same column?

If yes, help me on how to do the same

Thanks and Regards

Karthick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For whichever column you need the link to url, you need to create an object of the class cl_salv_wd_uie_link_to_url and assign this reference as the <b>cell editor</b>. You also need to define the 'reference' field for the url.

Go through the sample code below and change to your requirements:

DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,

l_ref_cmp_usage type ref to if_wd_component_usage.

l_ref_cmp_usage = wd_This->wd_cpuse_alv( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_Alv( ).

l_ref_INTERFACECONTROLLER->Set_Data(

R_NODE_DATA = lr_node " Ref to if_Wd_Context_Node

).

DATA:

l_alv_model TYPE REF TO cl_salv_wd_config_table,

lr_column TYPE REF TO cl_salv_wd_column,

lr_link type ref to cl_salv_wd_uie_link_to_url.

l_alv_model = l_ref_interfacecontroller->get_model( ).

l_alv_model->if_salv_wd_table_settings~set_read_only( abap_false ).

lr_column ?= l_alv_model->if_salv_wd_column_settings~get_column( id = 'NAME' ).

create object lr_link.

lr_link->set_text_fieldname( 'NAME' ).

lr_link->set_reference_fieldname( 'URL' ).

lr_column->set_cell_editor( lr_link ).

In my example, I have a field 'Name' and a field 'URL' in my context node. The value in the attribute NAME will be displayed as the hyperlink text. And the attribute URL will contain the target URL. Instead of taking the target URL from a node attribute, you could define it directly also, using the method lr_link->set_reference( <url> ).

Hope this helps.

Regards

Nithya

Former Member
0 Kudos

Hi Nithya

I do not have any problem in linking to an url. But once i link it I am not able to edit that column.

Do we have any alternative/work around to edit the column with the link?

Thanks and Regards

Karthick

Former Member
0 Kudos

Have you set the ALV as editable? You need to set_read_only as false in your table settings.

Even then I do not get your requirement. Why do you want to edit a link? You can have the field that contains the link information as an input field and make it editable. But why would you edit the actual link element itself? I am not very clear about what you want.

Regards

Nithya

Former Member
0 Kudos

Hi Nithya

I would like to edit my URL text basically but not my actual link which is present in the different attribute. And my requirement is to enable link at the URL text which can be edited.

I have kept my alv in read_only ~ abap_false and as a result i could see the rest of my columns as editable but not url column<link>.

Thanks and Regards

Karthick

Former Member
0 Kudos

Hi Karthick,

Why don't you have an input field in one column, where you can enter the link. Also, have another column with URLs. Whenever you press enter in input field, your URL will get updated if you have the same attribute bound to both the fields.

Hope this helps.

Regards,

Neha

Former Member
0 Kudos

Hi Karthick,

I dont think you can do this. The link element will not be editable. A work around would be what I suggested before, i.e. enter the link (text or url) in an input field and then you can call the set_text method on the link to url element. That will update your text. I dont think a direct editing is possible.

Regards

Nithya

Answers (2)

Answers (2)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

You can have a link to URL

data: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.

data: lr_config type ref to CL_SALV_WD_CONFIG_TABLE.

data: lr_column_settings TYPE REF TO if_salv_wd_column_settings.

data: lr_col type ref to cl_salv_wd_column.

data: lr_link type ref to CL_SALV_WD_UIE_LINK_TO_ACTION.

lr_salv_wd_table = wd_this->wd_cpifc_<usedcomp name>( ).

lr_config = lr_salv_wd_table->get_model().

lr_column_settings ?= lr_config.

lr_col = lr_column_settings->get_column( id = <your field name> ).

create object lr_link .

lr_col->set_cell_editor( lr_link ).

Regards

Abhimanyu L

Former Member
0 Kudos

Hi Karthick.

Go through this thread:

https://forums.sdn.sap.com/click.jspa?searchID=4593836&messageID=3952017

instead of link to action use the link to url element.

For more infos just search this forum with ALV and Link.

Cheers,

Sascha