cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the position of a field in table in webdynpro abap

former_member219737
Participant
0 Kudos

Hi Experts,

I need to get the position of a field in a table part in webdynpro abap ...

Can anyone guide me in solving it .

Tasks :

1. Once i am placing the same value in a field (eg : new value = 6 & old value = 6 ) the position

is not captured .

2.

I need to get the position of the field that i have attached...

Request to guide me for the same ...

Regards,

Karthik S

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member193460
Contributor
0 Kudos

Hi Karthik,

     There is no provision in webdynpro ALV to get the position of alv cell of an unchanged data.

However, if there is a change of data, there are ALV events which can help you capture the field value.

How to trigger the event ON_CELL_ACTION in ALV - Web Dynpro ABAP - SCN Wiki

you will need to create an event handler for on_cell_action event (exposed from standard alv component), the parameter r_param(i think , Please check), you can get the field of the event being triggered.

Note: Event is triggered after a round trip( ex: ENTER key pressed )

Regards,

Tashi

former_member219737
Participant
0 Kudos

Hi Tashi,

Can you tell me an exact code to be given in ON_CELL_ACTION method ...

Regards,

KArthik S

former_member193460
Contributor
0 Kudos

The method is the event handler which will give you both the old data and the new data which you have inserted into the cell.

I have found one document which uses on_data_check alv event which should also solve your problem.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00f...

The event handler method will have parameter r_param which has all the information (old data and new data of the selected cell).

You need to write your own logic what you want to do with the changed data.

example code from the document:

data : wa_param like line of r_param->t_modified_cells.


data : lo_nd_projects type ref to if_wd_context_node,


lo_el_projects type ref to if_wd_context_element.


field-symbols : <fs_context> type standard table,


<fs_context2> type any,


<fs_variable2> type any,


<fs_variable> type any.


lo_nd_projects = wd_context->get_child_node( name =


'NEW_NODE' ).


lo_el_projects = lo_nd_projects->get_element( ).


call method lo_nd_projects->get_static_attributes_table


importing


table = <fs_context>.


loop at r_param->t_modified_cells into wa_param.


*Loop at changed entries and modify them in the dynamic internal table


read table <fs_context> index wa_param-index into <fs_context2>.


assign component wa_param-attribute of structure <fs_context2> to <fs_variable>.


assign wa_param-r_value->* to <fs_variable2>.


move <fs_variable2> to <fs_variable>

Emdloop

former_member219737
Participant
0 Kudos

Hi Tashi,

Thanks for your Valuable reply ...

I hope your option will be applicable if i have used ALV table in my application ...

Can u tell me an idea , if its of normal Table then how can i capture the user changed position ...

Regards,

Karthik S

former_member193460
Contributor
0 Kudos


Hi Karthik,

     I am sure there will be a feature, but sadly i dont have access to system currently to try it out.

Regarding ALV, i am sure of this feature because i have implemented similar functionality in my previous project.

Regards,

Tashi

former_member219737
Participant
0 Kudos

Hi Tashi,

Thanks for your reply ...

Once u find time, can you provide me the snippet of code to achieve the position of user changed one

for the normal table in WD Applications ...

Regards,

Karthik S

former_member219737
Participant
0 Kudos

Hi Tashi,

can you provide me the snippet of code to achieve the position of user changed one 

for the normal table in WD Applications ...

Regards,

Karthik S

former_member193460
Contributor
0 Kudos

Hi Karthik,

     i dont have access to SAP system currently, So please forgive my inability to give you a code snippet.

I am aware of another approach which may be little complex at first (neither the best way), but you can give it a try . The concept is called "context change log".

A brief on context change log: Context Change Log (Recording User Entries) - Developing Web Dynpro ABAP Applications - SAP Library

for a code snippet, you can google keyword "context change log" as i saw a non sap site which has an example on table control using context change log.

Please do check yourself if there is any other approach as i dont have access to system.

Regards,

Tashi

former_member219737
Participant
0 Kudos

Hi Tashi,

Thanks for yr' reply...

Allready the above method is used for the applications that i am using currently ...

But the Problem is when a value is changed ,..then only the above method is captured in the applications

For ex : old value : 5 ...new value : 6

If , old value : 5 ...new value : 5 ...Changed value is not captured in the above method ...

So, If i get the position of the user changed one...will filter the same from the above metod ...

Is there any other option to achieve it ...

Regards,

Karthik S

former_member193460
Contributor
0 Kudos

Hi Karthik,

     It definitely doesnt capture when the value is same, the primary purpose of this handler is to capture a change in value.

In your case, in the event of same value being entered, i didnt find any alv event handler ( m afraid we dont have any as far as i know). But please do share if you come across a different solution.

Regards,

Tashi

former_member197475
Active Contributor
0 Kudos

Hi Karthik,

You can use the method GET_SELECTED_ELEMENTS of interface IF_WD_CONTEXT_NODE.

BR,

RAM.

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks for your reply ...

With your suggestion, i got the entries of that particular line item but not the position (user changed field)

Regards,

KArthik S

former_member193460
Contributor
0 Kudos

As i mentioned earlier, you need to use alv events for this requirement.

on_cell_action.

Regards,

Tashi

former_member219737
Participant
0 Kudos

Hi Tashi,

Thanks ...

I have tried your suggestion and i have applied ON_CELL_ACTION method , snippet of code in Modify view ...

can u give me an exact code to get the position of User Changed data field ??...

Regards,

Karthik S

former_member219737
Participant
0 Kudos

Hi Tashi,

Can u tell me the snippet of code to be written in ON_CELL_ACTION method, to get the position of

user selection value ...

Regards,

Karthik S

former_member193460
Contributor
0 Kudos

Hi Karthik,

     i dont have system access currently, But i can definitely guide you.

In the Method tab of your controller,

you need to create a new event handler for ALV event on_cell_action.By doing so, a standard parameter (r_param) will be generated,

In this event handler method, r_param will give you the position of the column and row (cosequently the Cell).

former_member197475
Active Contributor
0 Kudos

Hi Karthik,

Follow the below logic.

1. From your internal table, get the index number that you are trying to edit.

2. Now call this method by passing the index.

LO_ND->SET_LEAD_SELECTION_INDEX( index = index )

BR,

RAM.

former_member219737
Participant
0 Kudos

Hi Tashi,

I have declared Method inside the view but its not triggering dring the debug mode ..

Do i need to check any other thing ...

Regards,

KArthik S

former_member219737
Participant
0 Kudos

Hi Rama,

The Entries which i am going to edit is the dynamic one and its not fixed  ...

Is there any other option to check it ...??

Regards,

Karthik S

former_member193460
Contributor
0 Kudos

Hi,

You need to enable the event first. I had shared a wiki regarding this earlier.

call method lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled

exporting

value = ABAP_TRUE

wiki link: How to trigger the event ON_CELL_ACTION in ALV - Web Dynpro ABAP - SCN Wiki

Regards,

Tashi