on 07-27-2005 9:57 AM
Hi everybody.
I am calling FM REUSE_ALV_GRID_DISPLAY to display certain data in an ALV grid. Some of the fields are supposed to be editable, so I modify the field catalogue accordingly (fieldcat-edit = 'X'). Since I want to edit some of the grid data I set the LAYOUT structure fields EDIT to 'X' and EDIT_MODE to ' ', respectively.
Now I have two problems:
The first problem is that all fields are editable, not just the ones I set fieldcat-edit = 'X' for. Even those with fieldcat-edit = ' ' are editable.
The second problem is that the internal table isn't always updated when I change the data in the ALV grid. I enter new text in one of the fields, but the internal table is changed only when I press the enter key or do some other stuff that causes a PAI (at least that's what I think). When I press 'SAVE' whithout hitting enter before, the data isn't updatet at all!!!
Is there a solution to this problem? Do I have to set the parameters EDIT or EDIT_MODE of the LAYOUT structure to any magic values before alling REUSE... ?
Any comments?
Regards, Joerg
Hi, I think can solve you second problem, about the update internal table after user inputted.
Call FM like this:
DATA:
LC_GLAY TYPE LVC_S_GLAY.
this is the critical point
LC_GLAY-EDT_CLL_CB = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_SETTINGS = LC_GLAY
IT_FIELDCAT = L_ALV_FILEDCAT
TABLES
T_OUTTAB = ITAB.
Then you can get the user inputted after FM return.
Hope it will be helpful, thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Something addition to my former reply.
You should move the cursor leave the cell, after finish the input.
Otherwise, the inputted date won't be update into internal table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
1) <b>don't</b> set LVC_S_LAYO-edit = 'X'.
2) -> use event <b>data_changed</b> of cl_gui_alv_grid
regards Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
See the following line in the below code,
line_fieldcat-edit = 'X'. This is the way how u shld make the field editable.
REPORT zsomalv3 NO STANDARD PAGE HEADING.
TYPE-POOLS: slis.
DATA: BEGIN OF i_data OCCURS 0,
qmnum LIKE qmel-qmnum,
qmart LIKE qmel-qmart,
qmtxt LIKE qmel-qmtxt,
ws_row TYPE i,
ws_char(5) TYPE c,
chk,
END OF i_data.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
SELECT qmnum
qmart
qmtxt
INTO TABLE i_data
FROM qmel
WHERE qmnum <= '00030000010'.
LOOP AT i_data.
i_data-ws_row = sy-tabix.
i_data-ws_char = 'AAAAA'.
MODIFY i_data.
ENDLOOP.
report_id = sy-repid.
PERFORM f1000_layout_init CHANGING i_layout.
PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
i_callback_program = report_id
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* i_structure_name = ' '
* I_BACKGROUND_ID = ' '
i_grid_title = ws_title
* I_GRID_SETTINGS =
is_layout = i_layout
it_fieldcat = i_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'A'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_data
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.
*&---------------------------------------------------------------------*
*& Form F1000_Layout_Init
*&---------------------------------------------------------------------*
FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM. " F1000_Layout_Init
*&---------------------------------------------------------------------*
*& Form f2000_fieldcat_init
*&---------------------------------------------------------------------*
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMNUM'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-key = 'X'.
line_fieldcat-seltext_m = 'Notification No.'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMART'.
line_fieldcat-ref_tabname = 'I_DATA'.
line_fieldcat-hotspot = 'X'.
line_fieldcat-seltext_m = 'Notif Type'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMTXT'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Description'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_ROW'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Row Number'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_CHAR'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Test Character Field'.
line_fieldcat-datatype = 'CHAR'.
line_fieldcat-outputlen = '15'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'CHK'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Checkbox'.
line_fieldcat-checkbox = 'X'.
line_fieldcat-edit = 'X'.
APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init
Regs,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the reply, but unfortunately that's exactly what I do - and it doesn't wor for me...
Here's the code I use:
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
...
changing ct_fieldcat = it_fieldcat[]
...
loop at it_fieldcat.
case it_fieldcat-fieldname.
when 'MATNR' or 'WERKS' or 'CHARG'.
it_fieldcat-edit = ' '.
it_fieldcat-key = 'X'.
when others.
it_fieldcat-edit = 'X'.
endcase.
modify it_fieldcat.
endloop.
l_layout-box_fieldname = 'MARK'.
l_layout-edit = 'X'.
l_layout-edit_mode = ' '.
l_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
...
While xperimenting, I found out that setting l_layout-edit = 'X' makes all fields editable, regardless of the field cataloue. Removing this line (or explicitly setting l_layout-edit = ' ') makes just those fields editable that are enabled in the field catalogue. So this problem is kind of solved...
Problem two remains, however. Any ideas there?
Regards, Joerg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.