12-26-2014 9:32 AM
Hi Experts,
i have a requirement that i need to get the field name of any input field which value is changed on screen by user. I am sure there is something is available in ABAP to achieve.
Any help would be appriciated.
Thanks in advance
Regards,
Ashutosh
12-26-2014 9:40 AM
Hi Ashutosh,
Can you give a details information of your requirement.
What is the mean by input fields. Can you provide some example of requirement.
Regards.
Praveer.
12-26-2014 9:51 AM
Hi Praaveer
My requirement is like suppose there are many input fields on a Z screen and user changes the value of any field. so when he press enter or any other button then in code i get that field name of that input field which value was changed.
I think by this i made you clear about my requirement.
Thanks & Regards
Ashutosh
12-26-2014 9:56 AM
Hi Ashutosh,
You can use the Get Cusrsor Field V_Field Statement in your PBO.
here V_Field is any string variable.
It will return your the current selected / entered value field information or I can say your system cursor position in SAP screen.
Regards.
Praveer.
12-26-2014 10:17 AM
Hi Praveer,
Yes you are right it will return me the current selected or entered value field, but i need all the fields which were changed on screen.
Let say if 3 field have been changed on screen then i want those 3 field names.
Regards
Ashutosh
12-26-2014 10:46 AM
Hi,
You can use the 'DYNP_VALUES_READ' function module to get the changed value information of the screen.
Regards.
Praveer.
12-26-2014 11:27 AM
12-26-2014 9:50 AM
Hi Ashutosh,
TRy this...
PROCESS AFTER INPUT.
MODULE get_cursor.
MODULE get_CURSOR INPUT.
data : wa_cursor(40).
get CURSOR FIELD wa_cursor.
ENDMODULE.
wa_cursor will have the field name which value is changed on screen by user.
Thanks,
Sharath
12-26-2014 10:13 AM
Hi Sharath,
Thanks for your reply but by this method i will get only last changed field or the field which one has cursor on it. But if on that screen suppose i have changed 3 field's value then how would i get all the three fields.
I think i made you clear about my requirement.
Regards
Ashutosh
12-26-2014 10:37 AM
Hi Ashutosh,
In Module pool, we use screen fields which are referred to Data dictionary objects, for e.g. Ztable-field1
we declare extra data objects which is of same structure of screen fields e.g. wa_table type ztable.
the wa_table fields are getting filled by the program logic, i.e. from select * from ztable.
in PBO, copy ztable fields from wa_table feilds. i.e. ztable = wa_table.
in PAI, compare if ztable = wa_table?
IF ztable NE wa_table.
" Screen values have been changed.
" Compare all fields from both the structures to identify the changed fields & its values.
ENDIF.
12-26-2014 10:53 AM
Logic for identifying the changed fields:-
DATA lr_structdescr TYPE REF TO cl_abap_structdescr.
DATA l_component TYPE abap_compdescr .
FIELD-SYMBOLS: <field_value1> TYPE any.
FIELD-SYMBOLS: | <field_value2> TYPE any. |
lr_structdescr ?= cl_abap_typedescr=>describe_by_name( 'ZTABLE' ).
LOOP AT lr_structdescr->components INTO l_component
ASSIGN COMPONENT l_component-name OF STRUCTURE wa_table TO <field_value1>.
ASSIGN COMPONENT l_component-name OF STRUCTURE ztable TO <field_value2>.
IF <field_value1> NE <field_value2>.
"Field value has changed field name is in l_component-name
ENDIF.
ENDLOOP.