Set color alv output cell abap webdynpro
Hi Guys ,
i wanted to set the color of some cells in alv output to red in ABAP WebDynpro.
i am using the salv_wd_table.
any piece of code is appreciated.
thanks,
Bobby.
Bobby,
If let's say you are build a ALV table to output 'SFLIGHT' table, and you want PLANETYPE '747-400' to be displayed in green, and PLANETYPE '146-200' displayed in red.
Also, let's just say, you already had a context node 'SFLIGHT_NODE' that is mapped to the external node 'DATA' of your ALV.
Now:
1. you need to modify the context node 'SFLIGHT_NODE' to add an attribute -- say 'CELL_COLOR' of type 'WDY_UIE_LIBRARY_ENUM_TYPE' -- to the SFLIGHT_NODE (note, you need to delete 'DICTIONARY structure' that is bind to the 'SFLIGHT_NODE' node, otherwise, you will not be able to create addition attributes)
After, you will have something like this for your context node .
CONTEXT
--> SFLIGHT_NODE
> CARRID
> CONNID
> FLDATE
> PRICE
> PLANETYPE
> <and any other attributes you had pulled from SFLIGHT)
> CELL_COLOR (TYPE WDY_UIE_LIBRARY_ENUM_TYPE)
2. In your supply function to the 'SFLIGHT_NODE', you now need to supply the data to this newly added attribute:
METHOD supply_sflight_node .
** data declaration
DATA:
itab_sflight_node TYPE if_componentcontroller=>elements_sflight_node,
stru_sflight_node LIKE LINE OF itab_sflight_node.
** read sflight data
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE itab_sflight_node.
** populate the 'CELL_COLOR' field
LOOP AT itab_sflight_node INTO stru_sflight_node .
IF stru_sflight_node-planetype = '747-400'.
stru_sflight_node-cell_color = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_DARK .
ELSEIF stru_sflight_node-planetype = '146-200'.
stru_sflight_node-cell_color = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_DARK .
ELSE.
stru_sflight_node-cell_color = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-STANDARD .
ENDIF.
modify itab_sflight_node from stru_sflight_node.
ENDLOOP.
** bind all the elements
node->bind_table(
new_items = itab_sflight_node
set_initial_elements = abap_true ).
ENDMETHOD.
3. Now, you need to obtain the configuration model of the ALV and config it before display. (say you have an method does this 'init_alv_table_settings', and it is called from your view's wddoinit() method)
METHOD init_alv_table_settings .
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv_table( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
l_ref_interfacecontroller = wd_this->wd_cpifc_alv_table( ).
DATA:
node_sflight_node TYPE REF TO if_wd_context_node .
node_sflight_node = wd_context->get_child_node( name = if_flights_view=>wdctx_sflight_node ).
CALL METHOD l_ref_interfacecontroller->set_data
EXPORTING
r_node_data = node_sflight_node.
** get ConfigurationModel from ALV Component
DATA: lr_table TYPE REF TO cl_salv_wd_config_table.
lr_table = l_ref_interfacecontroller->get_model( ).
** change the color of the cell
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA: lr_column TYPE REF TO cl_salv_wd_column.
lr_column_settings ?= lr_table.
lr_column = lr_column_settings->get_column( 'PLANETYPE' ).
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'PLANETYPE'.
lr_column->set_cell_editor( lr_input_field ).
lr_column->set_cell_design_fieldname( value = 'CELL_COLOR' ).
ENDMETHOD.
Compile and activate your code.
Regards,
Tina Yang
Message was edited by: Tina Yang
Similar Messages
-
Download colored ALV output in to EXCEL sheet
Hi ,
I want to download colored ALV output to Excel sheet with color.
one of the field in ALV is with 4 colors depending on condition.
i am unable to download the color using download option(that field is comming with out color).
Please help me by providing the solution.
Thanks in advance.
Regards
sarathHi Srini,
thanks for the reply.
i am using standard download function only.
if i use download->local file->HTML Format only the font is appearing in colors.in case of spread sheet no color comming.
but my requirement is to download into excel and background also with color(green...) font in black like that.
(exactly appearing in the ALV)
Thanks
sarath -
Display Smartform Pdf output in ABAP Webdynpro application
Hello,
there is a solution for displaying Smartform output in Java Webdynpro application in this forum. Since i want to start an project in ABAP Webdynpro i need a solution for this technology since i don't want to recreate all the paperwork again using Adobe. Is there any solution available?
Thanks
Udo AhleHello,
this is the solution which i was able to implement using the hints given by Heidi and Thomas. Thank you for the support. With this solution it is possible to reuse oldstyle sapscripts and smartforms in todays environment. Here is the sample code which solves the problem:
In WDA you define for example a pushbutton to start the display of the PDF.
In the onaction method you implement:
method ONACTIONSHOW_PDF .
data LX_pdf type xstring.
* get PDF from existing sapscript or smatform
call function 'Y_PDF_GET' destination '46c'
IMPORTING
ex_PDF = LX_PDF.
* append the pdf to the response
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'Hello.PDF'
i_content = lx_pdf
i_mime_type = 'application/pdf'
i_in_new_window = 'X'
i_inplace = 'X' ).
endmethod.
The function 'Y_PDF_GET' is implemented as follows:
FUNCTION Y_PDF_GET .
*"*"Local interface:
*" EXPORTING
*" VALUE(EX_PDF) TYPE XSTRING
*" TABLES
*" ET_OTF STRUCTURE ITCOO OPTIONAL
data: lf_filesize type i,
lt_otf type table of ITCOO,
lt_lines type table of tline,
tline type tline.
* start sapscript or smatforms and return
perform make_otf.
CALL FUNCTION 'READ_OTF_FROM_MEMORY'
TABLES
OTF = lt_otf
EXCEPTIONS
MEMORY_EMPTY = 1
OTHERS = 2
et_otf[] = lt_otf.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
IMPORTING
BIN_FILESIZE = lf_filesize
TABLES
OTF = lt_otf
LINES = lt_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 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.
* convert tline to xstring as needed in
* in web dynpro
field-symbols <X>.
data: st(268) type c.
data l1 type i.
data len type i.
data maxline type i value 134.
l1 = 0.
loop AT lt_lines INTO tline.
clear st.
st+l1(maxline) = tline.
len = maxline + l1.
l1 = maxline - strlen( tline ).
ASSIGN st TO <x> TYPE 'X'.
CONCATENATE ex_pdf <x>(len) INTO ex_pdf.
endloop.
ENDFUNCTION.
The make_otf for sapscript is the following:
* the next attribute enables the otf output.
* no other output will be generated
<b>options-TDGETOTF = 'X'</b>
CALL FUNCTION 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX = ARCHIVE_INDEX
ARCHIVE_PARAMS = ARCHIVE_PARAMS
DEVICE = DEVICE
DIALOG = ' '
FORM = FORM
LANGUAGE = language
OPTIONS = OPTIONS
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
OTHERS = 6.
*... make some write forms
data lT_OTF type table of ITCOO.
* get the otf data
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RESULT = result
TABLES
OTFDATA = lt_otf
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.
* put otf into memory for later usage
if not lt_otf is initial.
CALL FUNCTION 'SAVE_OTF_TO_MEMORY'
* EXPORTING
* MEMORY_KEY = 'DEF_OTF_MEMORY_KEY'
TABLES
OTF = lt_otf.
endif.
For Smartforms technology it is possible to implement the same concept. -
Set color of specific cells in JTable.
I have a JTable where I want to set the color for specific cells. Is this possible to do, and if so, how?
Well, one way is to create a custom renderer that know the background color of each cell in the table. The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer]How to Use Table has an example you might be able to build on.
Or, this posting may give you another approach. The key to both solutions is to somehow specify the color for every cell:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474 -
How to create a context menu in ALV table cell editor(Webdynpro abap )
Hello Experts,
I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
The code snippet below:
"Create menu for each coloumn
create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
id = 'MITM_ACTIONS'.
lo_menu_actions->set_visible( value = abap_true ).
lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
"ADd menu items
CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
exporting
id = 'MITM_CREATE_EXPRESSION'.
lo_menu_item_create->set_visible( value = abap_true ).
lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
"Add item 1
lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ).
" Set the cell editor for each column cell(link to an action)
LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
lv_column_name = ls_node_dec_tab_cols-object_name.
lr_column = lr_column_settings->get_column( lv_column_name ).
"Create 'lta' Ui item
CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
lo_lta->set_menu( value = lo_menu_actions ).
lo_lta->set_text_fieldname( lv_column_name ).
lr_column->set_cell_editor( lo_lta ).
IF ls_node_dec_tab_cols-is_result EQ abap_true.
lr_column->set_cell_design( value =
cl_wd_table_column=>e_cell_design-key_medium ).
ENDIF.
ENDLOOP.Hi Prakash,
I have not come across this requirement till now to have context menu in a cell editor of alv.
Unfortunately the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
Regards,
Rama -
Merge of Cells in ALV table in ABAP webdynpro.
Hi All,
We have a requirement to merge cells vertically if the consecutive cells have same data.(The merge of cells happens when we click on sort of a column.) This functionality needs to be achived with out sorting the cells.Sorted data is populated in the ALV table.
I will be greatfull if any one can help us on this issue.
Thanks in advance
Regards,
SharathHi Sarath,
Check this..
http://help.sap.com/saphelp_nw70ehp2/helpdata/en/9b/46bb0d339b42cc8d30636ca0c9f5b6/frameset.htm
and go through this..
merging cells in table
http://forums.sdn.sap.com/click.jspa?searchID=71460300&messageID=9768692
cheers,
Kris.
Edited by: kissnas on Apr 18, 2011 12:10 PM -
Calling smartform and displaying ALV grid in ABAP WEBDYNPRO
Hi all,
I am new to ABAP web dynpro.I ahve few custom reports which are simple ALV list reports which I now need to convert to ABAP web dynpro application .
For one particular report,based on the selection screen input,I need to display the ALV list and when I select the records from the ALV list,I need to call a smartform on clik of a push button.
My questions:
1. Im using 'REUSE_ALV_GRID_DISPLAY' FM to display the o/p in my report.Is there any similar FM in webdynpro ABAP which will display my list in ALV GRID in my web dynpro application??/
2. How to call a smartfrm in ALV grid in web dynpro??
Edited by: abap_1000 on Jan 9, 2011 6:09 PMHi,
You can search SDN, there are several posts available. Just to get some idea, you can check --
[Beginneru00B4s questions on WDA ALV;
[Reg ALV Display;
For clicking event on ALV --
[Reg Row Data fetching on click in ALV;
For ALV display on WDA --
[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110?quicklink=index&overridelayout=true]
Thanks.
Kumar Saurav. -
How to process Line Selection on ALV Table in ABAP WebDynpro
Hi there,
I have a view with an ALV table whose context node retrieves its data from a Service Call for a method.
The method provides certain data of a database table which the ALV displays.
Now I would like to be able to select one row of that ALV table and after pressing a button or doubleclicking on the row or whatever a different view (as for me it is also ok on the same view) should appear to display the details of that selection.
I only need to know how to retrieve the selected data.
Or its index within the internal table.
I am already looking for hours for a useful thread and actually there is one which obviously is about a similar issue apart from the multiple selection part:
How to process multiple row selection in ALV table in Wendynpro ABAP? Help!
but i am afraid that i don't understand it. Or at least I misunderstand it since it does not work with me.
The system example mentioned in the thread does not help me either because it somehow does not correspond to my needs, does it?
It would be GREAT if somebody could help me with that. Please keep it simple for I am not an expert in webdynpro yet (obviously ^^) and also please explain in detail what I have to do with the context nodes since I am not sure whether the selection is stored in my already existing node or whether I need a special one for that.
Thanks!!
christinaHi Christina,
If you just want to get one column data of the line that user clicked, use the Web Dynpro Code Wizard to Read Context of attibute you needed, then you will get code as follow:
* Define data for read attribute
node_alv TYPE REF TO if_wd_context_node,
elem_alv TYPE REF TO if_wd_context_element,
stru_alv TYPE if_view_display=>element_alv ,
item_column_name LIKE stru_alv-column_name.
* navigate from <CONTEXT> to <ALV> via lead selection
node_alv = wd_context->get_child_node( name = if_view_display=>wdctx_alv ).
* get element via lead selection
elem_alv = node_alv->get_element( ).
* get single attribute
elem_alv->get_attribute(
EXPORTING
name = `COLUMN_NAME'
IMPORTING
value = item_column_name ).
The value of column_name is stored in item_column_name.
If you need the index that the user clicked, try this:
* Definition of field symbol for index
FIELD-SYMBOLS : <fs_index> TYPE data.
* Get the selected index
ASSIGN r_param->index->* TO <fs_index>.
The index of clicked line is stored in field symbol <fs_index>.
Hope it will help.
Best Regards,
Stephanie -
Select Options use in ALV Report in ABAP Webdynpro
Hello Experts,
I Already Done ALV Report In webdynpro with use of view Container UI element.But i do not know ALV report with help of select option.so
Kindly Give Me simple Example of Use in select Option In ALV.
Reply ASAP.
Regards,
Ameya KaradkhedkarFirst you need to add the component WDR_SELECT_OPTIONS to the tab "Used components" of your Web Dynpro component and then also in the properties tab of your view. In the layout you need to create another view container and embed the view WND_SELECTION_SCREEN of the new used component to it.
Then in the WDDOINIT method of your view you can write this code (where SEL_OPT is the given name for the used component) in order to set the select option (This example is a select option for a date):
DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage,
lo_interfacecontroller TYPE REF TO iwci_wdr_select_options,
lo_r_helper_class TYPE REF TO if_wd_select_options,
rt_range_date TYPE REF TO data.
* Instantiate used component WDR_SELECT_OPTIONS (SEL_OPT)
lo_cmp_usage = wd_this->wd_cpuse_sel_opt( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
* Call method in used controller
lo_interfacecontroller = wd_this->wd_cpifc_sel_opt( ).
lo_r_helper_class = lo_interfacecontroller->init_selection_screen( ).
* Create select option for the date
CALL METHOD lo_r_helper_class->create_range_table
EXPORTING
i_typename = 'DATS'
RECEIVING
rt_range_table = rt_range_date.
CALL METHOD lo_r_helper_class->add_selection_field
EXPORTING
i_id = 'DATS'
it_result = rt_range_date
i_read_only = ABAP_FALSE.
* Hide unnecessary buttons
CALL METHOD lo_r_helper_class->set_global_options
EXPORTING
i_display_btn_cancel = abap_false
i_display_btn_check = abap_false
i_display_btn_reset = abap_false
i_display_btn_execute = abap_false.
Finally you need to write the following code in the action of the button in order to fetch the range table selected by the user.
DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage,
lo_interfacecontroller TYPE REF TO iwci_wdr_select_options,
lo_r_helper_class TYPE REF TO if_wd_select_options,
rt_date TYPE REF TO data.
FIELD-SYMBOLS: <fs_date> TYPE table.
* Instantiate used component WDR_SELECT_OPTIONS (SEL_OPT)
lo_cmp_usage = wd_this->wd_cpuse_sel_opt( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
* Call method in used controller
lo_interfacecontroller = wd_this->wd_cpifc_sel_opt( ).
lo_r_helper_class = lo_interfacecontroller->init_selection_screen( ).
* get selected range of inspections date
CALL METHOD lo_r_helper_class->get_range_table_of_sel_field
EXPORTING
i_id = 'DATS'
RECEIVING
rt_range_table = rt_date.
ASSIGN rt_date->* TO <fs_date>.
Then you can use the value that is assigned to the field symbol <fs_date> to continue with your ALV. -
Hi,
I'd like to access particular cell properties in cfgrid to
change its' background color. I know how to change whole row color
or column color but I'm interested in changing only one cell.
Thanks in advance
CMYou can probably do it with a bit of ActionScript.
I did a bit of googling and found an example of someone altering the way cells are rendered here:
http://www.asfusion.com/blog/entry/using-labelfunction-to-format-cfgrid
Not quite what you want, byut it points to using ActionScript to effect these sorts of things.
I'm sure if you do a bit of googling you can turn up more info.
Adam -
Sorting issue in ALV ABAP webdynpro
Hi All,
We are displaying the data in ALV format using ABAP webdynpro.
The issue here is sorting the values. The field is the character field, as the field may contain character or numberic values.
When we sort a set of values in ascending order, the values are sorted wrongly.
Example values sorted in ascending order:
11055
11260
5662
8697
9984
The above values are sorted wrongly. Is this a standard limitation of webdynpro ABAP or do we have any support class or setting available to solve this issue.
Please help.
Regards,
VijayHello Vijay
of course its not a limitation, you can sort it either ways.
Check the following link
http://help.sap.com/saphelp_nw70/helpdata/en/e9/e5eb40c4f8712ae10000000a155106/content.htm
you can use the following classes
Set sort Direction -
CL_SALV_SORTS meth: ADD_SORT (Parameter SEQUENCE)
CL_SALV_SORT meth: SET_SEQUENCE
Get sort direction
CL_SALV_SORT meth: GET_SEQUENCE
hope this helps!!
Regards
Senon -
Web Dynpro for ABAP alv table cell color
Hello,
I have a question about Web Dynpro for ABAP and ALV. I want to change the color of one cell as yellow. how to do it??in that method possible colors are
cellDesign: badvalue_dark
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_DARK
cellDesign: badvalue_light
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_LIGHT
cellDesign: badvalue_medium
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_MEDIUM
cellDesign: criticalvalue_dark
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_DARK
cellDesign: criticalvalue_light
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_LIGHT
cellDesign: criticalvalue_medium
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_MEDIUM
cellDesign: goodvalue_dark
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_DARK
cellDesign: goodvalue_light
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_LIGHT
cellDesign: goodvalue_medium
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_MEDIUM
cellDesign: group_level1
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GROUP_LEVEL1
cellDesign: group_level2
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GROUP_LEVEL2
cellDesign: group_level3
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GROUP_LEVEL3
cellDesign: key_medium
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-KEY_MEDIUM
cellDesign: negative
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-NEGATIVE
cellDesign: positive
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-POSITIVE
cellDesign: standard
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-STANDARD
not able to set column color as yellow.... -
Hi All,
I want to produce a report in ALV , where I have to print two diff colors in a cell..
Eg: In a cell 128(38)
128( ) in black and 38 in red.
Thanks in advance.
Balamurugan.Rhi,
see the below example which may be useful.
types: begin of ty_vbak,
Vbeln type vbeln_va,
erdat type erdat,
ernam type ernam,
cellcolors type lvc_t_scol, " table type for cell coloring
cellstyles TYPE lvc_t_styl, " table type for Style Table for Cells
end of ty_vbak.
data: t_vbak type table of ty_vbak,
w_vbak type ty_vbak.
data: gt_fieldcat type lvc_t_fcat,
gs_fieldcat like line of gt_fieldcat,
gw_layout type lvc_s_layo.
Reference to Custom container
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_CONTAINER TYPE SCRFNAME VALUE 'CC_ALV',
G_GRID TYPE REF TO CL_GUI_ALV_GRID,
*& Module STATUS_0001 OUTPUT
text
MODULE STATUS_0001 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
PARENT =
CONTAINER_NAME = G_CONTAINER
STYLE =
LIFETIME = LIFETIME_DEFAULT
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT G_GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = G_CUSTOM_CONTAINER
I_APPL_EVENTS = SPACE
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
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.
perform populate_data.
perform fieldcat.
perform populate_layout.
perform display_output.
ENDMODULE. " STATUS_0001 OUTPUT
*& Form populate_data
populating the data
--> p1 text
<-- p2 text
FORM populate_data .
data: color(1) type c.
DATA lw_cellcolor TYPE lvc_s_scol . "line type for cell coloring
select vbeln
erdat
ernam from vbak into CORRESPONDING FIELDS OF TABLE t_vbak up to 10 rows.
*coloring the particular cell.
READ TABLE t_vbak INTO w_vbak INDEX 5 .
lw_cellcolor-fname = 'ERDAT' .
lw_cellcolor-color-col = '4' .
lw_cellcolor-color-int = '1' .
APPEND lw_cellcolor TO w_vbak-cellcolors .
modify t_vbak index 5 from w_vbak.
READ TABLE t_vbak INTO w_vbak INDEX 7.
lw_cellcolor-fname = 'ERNAM' .
lw_cellcolor-color-col = '7' .
lw_cellcolor-color-int = '1' .
APPEND lw_cellcolor TO w_vbak-cellcolors .
modify t_vbak index 7 from w_vbak.
ENDFORM. " populate_data
*& Form fieldcat
populatin the fieldcat
--> p1 text
<-- p2 text
FORM fieldcat .
clear gs_fieldcat.
gs_fieldcat-fieldname = 'VBELN'.
gs_fieldcat-tabname = 'T_VBAk'.
gs_fieldcat-outputlen = '20'.
gs_fieldcat-SCRTEXT_M = 'DOCUMENT NUMBER'.
append gs_fieldcat to GT_fieldcat.
clear gs_fieldcat.
gs_fieldcat-fieldname = 'ERDAT'.
gs_fieldcat-tabname = 'T_VBAK'.
gs_fieldcat-outputlen = '20'.
gs_fieldcat-SCRTEXT_M = 'CREATED ON'.
append gs_fieldcat to GT_fieldcat.
clear gs_fieldcat.
gs_fieldcat-fieldname = 'ERNAM'.
gs_fieldcat-tabname = 'T_VBAK'.
gs_fieldcat-outputlen = '20'.
gs_fieldcat-SCRTEXT_M = 'CREATED BY'.
append gs_fieldcat to GT_fieldcat.
ENDFORM. " fieldcat
*& Form display_output
text
--> p1 text
<-- p2 text
FORM display_output .
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = gw_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = * IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = t_vbak
IT_FIELDCATALOG = GT_fieldcat
IT_SORT =
IT_FILTER =
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.
*& Form populate_layout
populating the layout
<--P_GW_LAYOUT internal table for the layput
FORM populate_layout." CHANGING P_GW_LAYOUT type lvc_s_layo.
gw_layout-zebra = 'X'.
gw_layout-ctab_fname = 'CELLCOLORS'. "cell coloring
*gw_layout-info_fname = 'ROW_COLOR'. "row coloring
gw_layout-stylefname = 'CELLSTYLES'. "styles
ENDFORM. " populate_layout
thanks and regards -
Display Color for sigle CELL in ALV report
Hi all,
I have one doubt is it possible to make a particular cell as read color in ALV.
Ex: I have one field which shows amount in my ALV report,My requirement is that when ever the amount is less then 'ZERO', I have to show that particular cell in read color.
Regards
Anil Kumar.Nhi,
here code for coloring a perticular cell
TYPE-POOLS:slis.
TABLES:mara,
makt,
marc.
DATA:BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
werks LIKE marc-werks,
mtart LIKE mara-mtart,
matkl LIKE mara-matkl,
meins LIKE mara-meins,
ntgew LIKE mara-ntgew,
rowcolor(4) TYPE c,
cellcolors TYPE lvc_t_scol,
END OF itab.
DATA:t_fcat TYPE slis_t_fieldcat_alv,
t_eve TYPE slis_t_event.
DATA : st_layout TYPE slis_layout_alv.
SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:mat FOR mara-matnr. " no intervals no-extension.
*PARAMETERS:mat LIKE mara-matnr.
SELECTION-SCREEN:END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_cata USING t_fcat.
PERFORM build_event.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM display_data.
*& Form build_cata
text
-->TEMP_FCAT text
FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.
sy-tvar0 = sy-uname.
WRITE sy-datum TO sy-tvar1.
DATA:wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Description'.
wa_fcat-fix_column = 'x'.
wa_fcat-key = 'X'. "To color a column
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
wa_fcat-key = ' '.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MTART'.
wa_fcat-seltext_m = 'Type'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-seltext_m = 'Group'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-seltext_m = 'Measurement Unit'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'NTGEW'.
wa_fcat-seltext_m = 'Net Value'.
APPEND wa_fcat TO temp_fcat.
ENDFORM. "build_cata
*& Form build_event
text
FORM build_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
list_type_wrong = 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. "build_event
*& Form data_retrieval
text
FORM data_retrieval.
SELECT maramatnr maramtart maramatkl marameins mara~ntgew
maktmaktx marcwerks
INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara INNER JOIN makt ON
maramatnr = maktmatnr
INNER JOIN marc ON
maramatnr = marcmatnr
WHERE mara~matnr IN mat.
SORT itab BY matnr.
DELETE ADJACENT DUPLICATES FROM itab.
ENDFORM. "data_retrieval
*& Form display_data
text
FORM display_data.
*******************************For setting Cell Color*******************************************
DATA ls_cellcolor TYPE lvc_s_scol .
st_layout-coltab_fieldname = 'CELLCOLORS'.
READ TABLE itab INDEX 5 .
ls_cellcolor-fname = 'MATNR' .
ls_cellcolor-color-col = '1' .
ls_cellcolor-color-int = '1' .
APPEND ls_cellcolor TO itab-cellcolors .
MODIFY itab INDEX 5 .
st_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_DS'
is_layout = st_layout
i_save = 'A'
it_fieldcat = t_fcat
it_events = t_eve
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.
ENDFORM. "display_data
Please reward if useful... -
ABAP WebDynpro: Handling the ON_ENTER Event in editable ALVs
Sub: ABAP WebDynpro : Handling the ON_ENTER Event in editable ALVs
Hi,
I would like to know if there exists an event to handle TABout (i.e, when user navigates out of the cell with a TAB key-press) for a cell of an editable ALV.
Alternatively, any help on how to handle ON_ENTER event and how it is triggered when data is entered by user into a cell of an editable ALV, would be really appreciated.
Thanks,
AdithyaHi
I had one similar problem where user enter something into the editable cell and press enter. to handle this scenario i used WDDOBEFOREACTION method of my view to call alv interface method check_data.
if there is any change in the any table cell, it will fire an event on_data_check..which has paramater column name, row index and new and old value of the cell.
you can handle this event and write your business logic in event handler method.
hope it will help
Regards
Saurabh Garg
Maybe you are looking for
-
Phone line and BB connection keeps dropping - BT H...
My broadband and phone connection keeps dropping. Its been fine for years and now since all this bad weather we have been having the connection lasts temporarily for a few minutes sometimes more and then all the blue lights start flashing orange, so
-
IPhone 2.0 Update let down on original iPhone!!!
APPLE, YOU HAVE TO BE KIDDING ME!!! HAS ANYONE NOT NOTICED THAT THE SPEAKER VOLUME FOR YOUR IPOD ON THE ORIGINAL IPHONE HAS GOTTEN MUCH MUCH LOWER? I NOW HAVE TO PUT MY EAR UP TO IT TO LISTEN TO THE SONG! WOW, IT IS SOOOO LOW? AM I ALONE? SO ANNOYING
-
Remove 'export to pdf' option from Webi in R3
Hi We would like to disable the option of saving a Webi report to PDF in R3. i.e DOCUMENT>SAVE TO MY COMPUTER AS> PDF should not appear How can we do this? rgds Asim
-
Xsd:complexType with extension and unordered (sometimes not all) elements
Hello, I have a schema definition that I need to change. I have the following BASE (from which I extend) elements Entity and Record Info, and I have a Quote element that extends from entity. Some times a Quote (title, context, quoted, written) will h
-
Mavericks toolbar icons missing, time and date as well
The time and date, wifi and other icons are missing from the toolbar. Other icons are missing from the finder window and the dismiss and minimize icons are missing from all windows. I have tried to delete the com.apple.systemuiserver.plist file and