07-10-2007 11:29 AM
Hi all,
I have custom container on the screen. when i enter some data into the alv grid and press enter, it should validate some dates in it. I have used
if ok_code = 'ENTER'
.............
endif.
This works only when i click on the screen outside the custom container, i.e if the control is outside the container.
My requirement is the validation should take place even if the cusor is in the CC space and ENTER is pressed.
07-10-2007 11:55 AM
Hi,
Please try to use DATA_CHANGED event of the CL_GUI_ALV_GRID to validate your changes. The parameters for this event provide you with enough information to eveluate the changed data.
Regards,
Sharat.
07-10-2007 12:00 PM
Hi,
Call this method in TOP.
class lcl_event implementation.
method catch_dblclick.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'SHOW'
IMPORTING
RC =
.
And do ur coding in PAI for 'SHOW'
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'INS'.
IF flag1 = space.
DO 5 TIMES.
tab-line = text-001.
APPEND tab.
ENDDO.
flag1 = 'X'.
ENDIF.
CALL METHOD editor1->set_text_as_r3table
EXPORTING
table = tab[]
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WHEN 'SHOW'.
if flag = space .
CALL METHOD editor1->get_text_as_r3table
EXPORTING
ONLY_WHEN_MODIFIED = FALSE
IMPORTING
TABLE = tab[]
IS_MODIFIED =
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD editor2->set_text_as_r3table
EXPORTING
TABLE = tab[]
EXCEPTIONS
ERROR_DP = 1
ERROR_DP_CREATE = 2
others = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear tab.
clear tab[].
CALL METHOD editor1->set_text_as_r3table
EXPORTING
TABLE = tab[]
EXCEPTIONS
ERROR_DP = 1
ERROR_DP_CREATE = 2
others = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
flag = 'X'.
endif.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
<b>Reward points</b>
Regards
07-10-2007 1:18 PM
whether it should be triggered by the event ? Please send me what should be written in the class definition.
07-10-2007 12:45 PM
In ALV there is a option to set pf-status
try using that & set pf-status same as that of your output screen.
reward points if helpful
07-10-2007 1:53 PM
As Sharat said use DATA_CHANGED. Here is an example:
----
CLASS lcl_event_handler DEFINITION
----
*
----
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_handler DEFINITION
----
CLASS lcl_event_handler IMPLEMENTATION
----
*
----
CLASS lcl_event_handler IMPLEMENTATION.
METHOD data_changed.
g_save = 'X'.
PERFORM data_changed USING er_data_changed.
ENDMETHOD. "data_changed
ENDCLASS. "lcl_event_handler IMPLEMENTATION
&----
*& Form DATA_CHANGED
&----
text
----
-->P_ER_DATA_CHANGED text
-->P_0356 text
----
FORM data_changed USING p_er_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA: ls_mod_cells TYPE lvc_s_modi OCCURS 0 WITH HEADER LINE.
DATA: ls_cells TYPE lvc_s_modi.
DATA: ls_delete TYPE lvc_s_moce.
MOVE p_er_data_changed->mt_good_cells TO ls_mod_cells[].
LOOP AT ls_mod_cells.
READ TABLE t_clxref INTO h_clxref INDEX ls_mod_cells-row_id.
IF sy-subrc = 0.
CASE ls_mod_cells-fieldname.
WHEN 'CLIENT'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
IMPORTING
e_value = h_clxref-client.
IF NOT h_clxref-client IS INITIAL.
SELECT SINGLE name1
INTO h_clxref-name1
FROM kna1
WHERE kunnr = h_clxref-client.
IF sy-subrc <> 0.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'Z1'
i_msgno = '007'
i_msgty = 'E'
i_msgv1 = 'Invalid Client.'
i_msgv2 = ' '
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
ELSE.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'NAME1'
i_value = h_clxref-name1.
ENDIF.
ENDIF.
WHEN 'KUNNR'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
IMPORTING
e_value = h_clxref-kunnr.
IF NOT h_clxref-kunnr IS INITIAL.
SELECT SINGLE name1
INTO h_clxref-name2
FROM kna1
WHERE kunnr = h_clxref-kunnr.
IF sy-subrc <> 0.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'Z1'
i_msgno = '007'
i_msgty = 'E'
i_msgv1 = 'Invalid Client.'
i_msgv2 = ' '
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
ELSE.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'NAME2'
i_value = h_clxref-name2.
ENDIF.
ENDIF.
ENDCASE.
ENDIF.
ENDLOOP.
ENDFORM. " DATA_CHANGED