Editable ALV's in WD4A (Like in Straight ABAP OO)
Last year I had to master ABAP OO editable ALV's to put one in a MIGO dialog process exit. The editable ALV class methods are pretty cool and do a lot of the work for you.
So while in NET310 this week, I was looking at all the SAP-provided WD4A ALV components (demo, test, etc) and I didn't see one dealing with editable ALV's.
Am I correct in assuming that this "editable ALV" functionality is not in WD4A yet?
Or is it buried in SALV_WD methods that no one has bothered to put in a demo or tutorial?
Hello David,
I have these, too.
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110],
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1] and
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/63a47dd9-0b01-0010-3d8e-de27242bf011].
Regards,
Similar Messages
-
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 -
ABAP WebDynpro: Handling the ON_ENTER Event in editable ALVs
Sub: ABAP WebDynpro : Handling the ON_ENTER Event in editable ALVs
Hi,
I would like to know if there exists an event to handle TABout (i.e, when user navigates out of the cell with a TAB key-press) for a cell of an editable ALV.
Alternatively, any help on how to handle ON_ENTER event and how it is triggered when data is entered by user into a cell of an editable ALV, would be really appreciated.
Thanks,
AdithyaHi
I had one similar problem where user enter something into the editable cell and press enter. to handle this scenario i used WDDOBEFOREACTION method of my view to call alv interface method check_data.
if there is any change in the any table cell, it will fire an event on_data_check..which has paramater column name, row index and new and old value of the cell.
you can handle this event and write your business logic in event handler method.
hope it will help
Regards
Saurabh Garg -
Add(Copy)/Change/Delete in editable ALV list
I want to add a column to my ALV list where the user can enter an 'A' to Copy, 'C' to Change or 'D' to Delete. If the user enters an 'A', the code needs to insert a new line into the ALV list. After the user makes the changes on the screen and selects Save, I need the program to perform different functions depending on whether the user entered an 'A', 'C' or 'D' in the column. I have never used an editable ALV list and would like to have some sample code to get started. Does anyone have any code similar to what I am trying to do?
Thanks.
SandyHi,
check this code... if you trying with ALV FM, and editable grid then check this code.
REPORT ZTESTDFALV1 .
*Data Declaration
DATA: BEGIN OF T_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
* FLAG TYPE C,
* HANDLE_STYLE TYPE LVC_T_STYL,
END OF T_EKKO.
DATA: GD_REPID LIKE SY-REPID, "Exists
REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
DATA: BEGIN OF IT_EKKO OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS. "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Start-of-selection.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
IT_BACKUP[] = IT_EKKO[].
PERFORM DISPLAY_ALV_REPORT.
*& Form build_fieldcatalog
* text
FORM BUILD_FIELDCATALOG.
REFRESH FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELN'.
FIELDCATALOG-SELTEXT_M = 'Purchase Order'.
FIELDCATALOG-INPUT = 'X'.
FIELDCATALOG-EDIT = 'X'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SELTEXT_M = 'PO Item'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM BUILD_LAYOUT.
"Permet d'ajuster les colonnes au text
* gd_layout-colwidth_optimize = 'X'.
* GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-box_fieldname = 'SELECT'.
* gd_layout-box_tabname = 'IT_EKKO'.
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_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* i_grid_title = 'My Title'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE:/ SY-SUBRC.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP
UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
ENDFORM. " DATA_RETRIEVAL
* FORM SET_PF_STATUS *
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.
ENDFORM. "set_pf_status
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
<b>
*then insert the following code in your USER_COMMAND routine...
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.</b>*modify
CASE R_UCOMM.
WHEN '&IC1'.
CHECK RS_SELFIELD-TABINDEX > 0.
IF RS_SELFIELD-VALUE EQ '6000000001'.
CALL TRANSACTION 'ZDF2'.
ENDIF.
WHEN 'REFRESH'.
READ TABLE IT_EKKO INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
IF IT_EKKO <> IT_BACKUP.
* then do your check
ENDIF.
ENDIF.
ENDIF.
PERFORM DATA_RETRIEVAL.
RS_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM. "user_command
regards
vijay -
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 -
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. -
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. -
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 -
Editable alv: add custom validation and display "errors" in protocol list
Hi,
What I want to do:
PAI validation of editable alv with displaying error's in the protocol list by adding custom entries to the existing protocol object.
What is my problem:
After registering "data_changed event", the protocol list don't appear.
My understanding is, that the object "er_data_changed" is passed by the event "data_changed"
an so I thought I can add some more entries to the protocol list.
After "de-registering" the "data_changed" event, the protocol appears with the standard errros messages (e.g. "input to numeric" by enter charachters)
One more hint:
By creating a new object "er_data_changed" in the handler method the protocol list works, but I would like to append entries to the object that was passed with the event.
Probably I've misunderstand something, please help !
My coding:
PAI:
trigger event "data_changed" -> calls handler method
CALL METHOD r_myalv->check_changed_data
IMPORTING
e_valid = is_valid.
stop processing
IF is_valid NE 'X'.
MESSAGE 'invalid input' TYPE 'E' .
ENDIF.
handler method:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING e_ucomm
er_data_changed.
METHOD handle_data_changed.
data: ls_mod_cell type lvc_s_modi.
CALL METHOD er_data_changed->add_protocol_entry
EXPORTING
i_msgid = 'SU'
i_msgty = 'E'
i_msgno = '000'
i_msgv1 = 'This is a test !'
i_fieldname = ls_mod_cell-fieldname.
er_data_changed->refresh_protocol( ).
er_data_changed->DISPLAY_PROTOCOL( ).
ENDMETHOD. "handle_data_changedDear Olaf,
If understood correctly, you want to Edit an ALV and do some data validations when some data is changed in an ALV. To do this follow the following steps:
1. Before displaying ALV, Register the edit event.
* Set cell modified to trigger data_changed
CALL METHOD go_alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
2. Register the event DATA_CHANGED of class CL_GUI_ALV_GRID & handle the event.
SET HANDLER lo_event_receiver->handle_data_changed FOR go_alv_grid.
The event DATA_CHANGED of class CL_GUI_ALV_GRID has a parameter ER_DATA_CHANGED which is of type CL_ALV_CHANGED_DATA_PROTOCOL.
This er_data_changed has internal table MT_MOD_CELLS(contains index of records changed ) & MP_MOD_ROWS(contains the changed row), using these update your internal table accordingly.
DATA : wa_mod_cell TYPE lvc_s_modi.
FIELD-SYMBOLS: <fs> TYPE table.
LOOP AT er_data_changed->mt_mod_cells INTO wa_mod_cell.
ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
READ TABLE <fs> INTO wa_output INDEX wa_mod_cell-tabix.
MODIFY lt_output FROM wa_output INDEX wa_mod_cell-row_id.
ENDLOOP.
3. Here it self you can do the required data validations(No need of any PAI modules) as below.
IF wa_orders-zfstfirmtyp = c_9.
MESSAGE s288(zcsp).
DELETE er_data_changed->mt_mod_cells.
EXIT.
ENDIF.
Regards
Kesava -
Editable ALV - how to throw an error message for a specific line & field
Hi all,
I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
How can I throw this error message corresponding to a specific line/field in the ALV?
I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
elem_alv = node_alv->get_element( index = <change>-element_index )
to get the element for the message.
CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'my message'
ELEMENT = elem_alv
* ATTRIBUTES =
* PARAMS =
* MSG_USER_DATA =
* IS_PERMANENT = ABAP_FALSE
* SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CTXT_ELEMENT
* MSG_INDEX =
* CANCEL_NAVIGATION =
* IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
If I try to use this, I can't get the values of my ALV table to check it.
Thanks,
AndreasHi Andreas,
I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
"if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
ASSIGN ls_modified_cells-r_value->* TO <temp>.
Then you can use this <temp> for comparison in your IF statement like:
IF <temp> = 3.
Find the entire coding as below:
METHOD check_data.
DATA: lr_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
ls_modified_cells TYPE salv_wd_s_table_mod_cell.
FIELD-SYMBOLS <temp> TYPE data.
" get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
lr_node = wd_context->get_child_node( name = 'NODE' ).
LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
lr_element = lr_node->get_element( index = ls_modified_cells-index ).
IF ls_modified_cells-attribute = 'TEMP_NEW'.
" Get the value extracted into the field symbol from the reference variable
ASSIGN ls_modified_cells-r_value->* TO <temp>.
" Use the value present in this field-symbol for your comparison
IF <temp> = 4.
" report message
CALL METHOD lo_message_manager->report_attribute_error_message
EXPORTING
message_text = 'Sample message text'
element = lr_element
attribute_name = ls_modified_cells-attribute.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Hope this helps resolve your problem.
Regards,
Uday -
Can anyone tell me a business scenario when we might need to develop an editable ALV. Am new to ABAP & trying to work out on some possible scenarios. So could anyone please help me out by suggesting/sending me a sample specification for the same? ( [email protected] ) Would be very helpful. And when we try to edit a field in the list how does the system edit the system tables like? I mean does it again make use of any FM's or procedures to ensure system consistency? And if anyone has some good material on advanced concepts of ALV's please send it to my email address. All helpful answers would be awarded SDN points. Thanks...
Hi
ABAP List Viewer
We raely use the editable ALV's in the real projects.
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
see the example:
report yh645_secndry_alv.
type-pools: slis.
data: fieldcat type slis_t_fieldcat_alv,
fieldcat_ln like line of fieldcat,
fs_layout type slis_layout_alv,
t_layoout like standard table
of fs_layout.
data: begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
cityfrom type spfli-cityfrom,
airpfrom type spfli-airpfrom,
countryto type spfli-countryto,
cityto type spfli-cityto,
airpto type spfli-airpto,
fltime type spfli-fltime,
deptime type spfli-deptime,
arrtime type spfli-arrtime,
distance type spfli-distance,
distid type spfli-distid,
fltype type spfli-fltype,
period type spfli-period,
checkbox,
color(3),
end of fs_spfli.
data:
begin of fs_table,
carrid type spfli-carrid,
connid type spfli-connid,
end of fs_table.
data: begin of fs_sflight,
check,
color(3).
include type sflight.
data:end of fs_sflight.
data:
begin of fs_table1,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
end of fs_table1.
data:
t_spfli like standard table
of fs_spfli.
data:
t_table like standard table
of fs_table.
data:
t_table1 like standard table
of fs_table1.
data:
t_sflight like standard table
of fs_sflight.
data:
t_sbook like standard table
of sbook.
data t_layout type slis_layout_alv.
select *
into corresponding fields of table t_spfli
from spfli.
perform start_list_viewer.
perform get_spfli_details.
*& Form SUB1
text
-->RT_EXTAB text
form sub1 using rt_extab type slis_t_extab.
data: flight type slis_extab.
flight-fcode = 'SFLIGHT'.
append flight to rt_extab.
set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.
endform. "SUB1
*& Form START_LIST_VIEWER
text
--> p1 text
<-- p2 text
form start_list_viewer .
data: pgm like sy-repid.
pgm = sy-repid.
fs_layout-box_fieldname = 'CHECKBOX'.
fs_layout-info_fieldname = 'COLOR'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB1'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SPFLI'
is_layout = fs_layout
tables
t_outtab = t_spfli
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. " START_LIST_VIEWER
*******Process Call Back Events (Begin)**************************
form user_command using ucomm like sy-ucomm
selfield type slis_selfield.
case ucomm.
when 'SFLIGHT'.
selfield-refresh = 'X'.
perform get_spfli_details.
select *
from sflight
into corresponding fields of table t_sflight
for all entries in t_table
where carrid eq t_table-carrid
and connid eq t_table-connid.
perform display_sflight.
when 'SBOOK'.
selfield-refresh = 'X'.
perform get_sflight_details.
select *
from sbook
into corresponding fields of table t_sbook
for all entries in t_table1
where carrid eq t_table1-carrid
and connid eq t_table1-connid
and fldate eq t_table1-fldate.
perform display_sbook.
endcase.
endform. "USER_COMMAND
*& Form SUB2
text
-->RT_EXTAB text
form sub2 using rt_extab type slis_t_extab.
data: flight type slis_extab.
flight-fcode = 'SBOOK'.
append flight to rt_extab.
set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.
endform. "SUB2
*& Form DISPLAY_SFLIGHT
text
--> p1 text
<-- p2 text
form display_sflight .
data: pgm like sy-repid.
pgm = sy-repid.
clear t_layout.
fs_layout-box_fieldname = 'CHECK'.
fs_layout-info_fieldname = 'COLOR'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB2'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
tables
t_outtab = t_sflight
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_SFLIGHT
*& Form GET_SPFLI_DETAILS
text
--> p1 text
<-- p2 text
form get_spfli_details .
loop at t_spfli into fs_spfli.
if fs_spfli-checkbox = 'X'.
fs_spfli-color = 'C51'.
fs_spfli-checkbox = '1'.
fs_table-carrid = fs_spfli-carrid.
fs_table-connid = fs_spfli-connid.
append fs_table to t_table.
modify t_spfli from fs_spfli.
endif.
endloop.
endform. " GET_SFLIGHT_DETAILS
*& Form GET_SFLIGHT_DETAILS
text
--> p1 text
<-- p2 text
form get_sflight_details .
loop at t_sflight into fs_sflight.
if fs_sflight-check = 'X'.
fs_sflight-color = 'C71'.
fs_sflight-check = '1'.
fs_table1-carrid = fs_sflight-carrid.
fs_table1-connid = fs_sflight-connid.
fs_table1-fldate = fs_sflight-fldate.
append fs_table1 to t_table1.
modify t_sflight from fs_sflight.
endif.
endloop.
endform. " GET_SFLIGHT_DETAILS
*& Form DISPLAY_SBOOK
text
--> p1 text
<-- p2 text
form display_sbook .
data: pgm like sy-repid.
pgm = sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_structure_name = 'SBOOK'
tables
t_outtab = t_sbook
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_SBOOK
Reward points if useful
Regards
Anji -
Save changed data in editable ALV
Hi experts,
I have a problem with an editable ALV. I get data out of a table and show it with my web dynpro application in an alv. Now I made the alv editablke, so that I can change the content of each cell in the alv in the web browser. But how will this changed data be saved? I want that it will be changed after ENTER or clicking a save button. I have a button, but all I tried yet brought no success.
Which code has to be in which method? Have I to do something eith the context. How can I reach that the changed content is also changed in the table, so that after reload the web dynpro application, the changed content is shown?
It would be nice if you had an answer with code examples and the exact place where to put it in, because I am very new to ABAP and WD4A.
Thanks a lot!
Best Regards
IngmarIf you look on the following lokn, there is the tutorial "Editing ALV in Web Dynpr for ABAP".
There is described how to save the data. But in the implementation of On_data_check on page 8 and 9 the code detail for saving the data to database is missing, because the flight model shall not be changed.
Would the missing code be the solution? What is the code?
Thanks!!!
Best Regards Ingmar
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1
Maybe you are looking for
-
I was making new Apple ID with my other Email on iTunes, but I canceled the process on payment page. After a while I went to make a new ID with same Email but it says the Email is already in use! what should i do?
-
Hi, I need to dynamicaly instantiate classes at runtime, that is multiple instances, with different reference variables. I can easily intantiate a number of classes with different object variables, but i need to do it dynamically at runtime. anyone?
-
Nokia express 5800 bluetooth problem
hi all my problem with my nokia 5800 express music is when i try to open the bluetooth it gives me a error message which says unable to preform blutooth operation and before it was already working , and i already upgraded the new version as try that
-
I can't access my iPhoto..what should i do?
i access my iphoto..what should i do?
-
I have a T500 that is a little over a year old; I have upgraded to an SSD with Win7. I keep it in the docking station on my desk, and once in a while the laptop suddenly shuts off with no warning. I can't restart it until I undock it, pull the batter