‎2008 Jun 11 11:32 AM
CASE e_ucomm .
WHEN 'CHANGE' .
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows.
* READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
* IF sy-subrc NE 0 .
* MESSAGE s000(su) WITH 'Select a row!'(203) .
* ENDIF .
LOOP AT lt_selected_rows INTO ls_selected_row.
READ TABLE i_output INDEX ls_selected_row-row_id TRANSPORTING NO FIELDS.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'MINIMUM' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
INSERT LINES OF lt_styletab INTO table ls_listrow-cellstyles .
APPEND ls_listrow to i_output.
ENDLOOP .I have given the code as above to make by field 'MINIMUM' as editable in my final alv display. But when i execute it its not getting displayed in the editable mode.
Can u find th problem and tell me
‎2008 Jun 11 11:54 AM
In your code, you have used APPEND for modifying ls_listrow. Instead of APPEND you need to modify i_output.
LOOP AT lt_selected_rows INTO ls_selected_row.
READ TABLE i_output INTO wa_output INDEX ls_selected_row-row_id.
l_tabix = sy-tabix.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'MINIMUM' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
Append lt_listrow to wa_output-lt_listrow. "lt_listrow is a field in your output table
MODIFY i_output FROM wa_output INDEX l_tabix TRANSPORTING lt_listrow.
ENDLOOP .
Regards,
Lakshmi.
‎2008 Jun 11 11:34 AM
HI,
Check your fieldcat table for this field. EDIT = 'X' should be there for this particular field.
Rgds,
Bujji
‎2008 Jun 11 11:35 AM
Try this way :
APPEND 'MINIMUM' TO fcode.
SET PF-STATUS 'STATUS_0100' EXCLUDING fcode.
include all buttons you want to exclude into fcode.
now go to your pf status thru menu painter - right click on application tool bar.
select radio button - attributes.> display of inactive functions> Select radio button display all.
activate.
this will display the inactive functions..but in a grayed out mode.
Rewards ponts if helpful.
Mustapha
‎2008 Jun 11 11:36 AM
Use method refresh_table_display of grid to refresh the alv with the changes.
At the end of your code, call this method.
Regards,
Lakshmi.
‎2008 Jun 11 11:43 AM
I gave refresh display. But what is happeniong is a new row is getting added at the end.
‎2008 Jun 11 11:54 AM
In your code, you have used APPEND for modifying ls_listrow. Instead of APPEND you need to modify i_output.
LOOP AT lt_selected_rows INTO ls_selected_row.
READ TABLE i_output INTO wa_output INDEX ls_selected_row-row_id.
l_tabix = sy-tabix.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'MINIMUM' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
Append lt_listrow to wa_output-lt_listrow. "lt_listrow is a field in your output table
MODIFY i_output FROM wa_output INDEX l_tabix TRANSPORTING lt_listrow.
ENDLOOP .
Regards,
Lakshmi.
‎2008 Jun 11 12:14 PM
Ya i have made the changes.Even then the list comes in display mode. Should i need to change anything to make the MINIMUM as editable.
‎2008 Jun 11 12:27 PM
In Layout,
wa_layout-stylefname = 'IT_STYLETAB'. - This should be the field name in your output table for styles. In this case lt_listrow i think.
Set this and pass layout to Set_table_for_first_display if not done already.
Regards,
Lakshmi.
‎2008 Jun 11 12:30 PM
Ya that I have done already lakshmi.
See this,
gs_layout-stylefname = 'CELLSTYLES'.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'X'
is_layout = *gs_layout*
it_toolbar_excluding = pt_exclude
CHANGING
it_outtab = i_output[]
it_fieldcatalog = i_fldctlg
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
‎2008 Jun 11 12:35 PM
Call this method before refresh_table_display.
CALL METHOD tt_gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
Regards,
Lakshmi.
‎2008 Jun 11 1:19 PM
I called that method. But what it made is, it deleted all my data in the alv list and is displaying a empty alv list instaed of my data.
‎2008 Jun 12 4:47 AM
Hi,
Paste your entire code if problem is not solved yet.
Regards,
Lakshmi.
‎2008 Jun 12 5:25 AM
My entire code,
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA event_receiver TYPE REF TO lcl_event_receiver.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
* MOVE 3 TO ls_toolbar-butn_type.
* APPEND ls_toolbar TO i_object->mt_toolbar.
* CLEAR ls_toolbar.
MOVE 'CHANGE' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_change TO ls_toolbar-icon.
MOVE 'Change rows' TO ls_toolbar-quickinfo.
* MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO e_object->mt_toolbar.
MOVE 'DELETE' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_delete TO ls_toolbar-icon.
MOVE 'Delete rows' TO ls_toolbar-quickinfo.
* MOVE 'Passenger Info'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO e_object->mt_toolbar.
MOVE 'NEW ENTRIES' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_create TO ls_toolbar-icon.
MOVE 'New records' TO ls_toolbar-quickinfo.
MOVE 'New Entry'(201) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
DATA lt_selected_rows TYPE lvc_t_roid .
DATA ls_selected_row TYPE lvc_s_roid .
* DATA i_ucomm LIKE sy-ucomm.
DATA ls_listrow LIKE LINE OF i_output .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
DATA l_index TYPE i.
CASE e_ucomm .
WHEN 'CHANGE' .
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows.
* READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
* IF sy-subrc NE 0 .
* MESSAGE s000(su) WITH 'Select a row!'(203) .
* ENDIF .
LOOP AT lt_selected_rows INTO ls_selected_row.
l_index = sy-tabix.
READ TABLE i_output INDEX ls_selected_row-row_id TRANSPORTING NO FIELDS.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'MINIMUM' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
ENDIF .
INSERT LINES OF lt_styletab INTO TABLE ls_listrow-cellstyles .
* MODIFY i_output FROM wa_output INDEX l_tabix TRANSPORTING lt_listrow
MODIFY i_output FROM ls_listrow INDEX l_index.
PERFORM s_input_ready.
PERFORM s_refresh_display.
ENDLOOP .
ENDCASE .
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*Building ALV layout
FORM s_build_layout .
gs_layout-cwidth_opt = c_x.
gs_layout-zebra = c_x.
gs_layout-sel_mode = 'D'. "For rows, columns and cells
gs_layout-grid_title = 'ASSORTMENT LIST'.
* gs_layout-no_toolbar = 'X'.
gs_layout-stylefname = 'CELLSTYLES'.
ENDFORM. " S_BULID_LAYOUT
*&---------------------------------------------------------------------*
*& Form S_DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ss_display_alv.
IF gr_alvgrid IS INITIAL .
*----Creating custom container instance
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gc_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Preparing field catalog.
PERFORM s_build_fldctlg.
PERFORM s_status USING rt_extab.
*----Preparing layout structure
PERFORM s_build_layout.
PERFORM hide_standard." CHANGING ls_exclude." TYPE ui_functions.
********************************************
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'X'
is_layout = gs_layout
it_toolbar_excluding = pt_exclude
CHANGING
it_outtab = i_output[]
it_fieldcatalog = i_fldctlg
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ELSE .
ENDIF .
ENDFORM. " S_DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Module S_DISPLAY_ALV OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE s_display_alv OUTPUT.
* SET PF-STATUS 'MAIN100'.
* SET TITLEBAR 'MAIN100'.
PERFORM ss_display_alv.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR gr_alvgrid.
SET HANDLER event_receiver->handle_toolbar FOR gr_alvgrid.
CALL METHOD gr_alvgrid->set_toolbar_interactive.
ENDMODULE. " S_DISPLAY_ALV OUTPUT
FORM s_refresh_display .
CALL METHOD gr_alvgrid->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
EXCEPTIONS
finished = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " S_REFRESH_DISPLAY
*&---------------------------------------------------------------------*
*& Form S_INPUT_READY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form S_INPUT_READY .
CALL METHOD gr_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 1
.
endform. " S_INPUT_READY
‎2008 Jun 12 5:52 AM
Still there are some confusions in the code. Change it as below.
CASE e_ucomm .
WHEN 'CHANGE' .
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows.
* READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
* IF sy-subrc NE 0 .
* MESSAGE s000(su) WITH 'Select a row!'(203) .
* ENDIF .
LOOP AT lt_selected_rows INTO ls_selected_row.
* Refresh tables for each pass
REFRESH lt_styletab.
* l_index = sy-tabix. "sy-tabix here will have an index to lt_selected_rows table. You can use ls_selected_row-row_id itself. No need to have index separately.
* READ TABLE i_output INDEX ls_selected_row-row_id TRANSPORTING NO FIELDS.
* You are not reading any data from i_output into workarea, then how can you modify it later?
READ TABLE i_output INTO ls_listrow INDEX ls_selected_row-row-id.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'MINIMUM' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .
APPEND ls_stylerow TO lt_styletab .
* Clear workarea
CLEAR: ls_stylerow.
* ENDIF
INSERT lines of lt_styletab INTO TABLE ls_listrow-cellstyles .
* MODIFY i_output FROM wa_output INDEX l_tabix TRANSPORTING lt_listrow
* MODIFY i_output FROM ls_listrow INDEX l_index . "l_index is not required
MODIFY i_output FROM ls_listrow INDEX ls_selected_row-row_id TRANSPORTING cellstyles.
ENDIF.
* PERFORM s_input_ready.
* PERFORM s_refresh_display.
ENDLOOP .
PERFORM s_input_ready.
PERFORM s_refresh_display.
I think it should work now. If you have problems, debug and see the structure of i_output at the end of the loop. Structure should be something like this,
field1 field2 field3 field4 minimum cellstyles
10 10 10 10 filedname style
MINIMUM enabled
i_output is a deep structure where field cellstyles is again a table with fieldname and style for each row.
Regards,
Lakshmi.
‎2008 Jun 12 8:31 AM
‎2008 Jun 14 8:11 AM
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows.
LOOP AT lt_selected_rows INTO ls_selected_row.
REFRESH lt_styletab.
READ TABLE i_output INTO ls_listrow INDEX ls_selected_row-row_id.
IF sy-subrc = 0 .
ls_stylerow-fieldname = 'ZZ_ACC_ASSGN'.
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
APPEND ls_stylerow TO lt_styletab .
CLEAR ls_stylerow.
ls_stylerow-fieldname = 'ZZ_DEPT_NAME' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
APPEND ls_stylerow TO lt_styletab .
CLEAR ls_stylerow.
ls_stylerow-fieldname = 'ZZ_ROOM_NR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
APPEND ls_stylerow TO lt_styletab .
CLEAR ls_stylerow.
ls_stylerow-fieldname = 'ZZ_LOC' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .
APPEND ls_stylerow TO lt_styletab .
CLEAR ls_stylerow.
ENDIF .
APPEND LINES OF lt_styletab TO ls_listrow-cellstyles.
MODIFY i_output FROM ls_listrow INDEX ls_selected_row-row_id TRANSPORTING cellstyles.
ENDLOOP.Hi I have given the code as above to disable my fields. But I am getting a runtime error as "A line is to be inserted or changed at position 3 in the sorted
internal table (type SORTED_TABLE)
"\PROGRAM=ZIAB_E_03_COPY\FORM=S_DISABLE_FIELDS\DATA=LT_STYLETAB".
In doing so, the sorting sequence - determined by the table key - was
destroyed."
Do anybody know wat it is??