Doubt in Editable ALV
Dear Friends,
I have editable ALV and capturing there save event its working properly.
so my problem is..
when i change there cell values can i capture that event like follows.
in my editable column only can be change 0-100 value cant be <0 or >100 values.
is it possible ....
please reply me....if possible give some sample plz....
Thanks in Advance
Hi Nelson,
Check out this code.
*& Report ZST_ALV_DATA_CHANGE_EVENT
REPORT ZST_ALV_DATA_CHANGE_EVENT.
CLASS lcl_grid DEFINITION
class lcl_grid DEFINITION.
PUBLIC SECTION.
methods: handle_data_changed
for event data_changed of cl_gui_alv_grid
IMPORTING er_data_changed.
endclass. "lcl_grid DEFINITION
CLASS lcl_grid IMPLEMENTATION
class lcl_grid IMPLEMENTATION.
method handle_data_changed.
perform validation using er_data_changed.
endmethod. "handle_data_changed
endclass. "lcl_grid IMPLEMENTATION
types: begin of ty_itab,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
netwr TYPE vbap-netwr,
end of ty_itab.
data: lt_itab TYPE TABLE OF ty_itab,
lw_itab TYPE ty_itab.
data: lt_fcat type lvc_t_fcat,
lw_fcat TYPE lvc_s_fcat.
data: l_grid TYPE REF TO cl_gui_alv_grid,
l_custom TYPE REF TO cl_gui_custom_container,
l_class TYPE ref to lcl_grid.
start-of-selection.
select vbeln
posnr
netwr
from vbap
into table lt_itab
up to 50 rows.
delete lt_itab where posnr ne '000010'.
perform build_fieldcatalog.
call screen 200.
*& Module STATUS_0200 OUTPUT
text
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZST_GUI'.
SET TITLEBAR 'xxx'.
if l_custom is initial.
CREATE OBJECT L_CUSTOM
EXPORTING
PARENT =
CONTAINER_NAME = 'CUSTOM'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
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 OBJECT L_GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = l_custom
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 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 L_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = lt_itab[]
IT_FIELDCATALOG = lt_fcat[]
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 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.
create OBJECT l_class.
endif.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
MODULE USER_COMMAND_0200 INPUT.
if sy-ucomm = 'EXIT'.
leave program.
elseif sy-ucomm = 'SAVE'.
set HANDLER l_class->handle_data_changed for l_grid.
data: l_char TYPE c.
CALL METHOD L_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = l_char.
endif.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Form BUILD_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCATALOG .
clear lw_fcat.
lw_fcat-fieldname = 'VBELN'.
lw_fcat-scrtext_l = 'Sales document'.
append lw_fcat to lt_fcat.
clear lw_fcat.
lw_fcat-fieldname = 'POSNR'.
lw_fcat-scrtext_l = 'Sales document'.
append lw_fcat to lt_fcat.
clear lw_fcat.
lw_fcat-fieldname = 'NETWR'.
lw_fcat-scrtext_l = 'Quantity'.
lw_fcat-edit = 'X'.
append lw_fcat to lt_fcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form VALIDATION
text
-->P_ER_DATA_CHANGED text
FORM VALIDATION USING er_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
data: temp type vbap-netwr.
DATA: ls_good TYPE lvc_s_modi.
DATA wa LIKE LINE OF lt_good_cells.
CALL METHOD l_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 'NETWR'. "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
if temp > 1000000.
message e000(8i) with 'amount should not be greater than 200'.
endif.
"Make your validations here.
ENDCASE.
endloop.
ENDFORM. " VALIDATION
in the ZST_GUI
there are two function code 'SAVE' and 'EXIT'.
regards,
Santosh Thorat
Similar Messages
-
Doubt regarding editable ALV report using Classes
I need to create an ALV report and make few fields editable
and i need to update the changes to the corresponding database tables
for that please suggest me some idea or provide me sample code for that
urgentHi ramesh,
Please check this example program. I think it will help for some extent.
[code]&----
*& Report ZSUMA_INTERACTIVEREPORT *
report zsuma_interactivereport.
tables: vbak.
data :gr_alvgrid type ref to cl_gui_alv_grid,
gr_cc_name type scrfname value 'CC_ALV',
gr_ccontainer type ref to cl_gui_custom_container,
gr_fieldcat type lvc_t_fcat,
gr_layout type lvc_s_layo,
gr_sort type lvc_t_sort,
gr_get_cell type lvc_t_cell,
gr_set_cell type lvc_t_cell,
gr_hyper type lvc_t_hype,
gr_drop_down type lvc_t_drop,
is_variant type disvariant,
line_number type lvc_s_roid-row_id,
line(5) type c ,
cell_value type lvc_value.
data: begin of it_vbak occurs 0,
vbeln type vbak-vbeln,
erdat like vbak-erdat,
erzet like vbak-erzet,
netwr like vbak-netwr,
waerk like vbak-waerk,
*Below field is useful for making the entire row with different colors.
it must be a char of 4.and layout-info_fname should populate with
*this field.
rowcolor(4) type c,
*Below field is useful for making the INDIVIDUAL CELL with different
*colors.for this we have to include structure of type lvc_t_scol.
*layout-ctab_fname should be populate with this field.
cellcolor type lvc_t_scol,
*below field is added for for providing the hyperlinks to perticular
*field. at the time of field catalog , it_fcatalog-web_field should be
*populate with this field.
vbeln_hyper type int4,
*For displaying one cell as button.we have to declare one styles
*internal table .it has to be populate.at layout structure this table
*name has to be populate at layout-stylename.
cellstyle type lvc_t_styl,
end of it_vbak.
*& SELECTION SCREEN
selection-screen begin of block b1 with frame title text-001.
select-options s_vbeln for vbak-vbeln.
selection-screen end of block b1.
start-of-selection.
select vbeln
erdat
erzet
netwr
waerk
from vbak
into corresponding fields of table it_vbak
where vbeln in s_vbeln.
data: wa_cellcolor type lvc_s_scol,
wa_style type lvc_s_styl.
loop at it_vbak.
FOR ROW COLORING
if sy-tabix = 1.
it_vbak-rowcolor = 'C511'.
FOR PUTTING THE HYPERLINKS ON VBELN FIELD
it_vbak-vbeln_hyper = '1'.
modify it_vbak.
endif.
FOR CELL COLORING
if sy-tabix = 2.
wa_cellcolor-fname = 'ERZET'.
wa_cellcolor-color-col = '6'.
wa_cellcolor-color-int = '1'.
wa_cellcolor-color-inv = '1'.
append wa_cellcolor to it_vbak-cellcolor.
modify it_vbak index 2.
endif.
FOR DISPLAYING THE CELL AS A BUTTON
clear it_vbak-cellstyle.
at last.
read table it_vbak index sy-tabix.
wa_style-fieldname = 'NETWR'.
wa_style-style = cl_gui_alv_grid=>mc_style_button.
append wa_style to it_vbak-cellstyle .
modify it_vbak .
endat.
endloop.
if not it_vbak[] is initial.
call screen 100.
endif.
*CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
class gr_event_handler definition.
public section.
methods:handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing e_row_id e_column_id es_row_no.
endclass.
*CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
class gr_event_handler implementation.
method handle_hotspot_click.
perform handle_hotspot_click using e_row_id e_column_id es_row_no.
endmethod.
endclass.
*& Form BUILDING_FIELDCATALOG
text
<--P_GR_FIELDCAT text
form building_fieldcatalog changing p_gr_fieldcat type lvc_t_fcat.
data s_fieldcat type lvc_s_fcat.
s_fieldcat-fieldname = 'VBELN'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '1'.
s_fieldcat-coltext = 'DOCCUMENT NO.'.
s_fieldcat-key = ' '.
s_fieldcat-emphasize = 'C511'.
s_fieldcat-web_field = 'VBELN_HYPER'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'ERDAT'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '2'.
s_fieldcat-coltext = 'REC CREATE DATE.'.
s_fieldcat-emphasize = 'C311'.
s_fieldcat-hotspot = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'ERZET'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '3'.
s_fieldcat-coltext = 'TIME ENTRY.'.
*S_FIELDCAT-EMPHASIZE = 'C311'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'NETWR'.
s_fieldcat-outputlen = '15'.
s_fieldcat-col_pos = '4'.
s_fieldcat-emphasize = 'C311'.
s_fieldcat-coltext = 'NET WEIGHT.'.
s_fieldcat-do_sum = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
s_fieldcat-fieldname = 'WAERK'.
s_fieldcat-outputlen = '5'.
s_fieldcat-col_pos = '5'.
s_fieldcat-emphasize = 'C511'.
s_fieldcat-coltext = 'CURR.'.
FOR PUTTING THE DROP DOWN BOX.
s_fieldcat-drdn_hndl = '1'.
s_fieldcat-edit = 'X'.
append s_fieldcat to p_gr_fieldcat .
clear s_fieldcat.
endform. " BUILDING_FIELDCATALOG
*& Form CREATE_CCONTAINER_INSTANCE
text
--> p1 text
<-- p2 text
form create_ccontainer_instance .
create object gr_ccontainer
exporting
container_name = gr_cc_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
endform. " CREATE_CCONTAINER_INSTANCE
*& Form CREATE_ALVGRID_INSTANCE
text
--> p1 text
<-- p2 text
form create_alvgrid_instance .
create object gr_alvgrid
exporting
i_parent = gr_ccontainer
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 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.
endform. " CREATE_ALVGRID_INSTANCE
*& Form DISPLAYING_ALVGRID
text
--> p1 text
<-- p2 text
form displaying_alvgrid .
call method gr_alvgrid->set_table_for_first_display
exporting
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
is_variant = is_variant
i_save = 'A'
I_DEFAULT = 'X'
is_layout = gr_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
it_hyperlink = gr_hyper
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
changing
it_outtab = it_vbak[]
it_fieldcatalog = gr_fieldcat
it_sort = gr_sort
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 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 METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
IMPORTING
ES_LAYOUT = GR_LAYOUT
*GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
*CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GR_LAYOUT
endform. " DISPLAYING_ALVGRID
*& Form REFRESH_DISPLAY_TABLE
text
--> p1 text
<-- p2 text
form refresh_display_table .
call method gr_alvgrid->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
exceptions
finished = 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.
endform. " REFRESH_DISPLAY_TABLE
*& Form SETTING_LAYOUT
text
<--P_GR_LAYOUT text
form setting_layout changing p_gr_layout type lvc_s_layo.
p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
p_gr_layout-zebra = 'X'.
p_gr_layout-no_toolbar = ''.
p_gr_layout-sel_mode = 'D'.
p_gr_layout-info_fname = 'ROWCOLOR'.
p_gr_layout-ctab_fname = 'CELLCOLOR'.
p_gr_layout-stylefname = 'CELLSTYLE'.
endform. " SETTING_LAYOUT
*& Module STATUS_0100 OUTPUT
text
module status_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
set pf-status 'MENU'.
if gr_alvgrid is initial.
*CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
*TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
perform create_ccontainer_instance.
perform create_alvgrid_instance.
*VARIANT POPULATION.
perform setting_variants changing is_variant.
*BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
*TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
perform setting_hyperlinks_field changing gr_hyper.
*TO MAKE THE COLOUMN AS DROP DOWN.
perform setting_dropdown_column changing gr_drop_down.
perform building_fieldcatalog changing gr_fieldcat.
perform setting_layout changing gr_layout.
perform setting_sorting changing gr_sort.
perform setting_cells changing gr_set_cell.
perform displaying_alvgrid.
*PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
FOR ME AND I HAVE DOUBT .
perform creating_event_object.
*PERFORM REFRESH_DISPLAY_TABLE.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave to screen 000.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*& Form SETTING_SORTING
text
<--P_GR_SORT text
form setting_sorting changing p_gr_sort type lvc_t_sort.
data: lr_sort type lvc_s_sort.
lr_sort-spos = '1'.
lr_sort-fieldname = 'VBELN'.
lr_sort-up = 'X'.
append lr_sort to p_gr_sort.
lr_sort-spos = '2'.
lr_sort-fieldname = 'ERDAT'.
lr_sort-up = 'X'.
append lr_sort to p_gr_sort.
endform. " SETTING_SORTING
*& Form GETTING_CELL_DETAILS
text
<--P_GR_GET_CELL text
form getting_cell_details changing p_gr_get_cell.
call method gr_alvgrid->get_selected_cells
importing
et_cell = p_gr_get_cell
*CELL_VALUE = P_GR_GET_CELL-VALUE.
endform. " GETTING_CELL_DETAILS
*& Form SETTING_CELLS
text
<--P_GR_SET_CELL text
form setting_cells changing p_gr_set_cell type lvc_t_cell.
data:s_gr_set_cell type lvc_s_cell.
s_gr_set_cell-col_id-fieldname = 'NETWR'.
s_gr_set_cell-row_id-index = '3'.
append s_gr_set_cell to p_gr_set_cell.
call method gr_alvgrid->set_selected_cells
exporting
it_cells = p_gr_set_cell.
endform. " SETTING_CELLS
*& Form SETTING_HYPERLINKS_FIELD
text
<--P_GR_HYPER text
form setting_hyperlinks_field changing p_gr_hyper type lvc_t_hype.
data: is_hype type lvc_s_hype.
is_hype-handle = '1'.
is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
append is_hype to p_gr_hyper.
is_hype-handle = '2'.
is_hype-href = 'HTTP://SDN.SAP.COM'.
append is_hype to p_gr_hyper.
endform. " SETTING_HYPERLINKS_FIELD
*& Form SETTING_DROPDOWN_COLUMN
text
<--P_GR_DROP_DOWN text
form setting_dropdown_column changing p_gr_drop_down type lvc_t_drop.
data: wa_drop type lvc_s_drop.
wa_drop-handle = '1'.
wa_drop-value = '$'.
append wa_drop to p_gr_drop_down.
wa_drop-handle = '1'.
wa_drop-value = 'Rs'.
append wa_drop to p_gr_drop_down.
wa_drop-handle = '1'.
wa_drop-value = 'CUR'.
append wa_drop to p_gr_drop_down.
call method gr_alvgrid->set_drop_down_table
exporting
it_drop_down = p_gr_drop_down
IT_DROP_DOWN_ALIAS =
endform. " SETTING_DROPDOWN_COLUMN
*& Form SETTING_VARIANTS
text
<--P_IS_VARIANT text
form setting_variants changing p_is_variant type disvariant.
p_is_variant-report = sy-repid.
endform. " SETTING_VARIANTS
*& Form HANDLE_HOTSPOT_CLICK
text
-->P_E_ROW text
-->P_E_COLUMN text
-->P_E_ROW_NO text
form handle_hotspot_click using p_e_row_id type lvc_s_row
p_e_column_id type lvc_s_col
p_es_row_no type lvc_s_roid.
read table it_vbak index p_es_row_no-row_id.
if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
line = p_es_row_no-row_id.
line_number = p_es_row_no-row_id.
leave to screen 200.
endif.
endform. " HANDLE_HOTSPOT_CLICK
*& Form CREATING_EVENT_OBJECT
text
--> p1 text
<-- p2 text
form creating_event_object .
data event_handle type ref to gr_event_handler.
create object event_handle.
set handler event_handle->handle_hotspot_click for gr_alvgrid.
endform. " CREATING_EVENT_OBJECT
*& Module STATUS_0200 OUTPUT
text
module status_0200 output.
set pf-status 'BB'.
SET TITLEBAR 'xxx'.
*LINE = LINE_NUMBER.
endmodule. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
module user_command_0200 input.
if sy-ucomm = 'BACK'.
leave to screen 100.
endif.
endmodule. " USER_COMMAND_0200 INPUT[/code]
Reward points if helpful
Thanks,
Suma. -
Update the Billing orders after display/ modifiy in the Editable ALV
Hi Experts,
I have created one Editable ALV to display theBilling order with BP details,
Once user get the ALV output he can modify the content and same will be updated once he hits UPDATE button.
my requirement is after user hits the UPDATE button a background should be created and update of BO should happen also user user should able to see the status by checking the SPOOL.
currently i am using the FM crm_order_maintain to update, kindly guide me how to process this step in background for all the entries which are selected in ALV by user.
i think i can use SUBMIT with JOB_OPEN and JOB_CLOSE, but i need some same code & guidance.
Thanks in Advance.
Regards,
Pradeepproblem solved
-
How can we find out data in an editable ALV grid has been changed or not?
Hi Experts,
How can we find out whether a data in an editable ALV grid has been changed or not.
I am using the
FM -> REUSE_ALV_GRID_DISPLAY_LVC
for ALV display.
I have to chekc whther data has been changed or not befor saving. if changed then only i want to
SAVE
. I cannot use the internal table comparison method for this purpose also i am not using OOP ALV.
So kindly sugest me an alternative.
Thanks and Regards,
ShahanaHi,
Thanks for your answer. I already saw this post.
See this method.
CALL METHOD reuse_alv_grid->check_changed_data
IMPORTING
e_valid = lv_check.
This will update the internal table with the edited values. Then we can go for internal table comparison.
But my scenario will not allow me for itab comparisons.I just want to know the ALV data has been changed or not.
Regards,
Shahana -
Check unchanged data in an editable alv grid
Hi,
I have a problem with my editable ALV. As long as I'm changing my data the event DATA_CHANGED is raised and my fields are checked correctly. But what about unchanged data like appended rows. In that case no changes have been made and the event is not triggered.
Even if i raise the event by using the method:
CALL METHOD gr_grid1->check_changed_data
IMPORTING
e_valid = lv_valid
CHANGING
c_refresh = lv_refresh.
there are no changed data so that my checks:
FORM data_changed USING lr_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA: ls_mod_cells TYPE lvc_s_modi.
DATA: ls_cells TYPE lvc_s_modi,
lv_value TYPE lvc_value ,
lv_matnr TYPE matnr,
lv_maktx TYPE maktx,
lv_error TYPE c.
CLEAR lv_error.
LOOP AT lr_data_changed->mt_good_cells INTO ls_mod_cells.
CASE ls_mod_cells-fieldname.
WHEN 'MATNR'.
CALL METHOD lr_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'MATNR'
IMPORTING
e_value = lv_value.
* CHECK MARA SEGMENT
SELECT SINGLE mara~matnr
makt~maktx INTO (lv_matnr,
lv_maktx)
FROM mara AS mara
INNER JOIN makt AS makt
ON mara~matnr = makt~matnr
WHERE mara~matnr = lv_value AND
makt~spras = sy-langu.
IF NOT sy-subrc IS INITIAL.
CALL METHOD lr_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'M3'
i_msgno = '305'
i_msgty = 'E'
i_msgv1 = lv_value
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
lv_error = 'X'.
ELSE.
CALL METHOD lr_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'MAKTX'
i_value = lv_maktx.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDFORM.
are not working.
Thank you for your help
Gregor
Edited by: Gregor Sure on Oct 13, 2009 1:58 PMTry to capture the event DATA_CHANGED_FINISHED. You can use the method REGISTER_EDIT_EVENT of the class CL_GUI_ALV_GRID to register the edit events.
Regards,
Naimesh Patel -
Row wise total in editable ALV
hello all,
I am workin on editable alv, the user need to enter the values in the editable fields and in the last column(non-editable) i need to populate the total row wise,as soon as user enters a value and goes to next editable cell or on entering a vale and press enter.how to accomplish this task...
with regards,
sandeep akella.
Edited by: sandeep akella on Aug 20, 2009 1:58 PMYou need to Implement the OnCellAction event.follow these steps;
1. Goto WDDOMODIFYVIEW and place the following code
IF first_time IS INITIAL.
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_usg_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_usg_alv( ).
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model(
CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
EXPORTING
value = abap_true.
ENDIF.
2. Implement the onCellAction event as follows;
Goto Methods tab, create a new method. Method Type- Event Handler , Event - ON_CELL_ACTION
3. Now in this method retrive the contents of the row and calculate the value as follows.
DATA: l_element TYPE REF TO if_wd_context_element.
DATA:ls_stru TYPE wd_this->element_cn_alv.
DATA: l_node TYPE REF TO if_wd_context_node.
l_node = wd_context->get_child_node( 'CN_ALV' ).
l_element = l_node->get_element( r_param->index ).
l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).
ls_stru-last_col = ls_stru-col1+ls_stru-col2....+ ls_stru-col5. " add all the cells data
l_element->set_static_attributes( exporting static_attributes = ls_stru ). -
Search help for date field in Editable ALV
Hello Friends,
I am using editable alv using 'reuse_* '.
I have used date as input field. While creating fieldcatlog also i have declared dat as a mkpf-budat.
But i am not getting serach help for date in output.
Is it possible with reuse or i have to go by object oriented ?Hi,
Just pass the Edit option of the fieldcatalog for those specific fields...
fcat-edit = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND' "<---- pass this
i_callback_top_of_page = 'TOP'
is_layout = it_layout
it_fieldcat = it_fcat
i_default = 'X'
i_save = 'A'
it_events = it_event
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form USER_COMMAND
* text
* -->R_UCOMM text
* -->RS_SELFIELD text
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&DATA_SAVE'. "<-------check this
PERFORM save_data.
ENDCASE.
ENDFORM. "USER_COMMAND -
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. -
Capture contents from an editable alv
I'm trying to capture fields from an editable alv. I have an update button in the application toolbar. So when i press this button, whatever changes I have done on the screen, the internal table should get updated. I'm using the function module REUSE_ALV_GRID_DISPLAY.
Can anybody help me out??Yes you can,
If you have access to the element in the context that is bound to the row in the ALV then you can connect the message. Marking a * is not possible by default with the WD message manager and you willl need to do it manually. Use the element method of the message manager API for this purpose. -
My changes edited on editable ALV report are not transferring back to itab?
Hello
I was developed a heirarchila editable ALV by using FM 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'. The user will do some changes in the ITEMs (Z_VBAP_TABLE) on this heirarchila ALV report and presses the SAVE button.
In my program am handling this SAVE command and even my break point is also triggering at SAVE, but my ITAB is not having the CHANGED/new data!! still it has the old data in it! How to capture the user changes done on the report? those changes are not tranferring back to my itab/prog! because, ineed to update Z_VBAP_TABLE with those changes
Thank youHi Raju,
it is possible . But i know about your code.
WHEN 'SAVE'(003).
Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = viewname
EXCEPTIONS
foreign_lock = 1
system_failure = 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.
IF NOT grid1 IS INITIAL .
CALL METHOD grid1->check_changed_data .
ENDIF .
SORT i_mod BY row.
DELETE ADJACENT DUPLICATES FROM i_mod COMPARING row.
lh_norec = LINES( i_mod ).
lh_total = lh_norec.
SHIFT lh_total LEFT DELETING LEADING space.
Standard Table Update
IF i_mod[] IS NOT INITIAL.
LOOP AT i_mod INTO lwa_mod.
READ TABLE <i_itab> INTO <wa_tab> INDEX lwa_mod-row.
IF sy-subrc = 0 .
IF lh_flag NE 'X'.
MODIFY (viewname) FROM <wa_tab>.
ELSE.
INSERT (viewname) FROM <wa_tab>.
IF sy-subrc NE 0.
MESSAGE 'DATA NOT SAVED' type 'I'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
CONCATENATE lh_total ' ' text-s01 INTO lh_succ SEPARATED BY space.
MESSAGE 'Data Saved' TYPE 'I'.
This i did a long back. Check your code . I created an alv that will display data from my table . In this the user can click in any line item and he can change any value and press save that will save the value .
Regards,
Madhu. -
Urgent : Problem with Editable ALV Grid for Quantity and Currency Fields
Hi All,
I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
When user changes these values these values are not changing properly .
For the quantity field the domain is MENG13 with 3 deciamal places and here if we enter 500 it takes it as 0.500 .
The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
Here also it takes last 2 digits after decimal places by default.
Please advice how to get proper values in this case from ALV editable fields.
Thanks and Regards
Harshad
Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AMfor all the currency field , it will display like that only.
u have to manipulate uin program before displaying.
if they are giving 500, in program multiply with 100 and move it to table.
when u are getting from table, divinde and display.
this is what I am doing.
Reward if helpfull. -
Hi all,
Frnds i am working in editable alv using function modules not object oriented abap.
i m trying to edit a Field(MATNR ) in my output list and finally update it with changed values in the DB table.
But i m getting syntax error like
"the work area i_final is not alligned properly
below i m providing my code.
<code>
*& Report ZEDITABLE_ALV1
REPORT ZEDITABLE_ALV1.
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
data: BEGIN OF i_final occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
erdat like vbap-erdat,
END OF i_final.
DATA : C_X(1) TYPE C VALUE 'X',
C_FC_MODIFY(6) TYPE C VALUE 'MODIFY'.
*DATA: i_final TYPE STANDARD TABLE OF T_FINAL with header line.
i_temp type standard table of T_FINAL with header line.
*wa_final like line of i_final.
*DATA:i_final LIKE vbap OCCURS 0.
*DATA:wa_final LIKE vbap.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-FIELDNAME = 'REC_SEL'.
fieldcatalog-NO_OUT = C_X.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'GUI_STAT'
*i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
*it_special_groups = gd_tabgroup
*it_events = it_events
i_save = 'X'
*is_variant = z_template
TABLES
t_outtab = i_final
EXCEPTIONS
program_error = 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.
ENDFORM. " DISPLAY_ALV_REPORT
**& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
*SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
*INNER JOIN vbap AS b ON avbeln = bvbeln
*INTO TABLE i_final WHERE a~vbeln = b~vbeln.
select VBELN ERDAT MATNR POSNR up to 10 rows from vbap into corresponding fields of table i_final.
ENDFORM. " DATA_RETRIEVAL
* FORM GUI_STAT *
* --> RT_EXTAB *
FORM gui_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MODIFY' EXCLUDING rt_extab.
ENDFORM.
* FORM USER_COMMAND *
* --> U_COMM *
* --> RS_SELFIELD *
FORM user_command USING u_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA:selfield TYPE slis_selfield.
*RS_SELFIELD-REFRESH = C_X.
CASE u_comm.
*IF U_COMM = C_FC_MODIFY.
WHEN 'UPDATE'.
LOOP AT i_final. " into wa_final."into wa_final.
*READ TABLE I_TEMP WITH KEY VBELN = I_FINAL-VBELN.
*IF SY-SUBRC = 0.
i_final-matnr = vbap-matnr.
*MODIFY I_final INDEX SY-TABIX.
*ENDIF.
ENDLOOP.
*ENDIF.
MODIFY VBAP FROM TABLE i_final.
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
*MESSAGE I000 WITH SY-DBCNT
*' Record(s) has been Updated'(020).
ENDIF.
*append i_final.
*it_temp = i_final.
*append it_temp.
**UPDATE sflight FROM TABLE sflight_tab.
*ENDLOOP.
*update vbap from table i_final.
*IF sy-subrc = 0.
*MESSAGE s000(0) WITH 'records updated successfully'.
*ENDIF.
ENDCASE.
ENDFORM.
</code>
Frnds plz help me in this regard.
Thanks,
satyaTry something like this...ur code was not clear..i have done something u can understand.
First check that u r not trying to update the primary key field.
first before updating.
Before updating select the record u r going to update from the main table.
select single * from VBAP where <pass the key values>.
if sy-subrc = 0.
move the rest of the values to the table header except the key values.
vbap-<field1> = value1.
vbap-<field2> = value2.
after moving the values.
update <table>.
if sy-subrc = 0.
commit work.
endif.
data:st_vbap type vbap.
WHEN 'UPDATE'.
LOOP AT i_final. " into wa_final."into wa_final.
select single * from vbap where vbeln = I_FINAL-VBELN.
move-corresponding i_final to vbap.
update vbap.
if sy-subrc = 0.
commit work.
wk_cnt = wk_cnt + 1.
endif.
at last.
*MESSAGE I000 WITH SY-DBCNT
*' Record(s) has been Updated'(020).
endat.
endloop -
Unable to display Refreshed editable alv
hi
I have developed editable alv which contains 7 colums. the final column is the addition of 4th n 5th cplumn. when i refresh after changing the values, the final column is not changing. but while debugging the changed values are reflected in internal table but its reflected in alv.
help me outin the user_comand form you have to put rs_selfield-refresh = 'X'.
like this:
*& Form user_comand
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
rs_selfield-refresh = 'X'. -
Retrieve front end values of editable alv in same format
I have a problem to retrieve the front end values in editable alv filled by user.
I am able to get it from MODIFIED CELL method but it gives the values after
alv automatically conversion. For example if user filled 1 in cell of type numc
then i want to keep it as 1 not as 00..001 format of numc.
Same for when user fill alphbets in small letter the alv convert it in CAPS.
I want to retain it as it as filled by user.
Example: User filled aAbBcFG in a cell
then it should update in database in same format not like AABBCFG as alv did
<offer removed by moderator>
Edited by: Rocky_S on Jan 20, 2011 7:50 AM
Edited by: Rocky_S on Jan 20, 2011 7:51 AM
Edited by: Thomas Zloch on Jan 20, 2011 11:24 PMHi Srinivas I have used CONVERSION_EXIT_ALPHA_OUTPUT for number input. My problem is that
when user fill 0 in the alv cell then alv automatically convert it into 00000000. My field is of type numc
that why it converts in 00000000. I want to retrieve it as the user fill in alv cell. Through this function
module the import parameter parameter is of numc format not as filled by user. In my case if it is 0
then then i should retrieve it as it is.
My actual scenario is i have a numc type field in alv and i want to keep it as mandatory. For which i am
writing a logic. Because in my table there is a valid entry of 0. If user do not fill 0 then it takes automatically
0 as input because of initial value of numc field. I want to restict it. I can not convert this field as char.
Give me some logic to make numeric field mandatory. -
Problem While Saving the editable ALV GRID
Dear Experts,
I have a scenario in which i am display the ALV(using class) with some data in the custom container of module pool screen in the non-editable mode.Also i have save and edit buttons.If i click the edit button i have written the code to edit the some columns in the ALV grid, it is working fine.After editing it,when i click the save button then ALV has to refreshed with edited data and then it should go to non editable mode but it is not working.I have written the code for changing the editable ALv to non editable mode as follows :
call method c_alvgd->set_ready_for_input
exporting
i_ready_for_input = 0.
*****Row and column of the alv are refreshed after changing values
stable-row = 'X'.
stable-col = 'X'.
*REfreshed ALV display with the changed values
*This ALV is non editable and contains new values
call method c_alvgd->refresh_table_display
exporting
is_stable = stable
exceptions
finished = 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.
Could you Suggest me solution for this issue ?
Thanks & Regards,
R.Dhineshraj.Dhinesh,
I suppose that you are able to get your changes values on screen but not able to get your field in DISPLAY mode from editable mode, let me know if this is not your problem.
When you press SAVE, after the PAI, again PBO will run and hence the editable code for that field will overwrite which will keep it editable.
So, do something like this.
data: gv_edit value 'X'..... "global variable in TOP include
PBO....
loop at ...
if gv_edit = 'X'.
CALL METHOD lo_alv->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
else.
CALL METHOD lo_alv->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
endif.
endloop.
PAI.
when 'SAVE'.
gv_edit = space.
When 'EDIT'.
gv_edit = 'X'.
Regards,
Diwakar
Maybe you are looking for
-
Is there a backup option were you don't have to reformat a external hard drive?
I want to backup my data on my mac as I have not done so yet. I plugged our familes external usb hardrive (500gb) in to my computer and time machine said it would delete every file on that to re format it. I have serached the internet for programmes
-
Would appreciate suggestions.
-
I'm awaiting deli'very of a 6gb zen micro (dark blue), and would like some educated opinions before I start using it. I'm probably a geezer compared to most of you and not quite as high tech, but not a dummy, and I've got a Muvo N200 that I've been u
-
Photoshop Elements Organizer alphabetic sort
I have been wanting to sort selections in Photoshop Elements Organizer alphabetically by file name. Does the recently released Photoshop Elements 12 Organizer have that feature or does it still only sort by date?
-
MacBook Pro w 16GB & SSD slow; kernal_task using 4GB
I've got processor and memory issues with my MacBook Pro. I have 16GB of memory and an SSD drive. Kernal_Task routinely uses 3 or 4GB of memory. And lots of times, various apps are pegging the processor, and my fans go crazy. Kernal_Task and WindowSe