2009 Jun 04 6:41 PM
Hi all,
how to add new row to ALV list with some fields filled with default values?
It would work with edit event registered as modification
"CALL METHOD go_grid_310->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified"
but then adding new record to ALV automatically calls check_changed_data and if other fields are empty error protocol is returned.....before user enter any data into new ALV row.
Thanks
J.
2009 Jun 05 10:13 AM
2009 Jun 05 3:26 PM
Hi,
This is possible through customization INSERT button on the application toolbar.
For fields(Columns on ALV) with default values and input fields in ALV, please find the sample code below.
WHEN 'INSERT'. "Define INSERT button on application toolbar
CLEAR wa_zqmseq.
PERFORM fill_celltab USING 'RW'
CHANGING lt_celltab.
INSERT LINES OF lt_celltab INTO TABLE wa_zqmseq-celltab.
*"passing default values to alv*
wa_zqmseq-mandt = sy-mandt.
wa_zqmseq-bereich = v_bereich.
wa_zqmseq-obersq = p_obersq.
APPEND wa_zqmseq TO itab_zqmseq.
*This form is used to enable input fields in the ALV
FORM fill_celltab USING value(p_mode)
CHANGING pt_celltab TYPE lvc_t_styl.
DATA: ls_celltab TYPE lvc_s_styl,
l_mode TYPE raw4.
* This forms sets the style of columns 'HPTSEQ',BEZEICHNUNG and
* SORTIERUNG editable
Refresh pt_celltab.
clear ls_celltab.
IF p_mode EQ 'RW'.
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'HPTSEQ'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'BEZEICHNUNG'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'KATEGORIE'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SORTIERUNG'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ENDFORM. " FILL_CELLTAB