Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Editable ( Validate changed Value )

Former Member
0 Likes
2,381

Hi Gurus,

I have a requiremnet on ALV.

I have a program ZTEST with screen no 9000.

I have a container places on the screen 9000

from PBO module of screen 9000

I am passing an internal table gt_xvbep with 3 values

VBELN , TIMEFROM , TIMETO

-


234000 10:00:00 12:00:00

234002 13:00:00 15:00:00

Fields TIMEFROM and TIMETO are 'editable" and of type DATS

When user enters a values on screen

TIMEFROM should be always greater than TIMETO.

I need to validate the above scenario

When ever user enters TIMEFROM > TIMETO ans press enter I need to show an error message "TO time should be greater than FRom time"

Please let me know how I can catch "ENTER" event in ALV in OOPS and validate the fields

Regards

Avi.

4 REPLIES 4
Read only

Former Member
0 Likes
915

in your module user command, have this as the first statement.

  • To capture the changed data on ALV grid & chack the changed data

CALL METHOD g_alv_grid->check_changed_data.

Then write a perform to validate the dates with a simple comparision logic.

If you are handling the dates for several zones....make sure you convert the timezone which will be some thing like...

CONVERT TIME STAMP.... INTO DATE <>. tAKE F1 HELP AND CHECK OUT.

Thanks,

Kiran

Read only

Former Member
0 Likes
915

check the standard report bcalv_test_grid_editable

Read only

Former Member
0 Likes
915

hi

Read only

Former Member
0 Likes
915

<br>Hi Avi

<br>1) Catch the enter event or modified event. Enter event is caught whenever you press enter after edit a field. If you edit a <br>field and then press TAB to go to another field than the Enter event is NOT CAUGHT. However if you use MODIFY

<br>event then ENTER event is also caught.

<br>

<br>Example:

<br>

<br>* Create the event or modified hanlder object

<br> CREATE OBJECT g_events.

<br> SET HANDLER g_events->data_changed FOR gref_alv_list.

<br>

<br>* Modify Event

<br> CALL METHOD gref_alv_list->register_edit_event

<br> EXPORTING

<br> i_event_id = cl_gui_alv_grid=>mc_evt_modified.

<br>

<br>* Or Enter Event

<br> CALL METHOD gref_alv_list->register_edit_event

<br> EXPORTING

<br> i_event_id = cl_gui_alv_grid=>mc_evt_enter.

<br>

<br>2) To be able to check data, you could do the following

<br> First, create class definition

<br> -


<br>

<br> CLASS lcl_events DEFINITION.

<br> PUBLIC SECTION.

<br> METHODS:

<br> data_changed FOR EVENT data_changed OF cl_gui_alv_grid

<br> IMPORTING er_data_changed

<br> e_onf4

<br> e_onf4_before

<br> e_onf4_after

<br> e_ucomm.

<br>

<br> ENDCLASS.

<br>

<br> Second, implementation

<br> -


<br>

<br> METHOD data_changed.

<br> DATA: ls_mod TYPE lvc_s_modi,

<br> ls_ins TYPE lvc_s_moce,

<br> ls_del TYPE lvc_s_moce.

<br>

<br>* To get rows that have been deleted if needed

<br> LOOP AT er_data_changed->mt_deleted_rows INTO ls_del.

<br> ENDLOOP.

<br>

<br>* To get rows that have been inserted if needed

<br> LOOP AT er_data_changed->mt_inserted_rows INTO ls_ins.

<br> ENDLOOP.

<br>

<br>* To get cells that have been changed if needed

<br> LOOP AT er_data_changed->mt_mod_cells INTO ls_mod.

<br>

<br>* You do your verififcation here

<br>* Add Message error if necessary by calling add_protocol_entry

<br>

<br> call method er_data_changed->add_protocol_entry

<br> exporting

<br> i_msgid = sy-msgid

<br> i_msgty = sy-msgty

<br> i_msgno = sy-msgno

<br> i_msgv1 = sy-msgv1

<br> i_msgv2 = sy-msgv2

<br> i_msgv3 = sy-msgv3

<br> i_msgv4 = sy-msgv4

<br> i_fieldname = Your table filed name here or any other value

<br> i_row_id = Your table row number here or any other value

<br>

<br>* Display message error if necessary by calling add_protocol_entry

<br> CALL METHOD er_data_changed->display_protocol.

<br>

<br> ENDLOOP.

<br> ENDMETHOD. "data_changed

<br>Dean Q.

<br>Good luck

Edited by: Dean Q on Nov 3, 2009 9:52 PM