Check_changed_data
i'm in trouble with method check_changed_data. i though i was to trigger any changes in my editable alv.
in pbo i've:
SET HANDLER g_event_receiver->handle_data_changed FOR grid1.
and in the pai:
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT' OR 'BACK'.
PERFORM exit_program.
WHEN '&DATA_SAVE'.
CALL METHOD grid1->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid = 'X'.
PERFORM call_transaction.
ENDIF.
WHEN OTHERS.
* do nothing
ENDCASE.
i had expected the call_transaction only if some changes are made in the alv, but i allways have l_valid = 'X'.
where do i make a mistake?
Hello
Assuming that your requirement is that "When the user pushes the DATA_SAVE button AND something has changed on the ALV grid then execute the transaction" the solution is quite simple:
"(1) Call method CHECK_CHANGED_DATA at the beginning of PAI
save_ok = ok_code.
CLEAR ok_code.
CALL METHOD grid1->check_changed_data( ). " triggers DATA_CHANGED
CASE save_ok.
WHEN 'EXIT' OR 'BACK'.
PERFORM exit_program.
WHEN '&DATA_SAVE'.
" CALL METHOD grid1->check_changed_data
" IMPORTING
" e_valid = l_valid.
IF l_valid = 'X'.
PERFORM call_transaction.
ENDIF.
WHEN OTHERS.
* do nothing
ENDCASE.
Define an event handler method (e.g. HANDLE_DATA_CHANGED) which just stores a CHANGE flag:
METHOD handle_data_changed.
" E.g. define static attribute in your event handler class
lcl_eventhandler=>md_data_changed = 'X'.
" That's all if you do not need any further validations.
ENDMETHOD.
Now change your USER_COMMAND module as following:
save_ok = ok_code.
CLEAR ok_code.
CALL METHOD grid1->check_changed_data( ). " triggers DATA_CHANGED
CASE save_ok.
WHEN 'EXIT' OR 'BACK'.
PERFORM exit_program.
WHEN '&DATA_SAVE'.
" CALL METHOD grid1->check_changed_data
" IMPORTING
" e_valid = l_valid.
" IF l_valid = 'X'.
IF ( lcl_eventhandler=>md_data_changed = 'X' ).
lcl_eventhandler=>md_data_changed = ' '. " reset change flag
PERFORM call_transaction.
ENDIF.
WHEN OTHERS.
* do nothing
ENDCASE.
Regards
Uwe
Similar Messages
-
Hi guys,
I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
call method alv_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
Any advice or tips or sample code is greatly appreciated.
Thanks,
ShareenHi Shareen,
Handle the data_changed event in the grid.
Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
METHODS handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
Implementation:
METHOD handle_data_changed.
PERFORM validations USING er_data_changed.
ENDMETHOD.
FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
DATA: ls_good TYPE lvc_s_modi.
DATA wa LIKE LINE OF lt_good_cells.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
CASE ls_good-fieldname.
WHEN 'FIELDNAME'. "Your fieldname
CALL METHOD er_data_changed->get_cell_value "Get the changed value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
IMPORTING
e_value = temp. "Your temp variable
"Make your validations here.
ENDCASE.
Ps: Reward points if helpful.
Regards,
Wenceslaus. -
"Implicit" Binding in ABAP OO?: the ALV method grid- check_changed_data
In this thread here:
Where/how would you add the actual DB update to BCALV_EDIT_03?
Uwe Schieferstein was kind enough to show that anyone can see the effect or outcome of the ALV check_changed_data method if they just add this code to the PAI of the SAP demo program BCALV_EDIT_03:
MODULE pai INPUT.
TRANSLATE ok_code TO UPPER CASE.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'SAVE'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
I_GRID_TITLE =
'Before CHECK_DATA_CHANGED -> changes not yet retrieved'
TABLES
t_outtab = gt_outtab
EXCEPTIONS
OTHERS = 99.
g_grid->check_changed_data( ).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
I_GRID_TITLE =
'After CHECK_DATA_CHANGED -> changes retrieved'
TABLES
t_outtab = gt_outtab
EXCEPTIONS
OTHERS = 99.
PERFORM save_data.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
When looking at this code, the following question occurred to me:
<b>Question: How does check_changed_data know the itab to bring the changed back to, since it is called in the PAI with no arguments.</b>
The only answer I can see is that when the grid is first loaded in the PBO of BCALV_EDIT_03 in the usual way:
if g_custom_container is initial.
perform create_and_init_alv changing gt_outtab
gt_fieldcat
gs_layout.
endif.
the ABAP OO engine implicitly "binds" the back-end table gt_outtab to the ALV contol (i.e. the instance of CL_GUI_ALV_GRID that the program creates.)
So, if you answer this question, please do one of two things:
a) confirm that check_changed_data "knows" the correct itab to bring the data back to because the ABAP OO engine has, in fact, implicitly "bound" the control to the itab gt_outtab;
or
b) if this is not true, explain how check_changed_data knows what itab to bring the data back to.
Thanks very much in advance for whatever time anyone can afford to spend on this question.
djhHello David
I have modified my previous sample report again to +demonstrate +that the
grid instance knows exactly which itab is displayed. Unfortunately it is already a few years ago when I attended the excellent SAP course BC412 (Dialog Programming using EnjoyControls, held by a chinese SAP employee with a beautiful Palatine dialect). Thus, I +cannot explain +the technical details (which are somehow related to the automation queue and the control framework).
Here are the new modifications:
(1) Inbetween the data definitions and the local class definition I have added two parameters:
DATA: gt_outtab TYPE TABLE OF sflight.
PARAMETERS:
p_byref RADIOBUTTON GROUP rad1, " pass itab by reference
p_byval RADIOBUTTON GROUP rad1. " pass itab by value
* LOCAL CLASS Definition
(2) The parameters are evaluated in PBO module PBO:
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
IF ( p_byval = 'X' ).
PERFORM create_and_init_alv_byval
CHANGING gt_outtab
gt_fieldcat
gs_layout.
ELSE. " ( p_byref = 'X' ).
PERFORM create_and_init_alv CHANGING gt_outtab
gt_fieldcat
gs_layout.
ENDIF.
ENDIF.
ENDMODULE. "pbo OUTPUT
(3) And here is the difference between the two routines:
*& Form create_and_init_alv_byval
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv_byval
CHANGING
value(pt_outtab) LIKE gt_outtab[] " by value
pt_fieldcat TYPE lvc_t_fcat
ps_layout TYPE lvc_s_layo.
PERFORM create_and_init_alv CHANGING pt_outtab
pt_fieldcat
ps_layout.
ENDFORM. " create_and_init_alv_byval
*& Form CREATE_AND_INIT_ALV
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv
CHANGING
pt_outtab LIKE gt_outtab[] " by reference
pt_fieldcat TYPE lvc_t_fcat
ps_layout TYPE lvc_s_layo.
DATA: lt_exclude TYPE ui_functions.
Now the crucial point is that the globally visible itab gt_outtab is passed
(a) by value to method g_grid->set_table_for_first_display (routine CREATE_AND_INIT_ALV_BYVAL)
(b) by reference to method g_grid->set_table_for_first_display (routine CREATE_AND_INIT_ALV_BYVAL)
If you run the report with the default (p_byref = 'X') then the report behave exactly like the original sample report.
However, if you choose p_byval = 'X' then the reports dumps as soon as you try to change the values of the ALV list (e.g. change a planetype and hit ENTER or even sorting is sufficient).
Why? The itab passed by value to the grid instance is not the same like gt_outtab!
Conclusion: Do not try to fool the grid instance...
Regards
Uwe
PS: The entire coding of the adjusted sample reports is shown below:
report ZUS_SDN_BCALV_EDIT_03_SAVE_1.
**PROGRAM bcalv_edit_03.
* Purpose:
* ~~~~~~~~
* In this example the user may change values of fields
* SEATSOCC (occupied seats) and/or PLANETYPE. The report checks
* the input value(s) semantically and provides protocol
* messages in case of error.
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Change values of the column "occupied seats" or "Planetype" or
* both (in the same line). Try to provocate errors.
* Click on the check symbol or press return to initiate checking.
* (ALV also checks input before any functions like sorting,
* filtering or doubleclick are processed. These functions are
* only active if the input does not contain any errors).
* The ALV Grid Control first checks if the input is correct
* according to DDIC-Information (Type, lenght). Then semantic
* checks are made by the application using event handler method
* HANDLE_DATA_CHANGED.
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Set status of columns PLANETYPE and SEATSOCC to editable.
* 2.Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
* 3.Optionally register ENTER to raise event DATA_CHANGED.
* (Per default the user may check data by using the check icon).
* 4.Define and implement event handler to handle event DATA_CHANGED.
* 5.Loop over table MT_GOOD_CELLS to check all values that are
* valid due to checks according to information of the DDIC.
* 6.Within a check cycle:
* 6a.Get new cell value to check it using method GET_CELL_VALUE.
* (In this case SEATSOCC).
* 6b.If the value is valid you may want to change values of
* other cells.
* 6c.If the value is not valid create an protocol entry in
* the application log.
* 6d.To access old values (which where not changed in this check cycle)
* use your output table GT_OUTTAB.
* 7.Display application log if an error has occured.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
g_max TYPE i VALUE 100.
* local class to handle semantic checks
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: g_event_receiver TYPE REF TO lcl_event_receiver.
DATA: gt_outtab TYPE TABLE OF sflight.
PARAMETERS:
p_byref RADIOBUTTON GROUP rad1, " pass itab by reference
p_byval RADIOBUTTON GROUP rad1. " pass itab by value
* LOCAL CLASS Definition
*§4.Define and implement event handler to handle event DATA_CHANGED.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
* This flag is set if any error occured in one of the
* following methods:
DATA: error_in_data TYPE c READ-ONLY.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
PRIVATE SECTION.
*** This flag is set if any error occured in one of the
*** following methods:
** DATA: error_in_data TYPE c.
* Methods to modularize event handler method HANDLE_DATA_CHANGED:
METHODS: check_planetype
IMPORTING
ps_good_planetype TYPE lvc_s_modi
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
METHODS: ch_new_plane_v_new_seatsocc
IMPORTING
psg_plane TYPE lvc_s_modi
psg_socc TYPE lvc_s_modi
ps_saplane TYPE saplane
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
METHODS: ch_new_plane_v_old_seatsocc
IMPORTING
psg_plane TYPE lvc_s_modi
ps_saplane TYPE saplane
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
METHODS: check_seatsocc
IMPORTING
ps_good TYPE lvc_s_modi
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
* This is a suggestion how you could comment your checks in each method:
* CHECK: fieldname(old/new value) !<comp> fieldname(old/new value)
* IF NOT: (What to tell the user is wrong about the input)
* Remarks:
* fieldname: fieldname of table for the corresponding column
* (old/new value): ckeck with value of GT_OUTTAB or MT_GOOD_CELLS.
* !<comp> : the value is valid if the condition <comp> holds.
* Example:
* CHECK seatsocc(new) !>= seatsmax(old)
* IF NOT: There are not enough number of seats according to this
* planetype.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: ls_good TYPE lvc_s_modi.
error_in_data = space.
* semantic checks
* Identify columns which were changed and check input
* against output table gt_outtab or other new input values of one row.
* Table er_data_changed->mt_good_cells holds all cells that
* are valid according to checks against their DDIC data.
* No matter in which order the input was made this table is
* ordered by rows (row_id). For each row, the entries are
* sorted by columns according to their order in the fieldcatalog
* (not the defined order using field COL_POS but the order
* given by the position of the record in the fieldcatalog).
* The order is relevant if new inputs in several columns of
* the same row are dependent. In this example,
* method 'ch_new_plane_v_new_seatsocc' needs only to be called
* once since we know that the corresponding check is already done
* when checking column PLANETYPE (see also method 'check_seatsocc').
*§5.Loop over table MT_GOOD_CELLS to check all values that are
* valid due to checks according to information of the DDIC.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
CASE ls_good-fieldname.
* check if column PLANETYPE of this row was changed
WHEN 'PLANETYPE'.
CALL METHOD check_planetype
EXPORTING
ps_good_planetype = ls_good
pr_data_changed = er_data_changed.
* check if column SEATSOCC of this row was changed
WHEN 'SEATSOCC'.
CALL METHOD check_seatsocc
EXPORTING
ps_good = ls_good
pr_data_changed = er_data_changed.
ENDCASE.
ENDLOOP.
*§7.Display application log if an error has occured.
IF error_in_data EQ 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
METHOD check_planetype.
* Overview of checks according to field PLANETYPE
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* a) Does the Planetype exists? (check against check table SAPLANE)
* b) Are the number of seats (SEATSMAX) of the new planetype
* sufficient to fullfill requested bookings (SEATSOCC)?
* b1) SEATSOCC (occupied seats) also changed within
* this check cycle.
* b2) SEATSOCC has not changed within this cycle.
DATA: l_planetype TYPE s_planetye,
ls_saplane TYPE saplane,
ls_good_seatsocc TYPE lvc_s_modi.
* Get new cell value to check it.
* (In this case: PLANETYPE).
CALL METHOD pr_data_changed->get_cell_value
EXPORTING
i_row_id = ps_good_planetype-row_id
i_fieldname = ps_good_planetype-fieldname
IMPORTING
e_value = l_planetype.
* existence check: Does the plane exists?
SELECT SINGLE * FROM saplane INTO ls_saplane WHERE
planetype = l_planetype.
IF sy-subrc NE 0.
* In case of error, create a protocol entry in the application log.
* Possible values for message type ('i_msgty'):
* 'A': Abort (Stop sign)
* 'E': Error (red LED)
* 'W': Warning (yellow LED)
* 'I': Information (green LED)
CALL METHOD pr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-m03 "Flugzeugtyp
i_msgv2 = l_planetype
i_msgv3 = text-m05 "exitstiert nicht
i_fieldname = ps_good_planetype-fieldname
i_row_id = ps_good_planetype-row_id.
error_in_data = 'X'.
EXIT. "plane does not exit, so we're finished here!
ENDIF.
* Check if other relevant fields of this row have been changed, too.
READ TABLE pr_data_changed->mt_good_cells INTO ls_good_seatsocc
WITH KEY row_id = ps_good_planetype-row_id
fieldname = 'SEATSOCC'.
IF sy-subrc = 0.
CALL METHOD ch_new_plane_v_new_seatsocc
EXPORTING
psg_plane = ps_good_planetype
psg_socc = ls_good_seatsocc
ps_saplane = ls_saplane
pr_data_changed = pr_data_changed.
ELSE.
CALL METHOD ch_new_plane_v_old_seatsocc
EXPORTING
psg_plane = ps_good_planetype
ps_saplane = ls_saplane
pr_data_changed = pr_data_changed.
ENDIF.
ENDMETHOD. " CHECK_PLANETYPE
METHOD ch_new_plane_v_new_seatsocc.
DATA: l_seatsocc TYPE s_seatsocc.
*§5a.Get new cell value to check it using method GET_CELL_VALUE.
* (In this case SEATSOCC).
CALL METHOD pr_data_changed->get_cell_value
EXPORTING
i_row_id = psg_socc-row_id
i_fieldname = psg_socc-fieldname
IMPORTING
e_value = l_seatsocc.
* CHECK: SEATSMAX(of new planetype) !>= SEATSOCC(new value)
* IF NOT: Message for wrong planetype
IF ps_saplane-seatsmax GE l_seatsocc.
*§5b.If the value is valid you may want to change values of
* other cells.
CALL METHOD pr_data_changed->modify_cell
EXPORTING
i_row_id = psg_plane-row_id
i_fieldname = 'SEATSMAX'
i_value = ps_saplane-seatsmax.
ELSE.
*§5c.If the value is not valid create an protocol entry in
* the application log.
* Possible values for message type ('i_msgty'):
* 'A': Abort (Stop sign)
* 'E': Error (red LED)
* 'W': Warning (yellow LED)
* 'I': Information (green LED)
CALL METHOD pr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-m03 "Flugzeugtyp
i_msgv2 = ps_saplane-planetype
i_msgv3 = text-m04 "hat nicht genug Sitzplätze
i_fieldname = psg_plane-fieldname
i_row_id = psg_plane-row_id.
error_in_data = 'X'.
ENDIF.
ENDMETHOD. "ch_new_plane_v_new_seatsocc
METHOD ch_new_plane_v_old_seatsocc.
DATA: l_old_seatsocc TYPE s_seatsocc,
ls_outtab TYPE sflight.
*§5d.To access old values (which where not changed in this check cycle)
* use your output table GT_OUTTAB.
READ TABLE gt_outtab INTO ls_outtab INDEX psg_plane-row_id.
l_old_seatsocc = ls_outtab-seatsocc.
* CHECK: SEATSMAX(of new planetype) !>= SEATSOCC(old value)
* IF NOT: Message for wrong planetype
IF ps_saplane-seatsmax GE l_old_seatsocc.
* ok->field seatsmax can be changed
CALL METHOD pr_data_changed->modify_cell
EXPORTING
i_row_id = psg_plane-row_id
i_fieldname = 'SEATSMAX'
i_value = ps_saplane-seatsmax.
ELSE.
CALL METHOD pr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-m03 "Flugzeugtyp
i_msgv2 = ps_saplane-planetype
i_msgv3 = text-m04 "hat nicht genug Sitzplätze
i_fieldname = psg_plane-fieldname
i_row_id = psg_plane-row_id.
error_in_data = 'X'.
ENDIF.
ENDMETHOD. "ch_new_plane_v_old_seatsocc
*& Form CHECK_SEATSOCC
* text
* -->P_LS_GOOD text
* -->P_ER_DATA_CHANGED text
METHOD check_seatsocc.
DATA: l_seatsocc TYPE s_seatsocc,
l_old_seatsmax TYPE s_seatsmax,
ls_outtab TYPE sflight,
ls_good TYPE lvc_s_modi.
* Check if the planetype has changed, too.
READ TABLE pr_data_changed->mt_good_cells INTO ls_good
WITH KEY row_id = ps_good-row_id
fieldname = 'PLANETYPE'.
IF sy-subrc EQ 0.
* remark: the check
* seatsocc (new value) <= seatsmax (new value)
* was already handled by form 'ch_new_plane_v_new_seatsocc'.
* so we are finished here.
EXIT.
ENDIF.
* CHECK: seatsocc (new value) <= seatsmax (old value)
* IF NOT: Message that SEATSOCC is to high.
* get new cell value of SEATSOCC.
CALL METHOD pr_data_changed->get_cell_value
EXPORTING
i_row_id = ps_good-row_id
i_fieldname = ps_good-fieldname
IMPORTING
e_value = l_seatsocc.
* get old cell value of SEATSMAX
READ TABLE gt_outtab INTO ls_outtab INDEX ps_good-row_id.
l_old_seatsmax = ls_outtab-seatsmax.
IF l_seatsocc > l_old_seatsmax.
CALL METHOD pr_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-m01 "Die Anzahl der belegten Plätze
i_msgv2 = text-m02 "übersteigt die Kapazität des Flugzeugs
i_msgv3 = ls_outtab-planetype
i_fieldname = ps_good-fieldname
i_row_id = ps_good-row_id.
error_in_data = 'X'.
ENDIF.
ENDMETHOD. " CHECK_SEATSOCC
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* MAIN *
END-OF-SELECTION.
CALL SCREEN 100.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
IF ( p_byval = 'X' ).
PERFORM create_and_init_alv_byval
CHANGING gt_outtab
gt_fieldcat
gs_layout.
ELSE. " ( p_byref = 'X' ).
PERFORM create_and_init_alv CHANGING gt_outtab
gt_fieldcat
gs_layout.
ENDIF.
ENDIF.
ENDMODULE. "pbo OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
TRANSLATE ok_code TO UPPER CASE.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'SAVE'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'SFLIGHT'
i_grid_title =
'Before CHECK_DATA_CHANGED -> changes not yet retrieved'
TABLES
t_outtab = gt_outtab
EXCEPTIONS
OTHERS = 99.
g_grid->check_changed_data( ).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'SFLIGHT'
i_grid_title =
'After CHECK_DATA_CHANGED -> changes retrieved'
TABLES
t_outtab = gt_outtab
EXCEPTIONS
OTHERS = 99.
PERFORM save_data.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
*& Form SAVE_DATA
* text
* --> p1 text
* <-- p2 text
FORM save_data .
IF ( g_event_receiver->error_in_data = 'X' ).
MESSAGE 'Error in data -> saving not possible' TYPE 'S'.
ELSE.
MESSAGE 'Data saved' TYPE 'S'. " simulates DB update
ENDIF.
ENDFORM. " SAVE_DATA
* FORM EXIT_PROGRAM *
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "exit_program
*& Form BUILD_FIELDCAT
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
IF ls_fcat-fieldname EQ 'PLANETYPE'
OR ls_fcat-fieldname EQ 'SEATSOCC'.
*§1.Set status of columns PLANETYPE and SEATSOCC to editable.
ls_fcat-edit = 'X'.
* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form create_and_init_alv_byval
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv_byval
CHANGING
value(pt_outtab) LIKE gt_outtab[] " by value
pt_fieldcat TYPE lvc_t_fcat
ps_layout TYPE lvc_s_layo.
PERFORM create_and_init_alv CHANGING pt_outtab
pt_fieldcat
ps_layout.
ENDFORM. " create_and_init_alv_byval
*& Form CREATE_AND_INIT_ALV
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv
CHANGING
pt_outtab LIKE gt_outtab[] " by reference
pt_fieldcat TYPE lvc_t_fcat
ps_layout TYPE lvc_s_layo.
DATA: lt_exclude TYPE ui_functions.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
* Build fieldcat and set columns PLANETYPE and SEATSOCC
* edit enabled.
PERFORM build_fieldcat CHANGING pt_fieldcat.
*§2.Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM exclude_tb_functions CHANGING lt_exclude.
SELECT * FROM sflight INTO TABLE pt_outtab UP TO g_max ROWS.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = ps_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab.
* set editable cells to ready for input
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
*§3.Optionally register ENTER to raise event DATA_CHANGED.
* (Per default the user may check data by using the check icon).
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_data_changed FOR g_grid.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* <--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS -
ALV_GRID- check_changed_data not working properly?
DEV experts:
In the PAI of my dialog screen (where I have an editable OO ALV):
This code works when my table behind the alv is already populated,
however, when it isn't populated and I put new values in and hit save.
DATA : wl_refresh TYPE c VALUE 'X'.
CALL METHOD C_alv_ELE->check_changed_data
CHANGING c_refresh = wl_refresh.
CALL METHOD C_ALV_ELE->REFRESH_TABLE_DISPLAY.
It just 'skips' the check_changed_data automatically and I have no idea why...
There is obviously data entered in the ALV, but I can't make it show up in the table behind the ALV. When the screen ends in the PAI and goes into PBO and displays its still in the ALV, but no sign of it in the table behind the ALV.
Any suggestions?Dear
Are you using ALV events ?
Check this for more info on ALV events:
[ALV Events;
This one has a list with all the ALV events avaialable
[Alv events;
It seems your code is not doing proper event handling, and your messing with the PBO/PAI instead.
Kind Regards
/Ricardo Quintas -
Problem with check_changed_data
hello
I have added a checkbox and a button to a ALV Grid report. When the checkbox is ckecked and the button is pushed, the record with the checkbox used for further processing. I have been searching thru the SDN and it looks like I need to use the "CHECK_CHANGED_DATA" statement. I have coded it like it mentions in the various threads and my process is short dumping. I have this coded in my program, not in the PAI screen. I have seen this coded at both places but when I try to code it in the PAI section of the screen, I get error on the DATA statement.
data: l_valid type c.
data: g_grid type ref to cl_gui_alv_grid.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
I have coded it in the program in the user-command section an when I run the program in debug at display the g_grid , i get the following and the program short dumps with Access via 'NULL' object reference not possible."
I am not sure what I am doing wrong.
does anyone know what is causing this?Hello Timothy
If you have placed a custom container on the dynpro where you want to display the ALV list then the name of this container is what you are looking for.
If the ALV list is the only displayed elements on your dynpro then I prefer to use a docking container instead of a custom container. Sample coding lookes like this:
Within routine MAIN the instances are created (see method INIT_CONTROLS). After that I just link the docking container instance to my dynpro '0100' which is empty.
*& START-OF-SELECTION *
START-OF-SELECTION.
PERFORM main.
gd_repid = syst-repid.
CALL METHOD zcl_material_gdsn=>mo_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 3
OTHERS = 4.
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 SCREEN '0100'.
END-OF-SELECTION.
method INIT_CONTROLS.
* Create docking container
CREATE OBJECT mo_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
others = 6.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD mo_docking->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
* Create ALV grids
CREATE OBJECT mo_grid
EXPORTING
i_parent = mo_docking
EXCEPTIONS
others = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD set_handler( ).
endmethod.
Regards
Uwe -
Need help using method check_changed_data correctly
I'm using method check_changed_data in my ALV program to update the grid with changes the user makes. The method works fine for this purpose. But I also want to know if any data actually changed. Can anyone give me an example?
FORM update_vendor .
do I need to call a different method before check_changed_data ?
call method gridhead->check_changed_data.
is there a parameter available here to see if anything actually
changed?
loop at gt_head into wa_head.
clear wa_head-lifnam.
select single name1 into wa_head-lifnam
from LFA1 where lifnr eq wa_head-lifnr.
if sy-subrc eq 0.
modify gt_head from wa_head.
endif.
endloop.
ENDFORM. " update_vendorHello Beth
If data have been changed then method <b>go_grid->CHECK_CHANGED_DATA</b> will raise event <b>DATA_CHANGED</b>. If you have an event handler method like HANDLE_DATA_CHANGED then you can, for example, validate the changes.
If no data were changed event DATA_CHANGED will not be raised and your event handler method will not be called.
Regards
Uwe -
Please explain how the method CHECK_CHANGED_DATA works?
Hi experts,
Can any of you experts please explain how the method <b>CHECK_CHANGED_DATA</b>
of <b>CL_GUI_ALV_GRID</b> class works ?
Thanks in advance
regards,
AshwinDATA: l_valid TYPE c.
Data grid1 type ref to cl_gui_alv_grid.
CALL METHOD grid1->check_changed_data IMPORTING e_valid = l_valid.
This method checks if any data is changed on the grid if there any editable fields .
And updates the changed values
Message was edited by:
Chandrasekhar Jagarlamudi -
Problem of alv CHECK_CHANGED_DATA method
hi,experts
i have created an alv with a checkbox field. i called the GRID_01->CHECK_CHANGED_DATA method to get what the records user selected.
the first time user select 2 records, it works fine and popup an 'E' type message to let user select only 1 record.
the second time user select 1 record, but it still got 2 record after CHECK_CHANGED_DATA, and popup message.
the third time user select 1 record again, and it works fine again, got 1 record and run.
what the problem it is?
hunger for your advice! thanks!Lee,
I wonder how you solved this.
Please share if you don't mind. -
Check_changed_data not working properly
Hi,
I have created a editable ALV using reuse_alv_grid_display. There is a field with type P length 13 Decimals 2.
when I use check_changed_data method to reflect the changes to internal table I am having some trouble with decimal places.
for eg 123456.23 is the value and I have changed the value to 123456.00 now after check_changed_data what I require is 123456.00 but it is giving me 1234.56
decimals are getting shifted if the values after decimal point is 00.
Thanks & Regards,
Nooruddin BohraDear
Are you using ALV events ?
Check this for more info on ALV events:
[ALV Events;
This one has a list with all the ALV events avaialable
[Alv events;
It seems your code is not doing proper event handling, and your messing with the PBO/PAI instead.
Kind Regards
/Ricardo Quintas -
Check_Changed_Data not working
Hi all,
In my BADI i am triggering an ALV grid pop-up to select values with check box. For getting the changed data i am using check_changed_data method. Even after selecting the check boxes in ALV pop i am not able to get the changed data.
program code :
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_grid_title = 'Select MAil ID'
is_layout = lt_layout
it_fieldcat = t_fieldcat
i_screen_start_column = 20
i_screen_start_line = 5
i_screen_end_column = 70
i_screen_end_line = 15
I_SAVE = 'A'
TABLES
t_outtab = it_ZEMAIL
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
data: gd_repid like sy-repid,
ref_grid type ref to cl_gui_alv_grid.
if ref_grid is initial.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref_grid.
endif.
if not ref_grid is initial.
call method ref_grid->check_changed_data .
endif.
while debugging i found that the ref_grid remains initial after the function GET_GLOBALS_FROM_SLVC_FULLSCR.
so call method ref_grid->check_changed_data is not executed.
So how can i solve this problem.
Thanks in advance.
Venkat.Hi,
u need to use user command
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_grid_title = 'Select MAil ID'
i_callback_user_command = 'USER_COMMAND'
is_layout = lt_layout
it_fieldcat = t_fieldcat
i_screen_start_column = 20
i_screen_start_line = 5
i_screen_end_column = 70
i_screen_end_line = 15
I_SAVE = 'A'
TABLES
t_outtab = it_ZEMAIL
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc 0.
ENDIF.
FORM user_command USING lv_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Declaration of local Variables
DATA : lv_ref1 TYPE REF TO cl_gui_alv_grid.
Event
WHEN <event>
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lv_ref1.
CALL METHOD lv_ref1->check_changed_data.
Now try this...
Regards,
Nagaraj -
Issue with CHECK_CHANGED_DATA method of CL_GUI_ALV_GRID class
HI,
I want to check whether my grid has any changes or not, for that i am using the CHECK_CHANGED_DATA method of CL_GUI_ALV_GRID class,
What i am doing is.... I am doing some changes in my grid data and clicking on SAVE . This time CHECK_CHANGED_DATA is saying the grid have changes ,and i am displaying a pop up whether to save the changes or not. And i am saving changes.
Till now Fine.
If i click on SAVE again CHECK_CHANGED_DATA is showing again the Grid has changes.
So how can i solve this problem.
Thanks in advance.Hello Narendra
If you do not need to do any validations of the changed ALV list data then you can use a very simple approach which does not even require an event handler for event DATA_CHANGED.
The crucial part of the coding is shown below, followed by the entire sample report ZUS_SDN_ALV_EDITABLE_1A. Basically, the ALV list is stored as a "PBO" image of the data (GT_OUTTAB_PBO). And only if the user changed the data (i.e. GT_OUTTAB_PBO <> GT_OUTTAB) the save option including the popup is executed.
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
" NOTE: retrieve changed data from frontend (grid control) into
" the backend (itab in ABAP)
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'SAVE'.
IF ( gt_outtab = gt_outtab_pbo ).
MESSAGE 'No data changed' TYPE 'S'.
ELSE.
CLEAR: gd_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'Save data?'
IMPORTING
answer = gd_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF ( gd_answer = '1' ). " yes
MESSAGE 'Data successfully saved' TYPE 'S'.
gt_outtab_pbo = gt_outtab. " update PBO data !!!
ELSE.
MESSAGE 'Action cancelled by user' TYPE 'S'.
ENDIF.
ENDIF.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Report ZUS_SDN_ALV_EDITABLE
* Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
**PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
**PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
REPORT zus_sdn_alv_editable_1a.
TYPE-POOLS: abap.
CONSTANTS:
gc_tabname TYPE tabname VALUE 'KNB1'.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knb1.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab,
gt_outtab_pbo TYPE ty_t_outtab.
DATA:
gd_answer TYPE c.
START-OF-SELECTION.
SELECT * FROM (gc_tabname) INTO TABLE gt_outtab UP TO 99 ROWS.
gt_outtab_pbo = gt_outtab. " set PBO data
PERFORM init_controls.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
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.
" NOTE: not required
* set handler:
* lcl_eventhandler=>handle_data_changed for go_grid.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
i_save = 'A'
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE:
* Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
*I_SAVE
*Determines the options available to the user for saving a layout:
*? 'X': global saving only
*? 'U': user-specific saving only
*? 'A': corresponds to 'X' and 'U'
*? SPACE: no saving
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
" NOTE: retrieve changed data from frontend (grid control) into
" the backend (itab in ABAP)
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'SAVE'.
IF ( gt_outtab = gt_outtab_pbo ).
MESSAGE 'No data changed' TYPE 'S'.
ELSE.
CLEAR: gd_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'Save data?'
* TEXT_BUTTON_1 = 'Ja'(001)
* ICON_BUTTON_1 = ' '
* TEXT_BUTTON_2 = 'Nein'(002)
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = gd_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Triggers PAI of the dynpro with the specified ok-code
IF ( gd_answer = '1' ). " yes
MESSAGE 'Data successfully saved' TYPE 'S'.
gt_outtab_pbo = gt_outtab. " update PBO data !!!
ELSE.
MESSAGE 'Action cancelled by user' TYPE 'S'.
ENDIF.
ENDIF.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = gc_tabname
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
ls_fcat-edit = abap_true.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING edit
WHERE ( key NE abap_true ).
ENDFORM. " BUILD_FIELDCATALOG
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
Regards
Uwe -
CHECK_CHANGED_DATA not populating entire data
Hi All,
I'm having problem in using the method CHECK_CHANGED_DATA of the class CL_GUI_ALV_GRID. I have 6 columns/fields in the grid, and when using this method, it is not returning the content of all the 6 fields. It's able to recognize the changed or added row but the value for one particular field is not being populated. Any inputs on this ?
Just as an information, I'm using OO techniques and registered events for this.
Thanks,
DKHi
No particular setting has to be done for the fields, that event should be triggered as soon as a value is changed.
Try to check if there's something strange in catalog table
Max -
"CHECK_CHANGED_DATA" WITHOUT
Hi abap gurus,
I am doing ALV grid with oops concept . I am not able to save the changes in the internl table using 'check_changed_data' using checkbox . It is giving following error :
Can anyone give me any clue ? Without using check box it is fine .
You attempted to access an unassigned field symbol
(data segment 32781).
This error may occur if
- You address a typed field symbol before it has been set with
ASSIGN
- You address a field symbol that pointed to the line of an
internal table that was deleted
- You address a field symbol that was previously reset using
UNASSIGN or that pointed to a local field that no
longer exists
- You address a global function interface, although the
respective function module is not active - that is, is
not in the list of active calls. The list of active calls
can be taken from this short dump.
translate ls_cells_temp-value to upper case. "#EC TRANSLANG
assign ls_cells_temp-value to <l_currency>.
else.
assign ls_cells_temp-value to <l_currency>.
clear <l_currency>.
endif.
if <l_currency> is initial.
assign component ls_fieldcat-qfieldname
of structure <ls_wa> to <l_currency>.
endif.
if <l_currency> is initial.
assign ls_fieldcat-QUANTITY to <l_currency>.
if sy-subrc ne 0.
assign space to <l_currency>.
endif.
endif.
endif.
else.
if not ls_fieldcat-currency is initial.
assign ls_fieldcat-currency to <l_currency>.
elseif not ls_fieldcat-quantity is initial.
assign ls_fieldcat-quantity to <l_currency>.
else.
assign space to <l_currency>.
endif.
endif.
>>>>> call method me->formal_field_check_no_ddic
214 exporting
215 i_currency = <l_currency>
216 i_value = ls_cells-value
217 i_row_id = ls_cells-row_id
218 i_tabix = l_tabix
219 is_fieldcat = ls_fieldcat
220 importing
221 eflg_invalid = eflg_invalid
222 changing
223 c_field = <l_field>
224 ct_good_cells = et_good_cells
225 ct_mod_cells = et_mod_cells.
226 else.
227 *-- Formal field check with DDIC reference
228 call method me->formal_field_check_ddic
229 exportingYes i know is old post. but i want contribute with this thread.
i have a similar dump, and YES my problem was on fieldcat.
curious, changed this line:
ws_gt_fieldcat-fieldname = 'Selection'.
by this:
ws_gt_fieldcat-fieldname = 'SELECTION'.
(see Uppercase).
and voila!!!! worked....
thanks!!! -
Pls help: check_changed_data not updating the Itab from non-OO ALV GRID
Hi experts,
Please help this newbie here. I have problem with updating my internal table with multiple cells changes in my ALV. I've used the FM 'GET_GLOBALS_FROM_SLVC_FULLSCR' and the method 'CHECK_CHANGED_DATA'. When I debugged, I could see the changes being captured in ref1.
How can I make sure that the changes were already updated into the itab new_antrag after I presses the button command 'EX_SEND'? The original program is leave program RPTARQUIATEST.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD LIKE SLIS_SELFIELD
Data: ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data.
read table new_antrag index rs_selfield-index into wa_new_antrag.
case r_ucomm.
when 'EX_SEND'.
perform before_prepare using rs_selfield
new_antrag
changing
wa_new_antrag.
perform request_check using req
pernr
modus
check_command
g_check_mode
changing
checked_req
messages.
perform request_exec using wa_new_antrag-request_id
pernr
modus
c_cmd_exec_cmd
changing
exec_req
messages.
perform after_exec using exec_req.
endcase.
ENDFORM.
Please help. Points will be awarded for constructive solutions which help in the problem solving. Thank you.
Cheers,
DamienSorry, please ignore this thead because I had unmarked it as a question by accident.
-
"CHECK_CHANGED_DATA" of the ALV Grid class
Hi Friends
I have an application in which I have created an editable ALV grid using CL_GUI_ALV_GRID.I have also registered the "ENTER" event of the class so that the method "CHECK_CHANGED_DATA" gets fired which in turn raises event DATA_CHANGED and looks then for any entries
in the error protocol.
The problem is in case of some values entered by the user the method "CHECK_CHANGED_DATA" is throwing a "Conversion Exit"(field too short) short dump.
To handle this error I need a method which fires before the "CHECK_CHANGED_DATA" and gives me all the values entered by the user on the screen.This way I will be able to trap the error.
Any suggestions are welcomed.FORM DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
********at this position call a conversion exit function module which takes l_value and returns a value in the required format*********
ENDLOOP.
ENDFORM. " DATA_CHANGED
FORM SAVE_DATA .
DATA FLAGG.
DATA ER_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
CALL METHOD GO_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = FLAGG.
IF FLAGG = 'X'.
PERFORM UPDATE_DBTAB.
MESSAGE 'DATA UPDATED IN TABLES' TYPE 'I'.
LEAVE TO SCREEN 0.
ELSE.
MESSAGE 'DATA NOT CHANGED' TYPE 'S'.
ENDIF.
ENDFORM. " SAVE_D
Maybe you are looking for
-
Applescript: transferring total appearance from one page item to another
What is the best way to transfer all the properties of a path item that determine appearance to another path item? What if those path items are in separate documents? Should I copy and paste? what about: set item_properties to every property of page
-
Parser dimension ACCOUNT's xml file error.
Hi friends, i manully uploading master data in ACCOUNT dimension. what i did here, i manually added PARENTH1hierarchy and i changed that column position infront of "ACCTYPE" property. While pasting i might paste on ACCTYPE property & processed ACCOUN
-
Passing binary information in a synchronous scenario
Hi All, I am working on a synchronous scenario where I am sending an HTTP request to third party and I am getting back the response. My requirement is that I need to pass through this response as it is from XI, no transformation is required. This hap
-
System updates = no internet with konqueror only[solved]
Could not start process Unable to create io-slave: klauncher said: Error loading 'kio_http'. I get this error after a few recents updates. I still have internet connection with firefox and other system services. heres what I've just updated: [03/15/0
-
TM backup of iBook G4 to new Mac book w/o Firewire
What is the best way to access my Time Machine backup that is on an external firewire drive via a new MacBook that does not have Firewire?