Freezing of cell of ALV(urgent)
Hi all abapers,
My requirement is to freeze a particular cell of ALV grid. Pleas give me an idea of that if anyway it is possible.
I anticipate for ur reply.
I assure you for giving full marks if you get my solution done.
Cheers,
Hi Pradeep,
before calling "REUSE_ALV_LIST_DISPLAY".
write the code as below:
LOOP AT FCAT ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'MATNR'.
<b><lfs_fieldcat>-KEY = 'X'. "for freezing MATNR column</b>
WHEN 'ERSDA'.
<b><lfs_fieldcat>-KEY = 'X'. "for freezing ERSDA column</b>
WHEN 'ERNAM'.
<b><lfs_fieldcat>-KEY = 'X'. "for freezing ERNAM column</b>
endcase.
endloop.
<b>Reward points if it is useful....</b>
Cheers !
Moqeeth.
Similar Messages
-
Double click on cell in alv report
Hi all,
I want to show detail popup on cell of alv report. how to get the cell value.
plz tell me the logic for getting cell value.
thanks in advance.Hi,
IF RS_SELFIELD-FIELDNAME = 'EBELN1'.
* Read data table, using index of row user clicked on
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
Please remember the field EBELN1 should be in IT_EKKO. after the read statement you can move which ever field you want to another for further processing
like
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
if sy-subrc eq 0.
move it_ekkp-( your field name) to v_field
endif.
a® -
How to give color of particular cell in alv list display for dynamic table
Dear Experts,
i want to give color of a particular cell in alv list display (reuse_alv_list_display). Here i am passing data through dynamic table?Hi,
Se this:
DATA: lt_color TYPE lvc_t_scol WITH HEADER LINE.
DATA: BEGIN OF data_tab OCCURS 0.
tabcolor TYPE lvc_t_scol,
END OF data_tab.
* Befone ALV call
alv_layout-coltab_fieldname = 'TABCOLOR'.
* For each row in data_tab
REFRESH: lt_color.
CLEAR: lt_color.
lt_color-color-col = 6.
lt_color-color-int = 1.
lt_color-fname = FIELD1'.
APPEND lt_color.
lt_color-color-col = 2.
lt_color-color-int = 0.
lt_color-fname = 'FIELD2'.
APPEND lt_color.
data_tab-tabcolor[] = lt_color[].
append data_tab.
Best regards,
Leandro Mengue -
How to make cell editable alv in WebDynpro for ABAP?
I make Column editable ALV.(See under source code)
But I can't make Cell editable ALV.
How to make Cell editable ALV in WebDynpro for ABAP?
and..how to get changed data?
DATA: l_value TYPE REF TO cl_salv_wd_config_table.
l_value = l_ref_interfacecontroller->get_model( ).
* { EDITABLE
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field,
lr_column TYPE REF TO cl_salv_wd_column.
lr_column_settings ?= l_value.
lr_column = lr_column_settings->get_column( 'TOTAL_COUNT' ).
CREATE OBJECT lr_input_field
EXPORTING
value_fieldname = 'TOTAL_COUNT'.
lr_column->set_cell_editor( lr_input_field ).
DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= l_value.
lr_table_settings->set_read_only( abap_false ).the code seems to be correct....but where are you writing it?
put the code in the wddoinit method and it should work.
have a look at this article..
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1 -
Can we put text and button together in the same cell of ALV?
Can we put a button and text in a cell of ALV Grid?
Requirement in detail:
Material Description + button - when the button is clicked, it opens up a screen to enter text.
I able to open the screen ob button click but..
when I concatenated the material description and an icon, it showing garbage in ALV output.Hi,
I think it is possible..check this code..I believe this also depends on the GUI version..Mine is 6.40 patch level 32....in my output it is showing icon with the text in one column...
TYPE-POOLS slis.
INCLUDE <icon>.
TYPES: BEGIN OF type_data,
matnr TYPE matnr,
END OF type_data.
DATA: t_fcat TYPE slis_t_fieldcat_alv.
DATA: s_fcat TYPE LINE OF slis_t_fieldcat_alv.
DATA: t_data TYPE STANDARD TABLE OF type_data.
DATA: s_data TYPE type_data.
* Field catalog.
s_fcat-fieldname = 'MATNR'.
s_fcat-row_pos = '1'.
s_fcat-ref_tabname = 'MARA'.
s_fcat-ref_fieldname = 'MATNR'.
APPEND s_fcat TO t_fcat.
CONCATENATE icon_negative 'test matnr' INTO s_data.
APPEND s_data TO t_data.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = t_fcat
TABLES
t_outtab = t_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.
Thanks
Naren -
Possible to have vertical scroll bar for a cell in ALV Grid (using methods)
Hi All,
I have a field with length 100 characters on a ALV Grid (using methods)..User doesn't want to scroll all the 100 characters horizontally to see the whole text rather he wants to have a vertical scroll bar for the cell so that he can scroll vertically.
Is it possible to have split the cell text into lines and have a vertical scroll bar for a cell in ALV Grid?
Regards
Jaker.Thanks for the suggestion Balu.I tried this , but while scrolling,headers also getting scrolled.
Becoz of this , if i scroll down to the last row,headers are getting hidden.
Headers should always be static.only the data should scroll.
Since h:datatable is being rendered as one table , i can div tag for this table alone.
If i have seperate datatable for headers alone i can do this .But i should not use two datatables. -
Display only cell in ALV Grid in OO
Hi Folks,
Hope someone can help me with this little issue. I have a series of columns in my ALV grid that are editable, but I need to a) make some of the cells on specific lines uneditable and b) display time based fields on this line as blank (presently they shoe 00:00:00).
For problem a) I have set the layout style frame as 'cellstyles'
es_layout-stylefname = 'CELLSTYLES'.
I have also set the edit flag in the field catalog for the individual columns to 'X' eg
WHEN 'CUSTTS_DATE_N'.
ls_fieldcat-edit = 'X'.
And coded:
gwa_stylerow-fieldname = 'CUSTTS_DATE_N'.
gwa_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND gwa_stylerow TO gt_stylerow.
wa_delivery_list-cellstyle[] = gt_stylerow[].
APPEND wa_delivery_list TO it_delivery_list.
Yet, the ALV cells are still being displayed as editable. Can't for the life of me figure out what's missing. The only other thought I had around this is that the wa_delivery_list-cellstyle table is being set in the data extraction code, before the ALV grid is built, and that the cell formats are being overwritten/on not being called by the field catalog entries. Any thoughts on how to make these fields/cells display only when the ALV is first displayed would be greatly appreciated.
As for option b) I'm clueless, as the cell style commands are not being picked up (see problem a.). Again any thoughts would be appreciated, and points will be rewarded for solutions/suggestions that lead to solutions.
Cheers,
Stephen KeamHello Stephen
I have created a simple report ZUS_SDN_ALV_EDITABLE_1B which shows how to use editability on cell level.
The crucial parts of the coding for your requirements are shown below, followed by the entire report.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPTIM'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ls_fcat-no_zero = abap_true. " suppresses 00:00:00
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
*& Form SET_CELL_EDITABLE
* text
* --> p1 text
* <-- p2 text
FORM set_cell_editable .
* define local data
DATA: ld_idx TYPE i,
ls_outtab TYPE ty_s_outtab,
ls_style TYPE lvc_s_styl.
LOOP AT gt_outtab INTO ls_outtab.
ld_idx = syst-tabix.
REFRESH: ls_outtab-celltab.
" NOTE: if you change the year of column ERDAT to 2008 then two columns will become non-editable
IF ( ls_outtab-erdat+0(4) = '2008' ).
CLEAR: ls_style.
ls_style-fieldname = 'UPDAT'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
CLEAR: ls_style.
ls_style-fieldname = 'UPTIM'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
ELSE.
ENDIF.
MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
TRANSPORTING celltab.
ENDLOOP.
ENDFORM. " SET_CELL_EDITABLE
*& Report ZUS_SDN_ALV_EDITABLE
*& Thread: Display only cell in ALV Grid in OO
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="765083"></a>
* Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
**PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
**PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
*& GUI-Status: ok-codes BACK, EXIT, CANC
REPORT zus_sdn_alv_editable_1b.
TYPE-POOLS: abap.
CONSTANTS:
gc_tabname TYPE tabname VALUE 'KNB1'.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knb1 AS knb1.
TYPES: celltab TYPE lvc_t_styl.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab,
gt_outtab_pbo TYPE ty_t_outtab.
DATA:
gd_answer TYPE c.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
" Just trigger PAI followed by PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH'
* IMPORTING
* rc =
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM (gc_tabname) INTO CORRESPONDING FIELDS
OF TABLE gt_outtab UP TO 99 ROWS.
gt_outtab_pbo = gt_outtab. " set PBO data
PERFORM init_controls.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
" NOTE: not required
* set handler:
* lcl_eventhandler=>handle_data_changed for go_grid.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
PERFORM set_cell_editable.
*§3.Optionally register ENTER to raise event DATA_CHANGED.
* (Per default the user may check data by using the check icon).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
SET HANDLER: lcl_eventhandler=>handle_data_changed FOR go_grid.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
i_save = 'A'
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
* NOTE:
* Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
*I_SAVE
*Determines the options available to the user for saving a layout:
*? 'X': global saving only
*? 'U': user-specific saving only
*? 'A': corresponds to 'X' and 'U'
*? SPACE: no saving
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
ENDFORM. " INIT_CONTROLS
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
" NOTE: retrieve changed data from frontend (grid control) into
" the backend (itab in ABAP)
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'REFRESH'.
PERFORM set_cell_editable.
" NOTE: Refresh required
CALL METHOD go_grid->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
* EXCEPTIONS
* finished = 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.
WHEN 'SAVE'.
IF ( gt_outtab = gt_outtab_pbo ).
MESSAGE 'No data changed' TYPE 'S'.
ELSE.
CLEAR: gd_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'Save data?'
* TEXT_BUTTON_1 = 'Ja'(001)
* ICON_BUTTON_1 = ' '
* TEXT_BUTTON_2 = 'Nein'(002)
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = gd_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 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.
IF ( gd_answer = '1' ). " yes
MESSAGE 'Data successfully saved' TYPE 'S'.
gt_outtab_pbo = gt_outtab. " update PBO data !!!
ELSE.
MESSAGE 'Action cancelled by user' TYPE 'S'.
ENDIF.
ENDIF.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = gc_tabname
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ls_fcat-edit = abap_true.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING edit
WHERE ( key NE abap_true ).
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPTIM'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ls_fcat-no_zero = abap_true. " suppresses 00:00:00
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPDAT'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
IF ( syst-tabix > 10 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
*& Form SET_CELL_EDITABLE
* text
* --> p1 text
* <-- p2 text
FORM set_cell_editable .
* define local data
DATA: ld_idx TYPE i,
ls_outtab TYPE ty_s_outtab,
ls_style TYPE lvc_s_styl.
LOOP AT gt_outtab INTO ls_outtab.
ld_idx = syst-tabix.
REFRESH: ls_outtab-celltab.
IF ( ls_outtab-erdat+0(4) = '2008' ).
CLEAR: ls_style.
ls_style-fieldname = 'UPDAT'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
CLEAR: ls_style.
ls_style-fieldname = 'UPTIM'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
ELSE.
ENDIF.
MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
TRANSPORTING celltab.
ENDLOOP.
ENDFORM. " SET_CELL_EDITABLE
Regards
Uwe -
Hidden Cells in ALV Output?
Hi Experts,
I didn't have idea about how to hidden Cells in ALV Grid Outpot.
Please give me any idea. and See the attached picture. It is help to Exact output.
Regards,
Thrimu AHi,
It is due to summation i.e sub total standard functionality.
When you set sub total for a column, the alv gets divided vertically into groups. All the cells of the column on which sub total is applied are displayed blank and a yellow cell under each group is displayed which has the total for those group of rows.
It is a standard functionality of ALV grid.
You cannot hide values of a column and display it blank in ALV. To achieve that you will have to do it manually :
add a empty column to the alv internal table and fieldcat with same heading as of the column to be displayed blank.
set fieldcat field NO_OUT = 'X' for the column that has to be hidden.
Regards,
Ashish -
Ask split long text into two line into same cell for ALV
Dear All,
Is it possible split long text into two line into same cell for ALV display data?
Regards,
Luke
Moderator message: please search for information before asking.
Edited by: Thomas Zloch on Feb 24, 2011 10:12 AMKeep options: Select the paragraph, then CtrlAltK (Mac: CmdOptK, I
think).
If you want the paragraphs in pairs, create two paragraph styles. Style
A has keep options set to start on a new page, and also, its Next Style
is style B.
Style B has no keep options, but it's Next Style is Style A.
Select all the text.
From the flyout menu of the paragraph styles palette, apply Style A
"then next style."
Now all paragraphs will be alternating -- style A, style B, style A, etc.
Now do what I wrote initially, and you'll have pairs of paragraph in
separate text frames. -
Changing colour based on cells for ALV in Web Dynpro ABAP
Hi,
I have a requirement where I need to change the font color for some cells of ALV in Web Dynpro ABAP. I am able to change the font color for whole row or whole column but need to know how to change it based on cells.
My output should be something like the picture attached to this discussion. The coloumns/cells where I need the font colour can change for different rows, based on some internal condition.
Please let me know how to achieve this...... Thank you.
- Divya PosanpallyHi Divya,
Your requirement can be achieved as below
Create an attribute for each column of alv i.e. COLOR_F1, COLOR_F2, COLOR_F3...... COLOR_F10 of type WDY_UIE_LIBRARY_ENUM_TYPE in the context node which holds the color value
Now while configuring ALV, set the field name of semantic color for each column as below
data lv_color_fld_name type string.
data lo_text_view type ref to cl_salv_wd_uie_text_view.
loop at lt_columns into ls_column.
concatenate 'COLOR' ls_column-id into lv_color_fld_name separated by '_'.
lo_text_view ?= ls_column-r_column->get_cell_editor( ).
if lo_text_view is bound.
lo_text_view->SET_SEMANTIC_COLOR_FIELDNAME( value = lv_color_fld_name ).
endif.
endloop.
Set the color based on the condition
loop at lt_data into ls_data.
if ..... "your condition here.
ls_data-color_f1 = cl_wd_text_view=>e_semantic_color-NEGATIVE.
ls_data-color_f2 = cl_wd_text_view=>e_semantic_color-POSITIVE.
elseif...... " another condition
endif.
endloop.
Note: You can optimize the code as per your requirement
Hope this helps you.
Regards,
Rama -
hi experts ,
any one tell me how to colour a cell in alve. give me some sample code.
reward points.......Hi
Fareeda
this is w2ht the code example u asked
if u found it helpfull plzz reward
TABLES:LFA1.
SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
REGIO LIKE LFA1-REGIO,
SORTL LIKE LFA1-SORTL,
CFIELD(4) TYPE C,
END OF ITAB.
data:col(4).
data:num value '1'.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
IN LIFNR.
LOOP AT ITAB.
concatenate 'C' num '10' into col .
ITAB-CFIELD = col.
num = num + 1.
if num = '8'.
num = '1'.
endif.
MODIFY ITAB.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
LAYOUT-EDIT = 'X'.
LAYOUT-info_fieldname = 'CFIELD'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
this is for coloring cols
REPORT ZBHCOLOR_COLS.
TABLES:LFA1.
SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
GRID RADIOBUTTON GROUP ALV.
DATA:BEGIN OF ITAB OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
LAND1 LIKE LFA1-LAND1,
ORT01 LIKE LFA1-ORT01,
SORTL LIKE LFA1-SORTL,
REGIO LIKE LFA1-REGIO,
COL TYPE LVC_T_SCOL,
END OF ITAB.
DATA:COLR TYPE LVC_S_SCOL.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
LOOP AT ITAB.
IF ITAB-LIFNR IN C_LIFNR.
COLR-FNAME = 'NAME1'.
COLR-COLOR-COL = '5'.
COLR-COLOR-INT = '1'.
COLR-COLOR-INV = '0'.
COLR-NOKEYCOL = 'X'.
APPEND COLR TO ITAB-COL.
COLR-FNAME = 'LIFNR'.
APPEND COLR TO ITAB-COL.
MODIFY ITAB.
ENDIF.
ENDLOOP.
TYPE-POOLS:SLIS.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-ZEBRA = 'X'.
layout-coltab_fieldname = 'COL'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = FCAT.
IF LIST = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ELSEIF GRID = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
TABLES
T_OUTTAB = ITAB.
ENDIF.
Plzzz dont forget to reward -
Making cells of ALV/ Table readonly
Hi,
We have some requirement in project where we have to make cells of ALV/ Table as readonly dynamically depending on the data.
As per our understanding, we can define readonly property at column level. Is it possible to do such dynamic cell level operation in ALV / Table.
If someone has some demo application for the same, please help us out in this issue.
Best Regards,
RuchiHi Ruchi.
This can be done by using cell variants. If you serach for ALV and cell variant(s) you will find some threads regarding this topic which might help you.
Cheers,
Sascha -
One editable cell in alv grid using function module
Hello all,
Any one have an idea how to make a single editable cell in alv grid using function module, i mean to say
with out using object oriented programming.
Regards,
PrakashHi,
Using ALV List display it is possible.
Try this.
TYPE-POOLS:SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:IT_EVENTS TYPE SLIS_T_EVENT.
data: begin of it_chg occurs 0,
index type sy-tabix,
end of it_chg.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
NAME(10) TYPE C,
ZTERM TYPE C,
END OF ITAB.
PERFORM FILL_TABLE.
loop at itab where zterm = 'A'.
it_chg-index = sy-tabix + 3.
" addition 3 IS FOR FIELD LABELS
append it_chg.
clear it_chg.
endloop.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
**fieldcatalog
X_FIELDCAT-FIELDNAME = 'NAME'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-FIELDNAME = 'ZTERM'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
**events
REFRESH:IT_EVENTS.
CLEAR:X_EVENTS,IT_EVENTS.
X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
X_EVENTS-FORM = 'MODIFY_LIST'.
APPEND X_EVENTS TO IT_EVENTS.
CLEAR X_EVENTS.
END-OF-SELECTION.
data lv_repid type sy-repid.
lv_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = lv_REPID
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = ITAB
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 FILL_TABLE
text
FORM FILL_TABLE.
ITAB-NAME = 'AAA'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ABC'.
ITAB-ZTERM = 'B'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'TEST'.
ITAB-ZTERM = 'C'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'BBB'.
ITAB-ZTERM = 'D'.
APPEND ITAB.
clear itab.
ITAB-NAME = '123'.
ITAB-ZTERM = 'E'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'GEN'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALV'.
ITAB-ZTERM = 'F'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALVTEST'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ENDFORM. "FILL_TABLE
*& Form MODIFY_LIST
text
FORM MODIFY_LIST.
data: l_lines type i.
describe table itab lines l_lines.
L_LINES = L_LINES + 3.
"because we have 3 lines extra occupied by lables.
"if we have header,i mean top of page add the no.of lines
"how many ever top of page have + 3 for labels.
DO L_LINES TIMES.
read table it_chg with key INDEX = sy-index.
if sy-subrc = 0.
**This code is for reading the out put line
**and modify accordinlg to our requiremnet.
**don't chnage this.
READ LINE SY-INDEX INDEX SY-LSIND.
IF SY-SUBRC = 0.
MODIFY LINE SY-INDEX INDEX SY-LSIND
FIELD FORMAT ITAB-NAME INPUT.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "MODIFY_LIST -
Edit One Cell In Alvs Based On Some Condition
Hi Experts,
My Requirement Is :
Has To *Edit one cell using alv grid *, for ex: If Netpr > 100(value). that should be in editable mode,rest of the cells in non-editable mode. pls let me know how to do it,
best answer rewarded
Reagrds,
Fareedas.Hi Fareedas,
The follow program demonstrates how to make individual fields of an ALV grid editable (NetPR greater than 10). Changes required from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this field with style attribute and adding an entry to layout control table. Also from the previous examples used on this website you will also need to change the data type of the fieldcatalog, the layout and use a different function module for displaying the report
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM build_layout.
* Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
* call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
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.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
* populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
* Populate style variable (FIELD_STYLE) with style properties
* The NETPR field/column has been set to editable in the fieldcatalog...
* The following code sets it to be disabled(display only) if 'NETPR'
* is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes
Check the above code.
For a sample code using ABAP OO check the program BCALV_EDIT_02.
Hope this helps.
Rwd points if helpful.
Thanks,
Balaji -
Hi All,
Can anyone please provide me how to make <b>BOLD</b> a particular cell in ALV list dispaly,also when downloading to excel from ALV list that particular cell should be in <b>BOLD</b>.Please help me ASAP.
Thx in advance.
SKCheck this program out !!!!
I wrote it by myself!
PROGRAM zzsidskai.
PARAMETERS :
pfrom TYPE raw4,
pto LIKE pfrom.
START-OF-SELECTION.
DATA: BEGIN OF gt_out OCCURS 0. "with header line
DATA value TYPE raw4.
DATA: celltab TYPE lvc_t_styl.
DATA: END OF gt_out.
DATA : gw_out LIKE LINE OF gt_out.
DATA : gw_cell LIKE LINE OF gw_out-celltab.
gw_out-value = pfrom.
WHILE gw_out-value <= pto.
FREE gw_out-celltab.
gw_cell-fieldname = 'VALUE'.
gw_cell-style = gw_out-value .
APPEND gw_cell TO gw_out-celltab.
gw_out-value = gw_out-value + 1.
APPEND gw_out TO gt_out.
ENDWHILE.
DATA :
gt_fc TYPE lvc_t_fcat,
g_layo TYPE lvc_s_layo.
** zzzzzsidskai build in se11 with field value type RAW4
g_layo-stylefname = 'CELLTAB'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'zzzzzsidskai'
CHANGING
ct_fieldcat = gt_fc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
is_layout_lvc = g_layo
it_fieldcat_lvc = gt_fc
TABLES
t_outtab = gt_out[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
PFROM 000000FF
PTO 0000FF00
BOLD IS THEN POSSIBLE if you put in the field style for example values from bellow!
00000121
00000122
00000123
00000124
00000125
00000126
00000127
00000128
00000129
0000012A
0000012B
0000012C
0000012D
0000012E
0000012F
00000130
00000131
run the program with small ranges because of the memory dumps in case you need to find something else
Don't forget my rewards
Maybe you are looking for
-
Tables for delivery and stock transport orders
Hi Members, I have a requirement where i have to display (in a report output) a requirement quantity of deliveries and stock transport orders which are displayed in MD04 transaction for particular material and plant. I don't know which tables these q
-
Hello, I hope everyone is doing well. I am looking for an inexpensive laptop to run any or all Adobe programs on them. I am taking classes at a local college so I can changed my life. The problem is that I have something called Fibromyalgia; which i
-
Photoshop crashing/Adobe Bridge
Photoshop CC crashed about a month ago while trying to complete a batch process from Adobe Bridge CC. Now whenever I try to open Photoshop or a PSD file, Photoshop attempts to "recover" these damaged files, it freezes up the program, as well as my co
-
IPOD Clasic (20 gig) B/W screen, Click Wheel won't connect to ITUNES
Hey, anyone have this problem or any ideas on how to fix it. I have the classic, white, 20 gig IPOD with the black & White screen and click wheel. It does everything fine, except connect to ITUNES. It has all the music previously loaded, it charges f
-
I have a standard html table in and ICE div and want my client to be able to add table rows to enter new problems reported. When in edit mode we can edit content in the existing rows, but do not seem to be able to add a new row. Suggestions? Morris