Regarding validating data in editable ALV in OOPS
I'm using the data_changed event in my ALV grid to validate the user's
entry in the ALV grid. My code finds the errors when the user originaly
enters the wrong data, highlights the errors in the grid, and popups u the
list of error messages.
My problem occurs when the user only fixes some of the errors and leavs
some data errors still in the grid. The data_changed will check the lnes
the user has fixed. However if they neglect to fix one of the errors,the
code doesn't reread the entry since the data didn't change from the
original entry. The error still exist and I don't want to allow the uer
to continue until they have fixed all of the errors. Is there another
event or coding that I can use to ensure the user fixes all of the errrs.
I know I could loop through the ALV grid table outside of my methods, ut
that would require rewriting all the checking again which seems very
inefficient.
Thanks,
Phani.
Check this link if it is useful:
F4 Help in ALV Grid (using CL_GUI_ALV_GRID)
Regards
Neha
Similar Messages
-
How to Transfer Data from editable ALV grid control to internal table?
Hi,
Can anyone give me a simple example by which I can transfer data from editable alv grid control back to the internal table. The ALV has been created by OO approach.
I would appreciate if the solution is provided without handling any events.
Regards,
AuroHello Auro
You simply need to call method <b>go_grid->check_changed_data</b> at PAI of the dynpro displaying the ALV grid. If data have been changed on the editable ALV grid then this method will raise event DATA_CHANGED. If you do not want or need to handle this event (e.g. for validating the edited values) then you do not define any event handler method.
Regards
Uwe -
Editable ALV in OOPs : default value for newly created rows
<b>I have created editable ALV using OOPs. </b>
But my requirement is while creating new rows in ALV, one column value should be filled with some default value automatically(as soon as I press create row icon on toolbar)
Thanks.HI HaReSh
<b>refer to this code below.hope it might help u.</b>
*& Report ZTESTDEMO_INTERACTIVE_LIST_2
REPORT ZTESTDEMO_INTERACTIVE_LIST_2.
TABLES: MARA,MARC,MARD.
* internal table itab_mara 3 fields matnr, ernam,mtart
DATA: BEGIN OF ITAB_MARA OCCURS 0,
MATNR LIKE MARA-MATNR, " material number
ERNAM LIKE MARA-ERNAM, " name of person who create
MTART LIKE MARA-MTART, " Material Type
END OF ITAB_MARA.
* internal table itab_marc 3 fields matnr, werks,lvorm
DATA: BEGIN OF ITAB_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS, " Plant
LVORM LIKE MARC-LVORM, " Flag Material for Deletion at Plant Level
END OF ITAB_MARC.
* internal table itab_mard 2 fields
DATA: BEGIN OF ITAB_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT, " Storage Location
END OF ITAB_MARD.
SELECT-OPTIONS: S_MTART FOR MARA-MTART.
INITIALIZATION.
S_MTART-LOW = 'HALB'.
S_MTART-HIGH = 'HAWA'.
S_MTART-OPTION = 'BT'.
APPEND S_MTART.
START-OF-SELECTION.
SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
S_MTART.
PERFORM DISPLAY.
TOP-OF-PAGE.
WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.
FORM DISPLAY.
LOOP AT ITAB_MARA.
WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
HIDE: ITAB_MARA-MATNR.
ENDLOOP.
ENDFORM.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
ITAB_MARA-MATNR.
PERFORM DISPLAY1.
WHEN 2.
SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
ITAB_MARC-MATNR.
PERFORM DISPLAY2.
when 3.
sy-lsind = 0.
ENDCASE.
FORM DISPLAY1.
LOOP AT ITAB_MARC.
WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
HIDE: ITAB_MARC-MATNR.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
FORM DISPLAY2.
LOOP AT ITAB_MARD.
WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
regards
ravish
<b>plz reward for useful ans</b> -
Update out_tab data in editable ALV
Hi,
I am working on editable ALV using oops. I want to insert the data into database tables after user insert the data in ALV based on the application tool bar button action.
How to refresh the data in out_tab, If user click the application tool bar button then I need to save the ALV grid data in database table.
Please give me the valuable suggestions.
- Rayudusolved my self
-
Regarding editable ALV in OOPS
Hi,
I have an editable alv.
I have requirement like i need to validate the data which is edited on pressing "ENTER" or "SAVE"
for this iam using the event DATA_CHANGED
and define a local class lcl_event handler and also set handler for it.
But iam able to validate using this event only if the data is changed inspite of SAVE or ENTER its getting triggered.
But if the data is not changed its not triggering please suggest me an event which triggers on clicking SAVE in menu bar.
Thanks,
Phani.Hello
If the event is not triggered but you need to do the validation then just call the event handler method yourself:
" PAI: USER_COMMAND module
CASE gd_okcode.
WHEN 'SAVE'.
" Now call your event handler method directly
go_grid->handle_data_changed( )
EXPORTING
WHEN OTHERS.
ENDCASE.
Within your event handler method you can easily distinguish between whether the method is triggered by the control framework or by your direct call:
METHOD handle_data_changed.
" instance exists -> triggered by framework
IF ( er_data_changed IS BOUND ).
" direct call
ELSE.
ENDIF.
ENDMETHOD.
Regards
Uwe -
How to validate data in editable ALV report after making changes
Hi Folks,
My requirement is to display data in ALV format with quantity field is editable. Once we get the data in display mode only quantity field is enabled right. I am going to make changes to that quantity field and updating that modifed value to the database table. Before updating databse table i want to validate the data for perticluar field which I edidted(Quantity).
Can you guide me on this.
Currently I am using FM: GET_GLOBALS_FROM_SLVC_FULLSCR and calling the method CHECK_CHANGED_DATA.
I want to validate the quantity data.
If I entered negative value like -100 instead of 100. It should validate and show some popup screen or message.
Pls guide me on this or give some code to do that.
Thanks&Regards,
SurendraHey Surendra,
Check if this helps: Link:[Click here|Edit Field in Oops Alv;
There are many posts available for this requirement. Please look SDN/web for same.
Regards,
Santosh -
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 -
Hi all,
I am using an editable ALV in webdynpro using which I would like to save some data to a table. In the list of standard functions, I see only options like 'Insert row', 'Delete row' etc. There is no option to Save the edited data.
Even if I declare a user defined function, how do I specify the action it would trigger? Any help would be greatly appreciated. Thanks in advance.
Regards,
NithyaHi Nithya,
Once you edit an ALV, the data is automatically updated to the context node, you map in the DATA field of controller usage (of the component usage).
If you want to trigger event for change in ALV, see the below tutorial.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8">Using Events with ALV Tables
in Web Dynpro for ABAP</a>
If you want to trigger a event for user defined function,
Create a event handler method in the view. Specify event,
ON_FUNCTION of the interface controller of ALV for the event handler method.
The importing parameter r_param of the method contains unique ID of the
function for which the UI element is assigned.
For reference see the below tutorial. It will be useful.
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110">Generating Self-Defined Functions for ALV in Web Dynpro for ABAP</a>
Hope it Helps
Rakesh -
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 -
Regarding validating data using excel add-in
hi
i am new to essbase, please any help me regarding the steps to be followed for
validating data that is loaded in to a cube using excel add-inThere are no standard steps.
If you wish to just cross check the data which has been loaded in cube ,then Identify the level 0 combination of members in data source from where cube is picking up data (Oracle,flat file ..etc) and retrieve the same combination through excel addin and compare the data.
hope this will help ! -
Validation of data in editable ALV report output for particular field
Hi Experts,
I have one input enabled field in ALV output. How to validate the data once user enters in that field and press enter? Is it possible to capture the value, hit the enter after user enters the data?
Thanks,
Surya PrakashHalo Prakash,
1 First you should registeer the ENTER Event.
call method g_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
2 Declare event handler method for Event data_changed of cl_gui_alv_grid.
handle_data_changed
for event data_changed of cl_gui_alv_grid
importing er_data_changed.
3 Inside the Event handler method , you get the event parameter er_data_changed type ref to CL_ALV_CHANGED_DATA_PROTOCOL.
loop at er_data_changed->mt_good_cells into ls_good.
case ls_good-fieldname.
when 'FIELD1'.
call method check_FIELD1.
when 'FIELD2 '.
call method check_FIELD2
endcase.
endloop.
4 Inside the Method check_FIELD1 and check_FIELD2 you can do the validation check .
call method er_data_changed->get_cell_value( Passing the row no and field name).
if the check fails you can use add_protocol_entry to write the error.
5 Finally call
er_data_changed->display_protocol.
Regards
Arshad -
Enable User Defined toolbar button on click - editable alv grid using oops
Hi all,
I have created editable alv using oops concept.
created 2 user defined toolbar button save and print using method toolbar
ls_toolbar-text = 'Print'. "#EC NOTEXT
ls_toolbar-quickinfo = space.
ls_toolbar-checked = space.
APPEND ls_toolbar TO e_object->mt_toolbar.
requirement is
initially print button should be disabled, and save enabled
when i click save button, print button should be enabled.
I want coding in editable alv oops concept
kindly help
regards
senthil kumarHalo Senthil,
You should call set_toolbar_interactive method of cl_gui_alv_grid in the on_user_command( ie the event handler for event user command) .
method on_user_command.
case e_ucomm.
when 'SAVE'. or whatever your function code is .
my_save_flag = 'X'.
call method grid->set_toolbar_interactive.
endmethod.
This triggers the toolbar event of the
cl_gui_alv_grid. Inside the eventhandler method ( ie the on_toolbar method ) you should set the toolbar.
if my_save_flag = 'X'.
read table e_object->mt_toolbar
clear l_toolbar-disabled.
modify e_object->mt_toolbar.
endif.
e_ucomm will not have the function code if the save button is not in the toolbar area.
then you can set the my_save_flag in the data_changed event handler of the Cl_gui_alv_grid.
Regards
Arshad -
Can we edit alv output list.
hi happy new year to everybody ......
can anybody tell me that can we create aditable alv list ...
how can we.....Hi,
Yes you can create an Editable ALV.
I am giving you an example of Editable ALV in OOPs.
Example:
Take a Custom container in Screen 100 and name it "LIST_AREA".
REPORT ZSB_ALV_EDITABLE_SAMPLE.
TABLES: SFLIGHT.
DATA: gc_container TYPE scrfname VALUE 'LIST_AREA',
gc_custom_container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
gc_grid TYPE REF TO CL_GUI_ALV_GRID,
gs_layout TYPE LVC_S_LAYO,
gt_fieldcat TYPE LVC_T_FCAT.
DATA: ok_code TYPE SY-UCOMM.
DATA: gt_outtab TYPE TABLE OF SFLIGHT.
*DYNPRO
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
CREATE OBJECT gc_custom_container
EXPORTING
container_name = gc_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT gc_grid
EXPORTING
i_parent = gc_custom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5 .
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
PERFORM prepare_layout CHANGING gs_layout .
PERFORM get_alv_display.
ENDMODULE.
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
OK_CODE = SY-UCOMM.
IF OK_CODE = 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR OK_CODE.
ENDIF.
ENDMODULE.
FORM prepare_field_catalog CHANGING gt_fieldcat TYPE LVC_T_FCAT.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fieldcat[].
ENDFORM.
FORM prepare_layout changing p_gs_layout TYPE lvc_s_layo.
p_gs_layout-zebra = 'X'.
p_gs_layout-edit = 'X'.
ENDFORM. " prepare_layout
FORM get_alv_display .
SELECT * FROM sflight INTO TABLE gt_outtab UP TO 10 ROWS.
CALL METHOD gc_grid->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = gs_layout
CHANGING
it_outtab = gt_outtab
IT_FIELDCATALOG = gt_fieldcat
ENDFORM. " get_alv_display
Regards,
Sachin -
Event Handling in Editable ALV
Hi all,
I am having 4 to 5 fields in my module pool screen and at the same time i am having a custom container wherein, there is editable ALV [using OOPS Editable ALV inside a custom container].
Here in editable ALV, i am having an editable field called dealer code.When i enter dealer code in editable ALV and press enter
my dealer name and dealer address in editable ALV inside Custom Container should get populated.
But when the cursor is inside the custom container in that editable field none of my screen eventsModule pool events
are getting triggered [Hence my values are not getting populated.When the cursor is outside the custom container all my module pool events are working fine, hence values are getting populated....
*I am handling the event in my program.But i don't know where exactly i should create object and handle this as
nothing is getting triggered[pai or pbo] when my cursor is inside the custom container.
Could you suggest me anything...*
Waiting for your repiles...Hi
First of all you need to creat object in PBO.
You must be calling method SET_TABLE_FOR_FIRST_DISPLAY.After this call method REGISTER_EDIT_EVENT.And then REFRESH_TABLE_DISPLAY.
In OK code create an OK code with name "OK".This is for ENTER key.
And in that call method CHECK_CHANGED_DATA.
Sample code for REGISTER_EDIT_EVENT is given below:
*--event to detect if data gets edited
CALL METHOD OBJ_ALV2->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
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.
Sample code for CHECK_CHANGED_DATA
*--when alv is edited and ENTER button is clicked then data
*will be saved in internal table and edited data will
*be displayed on alv
IF V_OK_CODE = 'OK'.
*--metohd to detect if data was changed in oops alv
CALL METHOD OBJ_ALV2->CHECK_CHANGED_DATA
IMPORTING
E_VALID =
CHANGING
C_REFRESH = 'X'
ENDIF.
Hope this solves your problem.
Thanks
Khushboo -
Display in editable alv grid.
Hi,
This is my source code of uploading excel into sap and displaying the list.Please give the code for displaying the excel data in editable alv.
<<The code came from [here|https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-UploaddatafromExceltoSapusing+OO]>>
Thanks in advance.
am just a beginner in learning abap objects.pls help.
Edited by: Matt on Aug 6, 2009 4:26 PMIt wasn't your source code, was it?
Please take the time to read the rules of engagement. As it stands, your question is far too general. There are examples of editable alvs in many location on the net. You must search for them. Please note these are not training forums, they are expert forums. When you have a specific question, we'll be glad to assist.
Post locked
matt
Maybe you are looking for
-
Hello, I have to change the PW for user admin and tried to do this in the ERP/SU01 on every client. The connection to XI was lost. The error 'can not read exchange profile' occurred. I reset the password of user admin in all clients to default and en
-
Photoshop CS4 Installer File for Mac
Hello, I bought CS4 for mac (student edition, I am not sure if that matters) a couple of years ago and have since misplaced my disks, though I still have the serial numbers. Does anybody have the .dmg installer file for CS4? The file name MAY be ph
-
How to invoke a report by name instead of ID?
Hello, We have developed several shared reports which are invoked from other applications. In Active Studio we select the Report and use "Copy Shortcut" option in left menu to get a web link such this: http://work/oraclebam/ReportServer/default.aspx?
-
JScrollPane - scroll bar not visible
I'm writing a graphical chat application where the user presses buttons to insert images into their message. The buttons reside in a JPanel with a GridLayout. As i have more buttons than can be physically seen on the screen I'm trying to use a JScrol
-
what to do, and what happened, how can I get a replacment, I live in bahrain.