Edit ALV - Capture modified data
Hi,
I am using cl_gui_alv_grid to show an ALV. I am able to edit the ALV. I have used the following code to register the edit event too.
call method g_p_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>MC_EVT_MODIFIED.
create object g_event_receiver.
set handler g_event_receiver->handle_data_changed for g_p_grid.
The only issue that I face is, the user needs to hit the enter key inorder to store the modified values back in the internal table. Is there any way by which, the modified values can go back into the Internal table with as soon as the user changes the values.
Any suggestions will be appreciated.
Please note, I am able to edit an ALV and update the modified values into the tables. I have gone thru the exisitng examples.
Murali.
I was actually editing a cell using lvc_s_styl properties (cl_gui_alv_grid=>mc_style_disabled/enabled). I added the edit='X' in the fieldcatalog and it started to react to my tabout event the moment I change the cell value.
Cheers.
Similar Messages
-
Editable ALV -- OO -- Changed data capture
Hi,
I'm using an editable ALV to display the output. Output has a field for the user to enter comments. When the user enters the comments and presses "ENTER" key or clicks somewhere else on the ALV itself, the event DATA_CHANGED or DATA_CHANGED_FINISHED gets triggered and I'm able to capture the changed data and update the DB table.(I have a "SAVE" button on the menu bar which when pressed will update the ALV values into DB table.)
However, I need to capture this changed data even if the user does not press the "ENTER" key or clicks somewhere else on the ALV, but just presses the "SAVE" button. Please let me know if there is any way to do this.
Thanks,
Raj.Hi,
in your program check the user-command if 'SAVE' then write the following code in it
"Call the method check_changed_data to update the internal table with changed data.
DATA: lv_valid TYPE xfeld,
lv_refresh TYPE xfeld.
CALL METHOD gv_alv_grid->check_changed_data
IMPORTING
e_valid = lv_valid
CHANGING
c_refresh = lv_refresh.
" to refresh alv
CALL METHOD gv_alv_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
by this way it the internal table will get the changed data and then you can update it in the DB and also after updating show the ALV since it is refreshed it will now show the changed data.
Hope it helps you,
Regards,
Abhijit G. Borkar -
Editable ALV, capturing multiple record changes
Hello
I am writing the editable ALV prog. (because of some reaosn am using FM - REUSE*) and i need to capture the user changes on the list, but, when i searched, i found the below code, where in i can get only one change/record (because am getting importing formal parameter is a structure), but, i need to get all records user changes, multiple.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Pls. let me know how to capture all records/changes? I saw BCALV, but, all they are on OOPS.
Thank youHi Raju,
no chance without oo event data_changed.
You can get the grid object from the function module, I think FM LVC_GET_GLOBALS or something like that. Then implement method
METHODS: handle_data_chg FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
In SET_STaTUS event of the function module, you can extract the grid object and registr your own handler.
But, honestly, I'm not convinced this will be easier for you than changing to OO grid.
Regards,
Clemens -
How to autofill the Modified Date And Modified User?
hi All,
Below is the screenshot of my form , if we look at the last 4 columns we have Created Date,Created User Id which is popped up automatically if a new entry is being created. Now if we look at the last 2 ModifiedDate and ModifiedUserId those fileds will be
empty wile creating a new entry which is good for me. But lets say if i go back to any existing record and want to modify it then the modified date and modified userid must be popped up with that persons name and current date. I think i can use the logic i
have to get date and userid but i want some help with code to how to make the modified fields fill up.
Can someone please help me with this?
Thanks a lot for all your time and support.well I use it all the time, and have no problem in that initially both the 'started' and the 'modified' date fields have the same value..... because when one is editing a record whether initially putting in data or adding/changing later - they are both considered
to put the form in a dirty state.
then in future edits only the modified date field changes. the code in the OnDirty event is:
me.ModifiedDateFieldName=Now()
any other approach will be more difficult to achieve as essentially one must trigger it not universally at the OnDirty event but something more specific such as at every control -
Editable ALV, how to capture changed data
Hi All,
I have created an editable ALV. User can make some changes in the displayed record and press "Submit" button (custom button on application toolbar), the program should validate the data and write the file on application server if validations are successful otherwise controls stay on the same screen.
I am handling this validation and writing file part in PAI of the screen.
Problem: The program is capturing the data when user changes it for the first, but program is failing to capture the subsequent changes (user makes after the validation fails). Program processes always the first time changed data only. Please help me in getting this problem resolved.
Step1 : Program shows output.
Step2: User changes Company Code.
Step3: User clicks on Submit Button.
Step3.1: Program reads the new data and performs validation.
Step3.2: New Company code is not valid, error displayed.
Step4: User changes the company code again, presses submit button.
Goto step 3.1 -> Here program does not read the new data, rather first time changes company code is again read and validated, and program shows the same error again, which is not a desired resultHi Ashish,
you need a method HANDLE_DATA_CHANGED as handler for grid event DATA_CHANGED.
Use
LOOP AT er_data_changed->mt_mod_cells ASSIGNING <mod>.
to check all changed data. In this event, add the error messages to ER_DATA_CHANGED object.
set all required handlers, i.e.
SET HANDLER:
handle_data_changed FOR ro_grid,
handle_data_changed_finished FOR ro_grid,
handle_toolbar_set FOR ro_grid,
handle_user_command FOR ro_grid,
handle_hotspot_click FOR ro_grid,
handle_f4 FOR ro_grid,
handle_f1 FOR ro_grid.
ro_grid->set_toolbar_interactive( ).
Register ENTER and MODIFIED events.
ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_enter ).
ro_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ).
Regards,
Clemens -
ALV Grid - capturing the data of checked records
Hi All,
I have a report with ALV Grid display and it displays the contents of a custom table. Each record has a CHBOX, and I want to capture the data of all checked records in to an internal table when 'create Order' button is pressed. Please help me.
Thanks,
Neelu.Hi neelu,
Find attached complete code for the check box in ALV
REPORT ZTESTPRG .
TABLES AND DATA DECLARATION.
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
INTERNAL TABLE DECLARATION.
INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
chkbox(1) type c,
matnr like mara-matnr,
meins like mara-meins,
maktx like makt-maktx,
spras like makt-spras,
werks like marc-werks,
minbe like marc-minbe,
end of itab1.
THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
AND THE LAYOUT FOR THE ALV.
HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
THIS IS DONE TO MAKE THE CODE SIMPLER.
OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
PROGRAMS.
IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
MORE TABLES AND CREATE A STRUCTURE
IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
fieldlayout type slis_layout_alv.
DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
TOP-OF-PAGE ETC.
data : eventstab type slis_t_event with header line.
DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
data : heading type slis_t_listheader with header line.
data : heading1 type slis_t_listheader with header line.
data : heading2 type slis_t_listheader with header line.
data : heading3 type slis_t_listheader with header line.
data : heading4 type slis_t_listheader with header line.
data : heading5 type slis_t_listheader with header line.
data : heading6 type slis_t_listheader with header line.
data : heading7 type slis_t_listheader with header line.
data : heading8 type slis_t_listheader with header line.
STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
data : colorstruct type slis_coltypes.
INITIALIZATION. *
initialization.
syrepid = sy-repid.
sypagno = sy-pagno.
clear fieldcatalog.
START-OF-SELECTION. *
start-of-selection.
SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
INTERNAL TABLE.
perform selectdata_and_sort.
SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
perform populate_layout using fieldlayout.
SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
perform merge_fieldcatalog.
SUBROUTINE TO POPULATE THE EVENTSTAB.
perform fill_eventstab tables eventstab.
SUBROUTINE TO POPULATE THE HEADING TABLES.
perform fill_headingtable tables heading using 'HEADING'.
perform fill_headingtable tables heading1 using 'HEADING1'.
perform fill_headingtable tables heading2 using 'HEADING2'.
perform fill_headingtable tables heading3 using 'HEADING3'.
perform fill_headingtable tables heading4 using 'HEADING4'.
perform fill_headingtable tables heading5 using 'HEADING5'.
perform fill_headingtable tables heading6 using 'HEADING6'.
perform fill_headingtable tables heading7 using 'HEADING7'.
perform fill_headingtable tables heading8 using 'HEADING8'.
SUBROUTINE TO DISPLAY THE LIST.
perform display_alv_list.
FORMS
IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
FORM FILL_FIELDS_OF_FIELDCATALOG *
--> FIELDCATALOG *
--> P_TABNAME *
--> P_FIELDNAME *
--> P_KEY *
--> P_KEY *
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
FORM POPULATE_LAYOUT *
--> FIELDLAYOUT *
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
fieldlayout-coltab_fieldname = 'X'.
fieldlayout-box_fieldname = 'CHKBOX'.
fieldlayout-edit_mode = 'X'.
endform. " POPULATE_LAYOUT
FORM SELECTDATA_AND_SORT *
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
FORM MERGE_FIELDCATALOG *
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
i_structure_name = 'COLORSTRUCT'
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
FOLLOWS:-
i_callback_program --> CALLING PROGRAM NAME
i_structure_name --> STRUCTURE NAME.
is_layout --> LAYOUT NAME.
it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
form display_alv_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = syrepid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_structure_name = 'ITAB1'
is_layout = fieldlayout
it_fieldcat = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
TOOL BAR
i_save = 'A'
IS_VARIANT = ' '
it_events = eventstab[]
IT_EVENT_EXIT =
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*& Form POPULATE_ITAB1
text
--> p1 text
<-- p2 text
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*& Form FILL_EVENTSTAB
text
-->P_EVENTSTAB text *
form fill_eventstab tables p_eventstab structure eventstab.
WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
move 'TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_coverpage.
if sy-subrc = 0 .
move 'TOP_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_coverpage .
if sy-subrc = 0 .
move 'END_OF_COVERPAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_top_of_page.
if sy-subrc = 0 .
move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_foreign_end_of_page.
if sy-subrc = 0 .
move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_list_modify.
if sy-subrc = 0 .
move 'LIST_MODIFY' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_top_of_list.
if sy-subrc = 0 .
move 'TOP_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_page.
if sy-subrc = 0 .
move 'END_OF_PAGE' to p_eventstab-form.
append p_eventstab.
endif.
read table p_eventstab with key name = slis_ev_end_of_list .
if sy-subrc = 0 .
move 'END_OF_LIST' to p_eventstab-form.
append p_eventstab.
endif.
endform. " FILL_EVENTSTAB
*& Form FILL_HEADINGTABLE
text
-->P_HEADING text *
form fill_headingtable tables p_heading structure heading
using tablename.
case tablename.
when 'HEADING'.
p_heading-typ = 'H'.
concatenate
' REPORT NAME:-' syrepid
' ABB Industry Pte Ltd' into p_heading-info.
append p_heading.
write sy-datum using edit mask '__/__/____' to sydatum.
concatenate
' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
into p_heading-info.
append p_heading.
when 'HEADING1'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-COVER-PAGE'.
append p_heading.
when 'HEADING2'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-COVER-PAGE'.
append p_heading.
when 'HEADING3'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
append p_heading.
when 'HEADING4'.
p_heading-typ = 'H'.
p_heading-info = 'FOREIGN-END-OF-PAGE'.
append p_heading.
WHEN 'HEADING5'.
P_HEADING-TYP = 'H'.
P_HEADING-INFO = 'LIST-MODIFY'.
APPEND P_HEADING.
when 'HEADING6'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-PAGE'.
append p_heading.
when 'HEADING7'.
p_heading-typ = 'H'.
p_heading-info = 'END-OF-LIST'.
append p_heading.
when 'HEADING8'.
p_heading-typ = 'H'.
p_heading-info = 'TOP-OF-LIST'.
append p_heading.
endcase.
endform. " FILL_HEADINGTABLE
FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading[]
exceptions
others = 1.
endform.
*& Form FILL_COLORSTRUCT
text
-->P_COLORSTRUCT text *
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
FORM TOP_OF_COVERPAGE *
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
FORM END_OF_COVERPAGE *
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
FORM FOREIGN_TOP_OF_PAGE *
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
FORM FOREIGN_END_OF_PAGE *
form foreign_end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading4[]
exceptions
others = 1.
endform.
FORM LIST_MODIFY *
*FORM LIST_MODIFY.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEADING5[]
EXCEPTIONS
OTHERS = 1.
*ENDFORM.
FORM END_OF_PAGE *
form end_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading6[]
exceptions
others = 1.
endform.
FORM END_OF_LIST *
form end_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading7[]
exceptions
others = 1.
endform.
FORM TOP_OF_LIST *
form top_of_list.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading8[]
exceptions
others = 1.
endform.
*--- End of Program
Thanks
Mahesh -
Editable ALV issue: When Delete/Modify a row, ztable doesnt reflect changes
Greeting Fellow Abapers,.
I have been running into an issue that I need some advice on. I am allowing users to edit a Ztable via ALV. When the quantity field is updated everything is fine. However, when the field "lic_plate" is edited the code appends another row into the Ztable instead of modifying it. Also, when the delete row functionality of the grid is used the row is not deleted from the Ztable.
Here is the ztable structure. The fields I allow to be edited are in BOLD...
ZPALLET-VBELN
ZPALLET-MATNR
ZPALLET-LINE_NUM
ZPALLET-LIC_PLATE
ZPALLET-LOT_NUMBER
ZPALLET-PAL_TYPE
ZPALLET-MAN_DATE
ZPALLET-QUANTITY
ZPALLET-PROC_DATE
Here is the source code that the APPEND is taking place...
FORM save_database .
Getting the selected rows index*
CALL METHOD o_grid->get_selected_rows
IMPORTING
et_index_rows = i_selected_rows.
Through the index capturing the values of selected rows*
LOOP AT i_selected_rows INTO w_selected_rows.
READ TABLE itab INTO wa INDEX w_selected_rows-index.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING wa TO w_modified.
APPEND w_modified TO i_modified.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
MODIFY zpallet FROM TABLE i_modified.
ENDIF.
ENDFORM.
Please help. I am in your debt.
...as always, points will be awarded.
Best,
DanHello Dan
When you are using an editable ALV for table maintenance you have to take care that the users
- cannot edit the key fields of existing DB records and
- every new record (row) does not match any existing record (i.e. has identical key field values)
Instead of relying on selected rows for the DB update I would recommend to store a "PBO image" of your data and compare this with the "PAI image" of the data as soon as the user pushes the SAVE button.
Example:
DATA:
gt_outtab_pbo TYPE < your table type>, " PBO image
gt_outtab TYPE < your table type>. " PAI image
" 1. Select data from DB table and store in both itabs:
SELECT * ... INTO TABLE gt_outtab.
gt_outtab_pbo = gt_outtab.
" 2. Display editable ALV list -> user modifies gt_outtab
" 3. SAVE function requested
" ... compare gt_outtab vs. gt_outtab_pbo
" .... INSERT, UPDATE, or DELETE DB records
" Finally set:
gt_outtab_pbo = gt_outtab.
" 2. User continues with editing
In order to compare PBO vs. PAI data you may have a look at my sample coding:
[Comparing Two Internal Tables - A Generic Approach|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/comparing%2btwo%2binternal%2btables%2b-%2ba%2bgeneric%2bapproach]
Regards,
Uwe -
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 -
Date field not updated when select on F4 value on editable ALV Grid
Can some one look into this to see what was wrong.
I have a report that display fields extracted from a ZTable and display on an ALV Editable Grid.
The data are displayed as read only mode for these fields:
Field A - type char20 and have a search help available.
Start Date - type dats
End Date - type dats.
Field B
Field C ...
When user select to add new record, Field A, Start Date and End Date must be editable, the rest are read only.
On field A because there is search help available, I have no problem select data on F4 pull down menu and the data is updated on the grid.
But on field start date and end date, there is F4 menu and when you pull down, it shows the calendar date. But when I select the date to change, it acts like nothing happens. I run the debug mode and found out that in function module 'F4IF_FIELD_VALUE_REQUEST', after you select the date field, I got the return code irc = 8 from line 305 of this FM.
Here is what I did.
I build field catalog similar like BCALV_EDIT04 (add table type lvc_t_styl to each extracted record to indicate which field will be editable.
In the PBO, I build field catalog and set style as enable for these fields:
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_struct
CHANGING
ct_fieldcat = p_t_fieldcat.
LOOP AT p_t_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
when 'Field_A'.
ls_fcat-ref_table = 'ZTABNAME'.
ls_fcat-ref_field = 'FIELD_A'.
ls_fcat-edit = 'X'.
MODIFY p_t_fieldcat FROM ls_fcat.
when 'START_DATE' or 'END_DATE'.
ls_fcat-style = CL_GUI_ALV_GRID=>MC_STYLE_enabled.
MODIFY p_t_fieldcat FROM ls_fcat.
endcase.
Just curious, I copied program BCALV_EDIT_08 to ZBCALV_EDIT08 and make field booking date as editable to test. When I select to change booking date from F4 menu pull down, the new date is populated to the screen field. So what was wrong between my program and BCALV_EDIT_08? Thanks for your help. I am stuck on this problem for 2 days and could not figure out what was wrong.not sure why you use that FM for date filed , you just need in the field catalog make sure that are use a date field of reference , anyway check program BCALV_EDIT_01
-
IPhoto 08 can now edit EXIF Capture Date
iPhoto 08 is now able to change the EXIF Capture Date on the original files thru the Photo->Adjust Date and Time menu option. It also changes the Created and Modified date to the same selected date on the original file.
Do you Twango?
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.Björn:
I tried it on an alias library and the "source" files on the external HD did have their Capture Date changed. How did you get the files from the original (alias based) library into the other?
Do you Twango?
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file. -
How to save the editable alv data to another program ?
hi friends,
please solve this issue..
i have one editable alv grid report. after edit my data in the grid..
i want to
save those data (edited data )or
download those data into another internal table or
pass those data as input to another report program..
how can i do this ?The form switch to edit mode could be :
form p_edit.
data : is_fieldcatalog type lvc_s_fcat ,
it_ucomm type table of syucomm with header line ,
v_ucomm type syucomm.
* Switch Edit <-> Display
loop at it_fieldcatalog into is_fieldcatalog.
check is_fieldcatalog-fieldname ne 'NUM' and
is_fieldcatalog-fieldname ne 'RCODE'.
if is_fieldcatalog-edit eq 'X'.
clear is_fieldcatalog-edit.
else.
move 'X' to is_fieldcatalog-edit.
endif.
modify it_fieldcatalog from is_fieldcatalog.
endloop.
* Change the status of the grid.
if is_fieldcatalog-edit eq space.
move '&REFRESH' to v_ucomm.
call method obj_grid->set_function_code
changing c_ucomm = v_ucomm.
call method obj_grid->set_ready_for_input
exporting i_ready_for_input = '0'.
else.
call method obj_grid->set_ready_for_input
exporting i_ready_for_input = '1'.
endif.
* Modify the fieldcatalog.
call method obj_grid->set_frontend_fieldcatalog
exporting it_fieldcatalog = it_fieldcatalog.
* Refresh the display of the grid.
call method obj_grid->refresh_table_display.
* Set the column lines number.
perform p_set_lines_num.
* Clear the flag control.
clear v_flag_control.
* Messages.
if is_fieldcatalog-edit eq space.
move 'Passage en mode affichage.' to v_buff.
perform p_add_message
using v_buff
'ICON_DISPLAY'
else.
move 'Passage en mode édition.' to v_buff.
perform p_add_message
using v_buff
'ICON_CHANGE'
endif.
* Inactiv function.
if is_fieldcatalog-edit eq space.
set pf-status '100'.
else.
move '' to it_ucomm. append it_ucomm.
set pf-status '100' excluding it_ucomm.
endif.
endform. " P_EDIT.
and for the table:
data : w_id(60).
move 'ZTOTO' to w_id.
export it_table[] to memory id w_id.
in the other program, it's the same with the IMPORT instead of export. -
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 -
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 -
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. -
Get data in editable ALV back to internal table without data_changed ev?
Hi,
I have an editable ALV using classes to whch I have users the option to edit directly on the screen or upload data from an excel. The event data_changed gets triggered when users edit the table on the screen.
However when EXCEL is uploaded, I refresh the table display. So, I need a way to get the data from the ALV into a internal table to check which rows were update using the excel and save them into the db table.
PrakashHi!
For more information, inspect programs suiting the mask "BCALVEDIT*" and the thread with header "How to make a row of ALV editable " (I know this is some more steps further from your demand but it may be useful) at URL " How to make a row of ALV editable " .
If you want to study more BC412 "EnjoySAP Controls" may help you.
*--Serdar
Maybe you are looking for
-
Can I add my icloud @me address to my macmail
I added my first iCloud "@me" e-mail address on my iPad. But, I would also like to receive/send e-mail from my @me account from my iMac and MacMail app. Can I do this? (Many thanks sane Apples)
-
Can no longer print a PDF on Macbook Air - latest OS version
I had a message recently stating that I the HDD on the Mac was getting close to full, so moved some programs (including Acrobat Professional 11.0.10) and since then, I can't print any files using Acrobat. MS Office files print fine, so don't think it
-
Apply and delete buttons need differentiation
How do we get the apply and delete buttons put in different locations on the info window for ical? I've accidentally deleted when I meant apply because the buttons are in the same location. Mabye delete should be at the top right.
-
Problem in installing Directory Proxy server
Hi all! Recently downloaded the trial version of sun one directory proxy server. After installing the sun one DS 5.2 . I tried to install sun one proxy server..when it asks for configuration server information i have given the admin id and password .
-
Nothing displays correctly in Firefox (Solved)
Hi, I've been having a problem with firefox after I installed it on a freshly installed Arch installation. It was working fine for about 2 hours. Then, after that it just stopped displaying things correctly. It is kind of hard to explain so please ta