This website is not affiliated with, sponsored by, or approved by SAP AG.

ALV grid get current values from screen

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ALV grid get current values from screen

Postby Eggy » Wed Jan 21, 2015 10:18 am

The main question: How to get the current values from screen into an internal table? (using cl_gui_alv_grid)

What I've got on screen is an ALV grid that can be edited. Part of the table are two date fields to set the period for which the record is valid. When saving, I need to perform a check whether there are any overlapping periods. And if so, display a neat error message.

The problem I'm facing is that I can't get the current values from screen. The cl_gui_alv_grid class provides me with the data_changed event, in which I can get hold of a table that contains all individual fields that have been changed. I would have to use that to reconstruct the current values using the original table, row id's, fieldnames and new values... possible, but prone to errors.

Is there any way of simply retrieving the current values I have in my ALV grid on screen? Thanks in advance!
Eggy
 
Posts: 309
Joined: Wed Jan 11, 2006 8:50 am

Re: ALV grid get current values from screen

Postby Gothmog » Wed Jan 21, 2015 11:37 am

I think if you're using event DATA_CHANGED_FINISHED, the internal table is already updated with the changed values.
DATA_CHANGED happens before that.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: ALV grid get current values from screen

Postby jamiguel7777 » Wed Jan 21, 2015 5:42 pm

You can call this method:

DATA_CHANGED

this method update the values on the internal table assigned on:

g_grid->SET_TABLE_FOR_FIRST_DISPLAY

then you can check this table but after call the method DATA_CHANGED

for more info see the sample:

BCALV_EDIT_05

thanks.
jamiguel7777
 
Posts: 11
Joined: Tue Jan 20, 2015 10:47 am

Re: ALV grid get current values from screen

Postby Eggy » Thu Jan 22, 2015 4:01 am

Thanks! I have no idea why I didn't look at the table contents AFTER the check_changed_data method... indeed it is updated afterwards. So I can simply run my checks on overlapping periods afterwards :)
Eggy
 
Posts: 309
Joined: Wed Jan 11, 2006 8:50 am

Re: ALV grid get current values from screen

Postby jamiguel7777 » Thu Jan 22, 2015 10:06 am

other way is:


I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.


CALL METHOD g_grid->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = gs_layout
IT_TOOLBAR_EXCLUDING = lt_exclude
CHANGING
IT_OUTTAB = Registros_Proveedores[]
IT_FIELDCATALOG = gt_fieldcat.

CALL METHOD g_grid->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.

CALL METHOD g_grid->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.

Test please.
jamiguel7777
 
Posts: 11
Joined: Tue Jan 20, 2015 10:47 am

Re: ALV grid get current values from screen

Postby asix78 » Fri Jan 23, 2015 8:25 am

Eggy wrote:The main question: How to get the current values from screen into an internal table? (using cl_gui_alv_grid)

You have to just call method lo_grid->check_changed_data( ) to actualize internal table (pass all changes).
asix78
 
Posts: 3
Joined: Fri Jan 23, 2015 7:29 am


Return to ABAP

Who is online

Users browsing this forum: Google [Bot] and 8 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.