09-11-2013 3:55 PM
Hello.
I have to modify program which is based on REUSE_ALV_GRID_DISPLAY function module.
I want to highlight single cell, not a whole raw. When I choose a cell this function highlight me a whole raw.
How to turn off highlighting a whole raw. I want to ony highlight one cell.
In this program is used REUSE_ALV_GRID_DISPLAY function module.
How to do it?
Regards
Bogdan
09-11-2013 5:18 PM
Hi Bogdan,
There is one solution which I have tried for your problem . Just add 1 dummy field to your fieldcat as editable and hide it . This will allow you to select a particular cell.
Example :
fieldcatalog-fieldname = 'DUMMY'.
fieldcatalog-seltext_m = 'DUMMY'.
fieldcatalog-col_pos = LAST_POS.
fieldcatalog-edit = 'X'.
fieldcatalog-no_out = 'X'.
APPEND fieldcatalog to fieldcatalog.
CLEAR fieldcatalog.
Regards,
Lohit
09-11-2013 5:18 PM
Hi Bogdan,
There is one solution which I have tried for your problem . Just add 1 dummy field to your fieldcat as editable and hide it . This will allow you to select a particular cell.
Example :
fieldcatalog-fieldname = 'DUMMY'.
fieldcatalog-seltext_m = 'DUMMY'.
fieldcatalog-col_pos = LAST_POS.
fieldcatalog-edit = 'X'.
fieldcatalog-no_out = 'X'.
APPEND fieldcatalog to fieldcatalog.
CLEAR fieldcatalog.
Regards,
Lohit
09-12-2013 5:50 AM
Hi Bogdan,
As lohit said it will work fine but i think you need not pass any value to
fieldcatalog-col_pos which is not required . If it is not matching to your program requirement it will show a dump.
Regards.
09-12-2013 7:06 AM
Hi Amarnatha,
Yea you are right fieldcatalog-col_pos is not a compulsary field . I gave him an example ,if he has used COL_POS ,then he should give it the last position.
Rgds.
09-12-2013 5:51 AM
Hi Bogdan Biegan'ski,
I am not clear about your question
In ALV if you click this total row will select
like this
if you select specific field it selects field only like this
Code for reference
TABLES : sflight .
TYPE-POOLS : slis .
TYPES : BEGIN OF ty_sflight , " Structure
carrid TYPE sflight-carrid ,
connid TYPE sflight-connid ,
fldate TYPE sflight-fldate ,
price TYPE sflight-price ,
currency TYPE sflight-currency ,
planetype TYPE sflight-planetype ,
* cell TYPE slis_t_specialcol_alv ,
END OF ty_sflight .
DATA : it_sflight TYPE TABLE OF sflight , " Internal Table
wa_sflight TYPE sflight .
DATA : it_fcat TYPE slis_t_fieldcat_alv , " Field Cat
wa_fcat TYPE slis_fieldcat_alv .
DATA : wa_layout TYPE slis_layout_alv . " Layout
DATA : wa_grid TYPE lvc_s_glay . " Grid Setting
DATA : variant TYPE disvariant . " Layout
data : FM_NAME type TDSFNAME.
START-OF-SELECTION .
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight .
PERFORM fieldcat . " Field catalog
wa_layout-colwidth_optimize = 'X' . " Optimize the Field Name
wa_layout-zebra = 'X' . " Zebra
wa_layout-coltab_fieldname = 'CELL'. " To color one particular cell
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USRCMD' " Create FORM for this
i_callback_top_of_page = 'TOPOFPAGE' " Create FORM for this
i_background_id = 'SKY' " Background, OAER
i_grid_title = 'Sflight Table' " ALV Title
i_grid_settings = wa_grid " Grid Settings
is_layout = wa_layout " Layout
it_fieldcat = it_fcat " Field Cat
i_save = 'X' " Save
is_variant = variant " Variant
TABLES
t_outtab = it_sflight.
*&---------------------------------------------------------------------*
*& Form FIELDCAT
*&---------------------------------------------------------------------*
FORM fieldcat .
CLEAR it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'CARRID'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-seltext_m = 'Airline Code'.
wa_fcat-no_zero = 'X'.
wa_fcat-key = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'CONNID'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-seltext_l = 'Flight Connection Number'.
wa_fcat-key = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'FLDATE'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-seltext_m = 'Flight date'.
wa_fcat-key = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'PRICE'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-seltext_m = 'Airfare'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'CURRENCY'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-edit = 'X'.
wa_fcat-seltext_m = 'Local currency'.
wa_fcat-emphasize = 'C410' .
* WA_FCAT-KEY = 'X'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'PLANETYPE'.
wa_fcat-tabname = 'IT_SFLIGHT'.
wa_fcat-seltext_m = 'Aircraft Type'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM . "FIELDCAT
*&---------------------------------------------------------------------*
*& Form USRCMD
*&---------------------------------------------------------------------*
FORM usrcmd USING ucomm TYPE sy-ucomm " For Double Click
selfield TYPE slis_selfield .
DATA : it_sflight1 LIKE it_sflight .
DATA : it_sflight2 TYPE TABLE OF sflight ,
wa_sflight2 TYPE sflight .
CASE ucomm .
WHEN '&IC1' .
READ TABLE it_sflight INTO wa_sflight INDEX selfield-tabindex .
APPEND wa_sflight TO it_sflight1 .
ENDCASE.
ENDFORM . "USRCMD
*&---------------------------------------------------------------------*
*& Form TOPOFPAGE
*&---------------------------------------------------------------------*
FORM topofpage . " Header
DATA: it_header TYPE TABLE OF slis_listheader ,
wa_header TYPE slis_listheader .
wa_header-typ = 'H'. " H: Header, S: Sub header, A: Italic
wa_header-info = 'ALV Report'.
APPEND wa_header TO it_header .
CLEAR wa_header. "
* DATE
wa_header-typ = 'S'.
wa_header-key = 'DATE: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "TODAYS DATE
APPEND wa_header TO it_header.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
i_logo = 'LUFTHANSA'. " Upload the logo through T Code: OAER
ENDFORM . "TOPOFPAGE
09-12-2013 7:02 AM
Hi Ramesh ,
This is possible in your example because you some editable fields . You cannot select a particular cell if there are no editable field in your ALV which is Bogdan's case.
Rgds.
09-12-2013 5:55 AM
Hi Bogdan,
In the field catalog , try to add value 'X' to edit of field catalog , and try to make all other fields as ' ' in edit field of field catalg. This will make the desired field to be highlighted .
CALL METHOD catalog
EXPORTING
i_tablename = 'LT_TADIR_DISP'
i_fieldname = 'CHK'
i_text = text-009 "Check Box
i_len = c_fieldlength
i_checkbox = 'X'
i_edit = 'X'
i_hotspot = ' '.
09-12-2013 6:26 AM
09-12-2013 6:45 AM
09-12-2013 7:11 AM
Many thanks to all for the quick reply. Probably most of you have the right.
For me, the easiest solution is to create an additional column, giving it attributes to edit and hide it. It is solution proposed by lohit devadiga.
Thanks a lot for help
Regards
Bogdan
09-12-2013 9:34 AM
Hii
you can do that by following
declare a layout work area by
x_layout TYPE slis_layout_alv,
and write the followingcode before calling FM 'REUSE_ALV_GRID_DSIPLAY'
x_layout-box_fieldname = space.
and in field catalog enable the editable mode like below
CLEAR: x_fieldcat.
x_fieldcat-tabname = p_tabname.
x_fieldcat-fieldname = p_fieldname.
x_fieldcat-seltext_m = p_text.
x_fieldcat-outputlen = p_length.
x_fieldcat-edit = 'X'. "Enable editable mode in grid display
APPEND x_fieldcat TO t_fieldcat.
means in editable mode.
you can select any cell and only that particular cell will be highlighted.
other alternative is displaying alv grid using oops.
here you can highlighted any cell in none editable mode.
If can do that using oops then it will be very simple.
put
lx_layout-sel_mode = 'A'.
and
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
is_layout = lx_layout "layout work area
CHANGING
it_outtab = lt_not_exist "output table
it_fieldcatalog = lt_fieldcat "field catalog table
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards
Syed