How to color particular cell while working REUSE_ALV_HIERSEQ_LIST_DISPLAY
Hi All,
I am working with REUSE_ALV_HIERSEQ_LIST_DISPLAY function module to diaplay hierarchial list. Now my requirement is to color particular cells in the output based on condition. Can any one help me in this regard.
Thanks and Regards,
Srinadh.
hi ,
try this..
* FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv, "internal table for field catalog
wa_field TYPE slis_fieldcat_alv. "work area for field catalog
* FOR LAYOUT OF ALV GRID
DATA : wa_layout TYPE slis_layout_alv. "work area for layout design
*& Form SET_LAYOUT
* SUB-ROUTINE SET_LAYOUT IS USED TO SET THE DISPLAY OF THE
* ALV GRID LINES IN ALTERNATIVE COLOURS
FORM set_layout .
wa_layout-zebra = 'X'.
ENDFORM. " SET_LAYOUT
*& Form ALV_DISPLAY
* SUB-ROUTINE ALV_DISPLAY IS USED TO SET THE PARAMETERS
* FOR THE FUNCTION MODULE REUSE_ALV_GRID_DISPLAY
* AND PASS THE INTERNAL TABLE EXISTING THE RECORDS TO BE
* DISPLAYED IN THE GRID FORMAT
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = 'SY-REPID '
* 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 =
* I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_field
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* 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
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_final
* 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. "alv_display
regards
Ritesh J
Similar Messages
-
How can I convert Pdf from RGB to CMYK, keeping font color 100% K while working in Illustrator?
When I try to open the document in Illustrator and I convert to CMYK the black font converts to rich black, but to set up for Offset printintg I need the text to be only in Black (100%K).
The original source of the document is a Microsoft Word file, I have converted the Word file to Pdf in order to setup for OFfset Printing.
ThanksI have tried that way, but the downside is that the fonts are set in gray not in a 100%K, also I have to deal with other fonts that are composites and meant to stay Full Color. I could select text by text and convert to gray but, its a 64 page document and I wouldn't want to make a expensive mistake.
-
How to color a cell based on whether its filled or not. If filled color it
Hello All,
I am into BI 7.01. I have a requirement to colour a cell(Characteristics) based on its value. How do I do that. I know it has to be handled using the Module in web template 7.01 version. Please guide me.
Thanks & regards,
RajibWhy can't you use exception for this?
-
How to protect Excel cells while allowing VBA to modify them?
I want to allow users to modify inputs in some Unlocked cells and have the other cells update accordingly. I also want to prevent users from clobbering those other cells, so those are Locked.
Protect Sheet allows ordinary formulas in Locked cells to execute but, by default, prevents VBA functions from executing when their input cells are modified. So, after consulting the
Excel 2013 developer reference's descriptions of the Worksheet.Protect method and
Worksheet object, I added these statements to my initialization routine:
Worksheets(1).Activate
ActiveSheet.Protect "", UserInterfaceOnly = True
The 2nd statement enables Protect Sheet with a null password successfully, but the UserInterfaceOnly setting isn't having the effect I expected, i.e., allowing the VBA functions to execute when their input cells are changed. (I've noticed it seems to enable
the Allow Users to Edit Objects protection option.)
I also tried := True, but that doesn't help.The function fails because you cannot change characteristics of a chart in a worksheet function. A worksheet function can only return a value to the cell that contains the formula.
You can use the Worksheet_Change event to modify the chart instead. The function can be simplified to
Function Show_RGB(Y, u, v, Swatch) As Variant
Dim R As Single, G As Single, B As Single
On Error GoTo ErrHandler
R = R_from_Yuv(Y, u, v)
G = G_from_Yuv(Y, u, v)
B = B_from_Yuv(Y, u, v)
Show_RGB = Array(R, G, B) ' Allow <0 and >255 in spreadsheet
ExitHandler:
Exit Function
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Function
The Worksheet_Change event procedure in the worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Single, G As Single, B As Single, Swatch As Integer
Dim rng As Range
On Error GoTo ErrHandler
If Not Intersect(Range("B3:D14"), Target) Is Nothing Then
Worksheets(1).Unprotect
For Each rng In Intersect(Range("B3:D14"), Target)
R = Cells(rng.Row, 5)
G = Cells(rng.Row, 6)
B = Cells(rng.Row, 7)
Swatch = rng.Row - 2
R = WorksheetFunction.Max(0, (WorksheetFunction.Min(255, R))) ' ...avoid runtime error when changing displayed color
G = WorksheetFunction.Max(0, (WorksheetFunction.Min(255, G)))
B = WorksheetFunction.Max(0, (WorksheetFunction.Min(255, B)))
With Worksheets(1).ChartObjects(6).Chart.SeriesCollection(1)
.Points(Swatch).MarkerBackgroundColor = RGB(R, G, B)
.DataLabels(Swatch).Font.Color = RGB(R, G, B)
End With
Next rng
End If
ExitHandler:
Worksheets(1).Protect
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Sub
See
https://www.dropbox.com/s/nylonrp0y86lq1c/FAA%20palette%20designer%20Beta%2002.xlsm?dl=1
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How to reduce CPU Utlisation while working with OLAP Cubes?
Hi All,
I am working on OLAP cubes on MS SQL Server 2005. I have imported the same in the OBIEE rpd and when I query it in answers, the CPU Utilisation increases to 98%.
So the results also take pretty much time to get displayed.
Is there any other method with which I can reduce the CPU usage?
Regards,
ApoorvSorry, but that's like asking "My Data Warehouse is slow! What can I do?!".
Starting from the top of the food chain it depends on:
- how your report is built
- what the logical SQL is that this report fires against the BI server
- your logical business model
- your physical model in the rpd
- whether you use BI server aggregation or external aggregation for the cube source columns
- the structure of your cube
- whether your cube is pre-aggregated or not
- whether you did any performance tuning or your cube
...and tons of other things. I can query 5 dimensions with thousands of dynamic and shared members against dynamic accounts (not stored) without performance impact if I'm hitting an optimized cube (or area of my cube) but have > 1min performance for another comparatively simple query which queries a non-aggregated cube and does aggregation within the BI server (just as an example).
Start by verifying that your cube is nicely built. -
Hello,
im trying to Color some Cells in a Webdynpro ALV.
So far i found out that there are maybe two ways:
one like this with WDUI_TABLE_CELL_DESIGN
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393
but i didnt find out, how to color specified Cells. With this example it is only possible to color the column by the saved color.
the other way is to append a color table to ich column LVC_T_SCOL
and after that
* We will set this COLOR table field name of the internal table to
* COLUMNS tab reference for the specific colors
TRY.
lo_cols_tab->set_color_column( 'T_COLOR' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
http://help-abap.blogspot.com/2008/10/salv-table-9-apply-colors.html
but i dont works in Webdynpro ALV. or has someone an idea?
i hope someone can help me.
greets,
SaschaHi ,
Check this thread, [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393]
In your case you will have to create 1 attribute ( type WDY_UIE_LIBRARY_ENUM_TYPE ) for every column. ( for eg: c1, c2, c3 ,c4 , c5 for pt1 pt2 pt3 pt4 pt5 respectively ) and bind it as follows,
*---------- Column settings
DATA: l_column_settings TYPE REF TO if_salv_wd_column_settings.
l_column_settings ?= lo_value.
* Get columns
DATA: lt_columns TYPE salv_wd_t_column_ref ,
ls_columns TYPE salv_wd_s_column_ref .
DATA: l_column_header TYPE REF TO cl_salv_wd_column_header .
lt_columns = l_column_settings->get_columns( ) .
LOOP AT lt_columns INTO ls_columns .
CASE ls_columns-id .
WHEN 'PT1' .
l_column_header = ls_columns-r_column->get_header( ) .
l_column_header->set_ddic_binding_field(
if_salv_wd_c_column_settings=>ddic_bind_none ) .
ls_columns-r_column->set_cell_design_fieldname( value = 'C1' ). "binding C1 is attribute
WHEN 'PT2' .
l_column_header = ls_columns-r_column->get_header( ) .
l_column_header->set_ddic_binding_field(
if_salv_wd_c_column_settings=>ddic_bind_none ) .
l_column_header->set_text( 'Item No' ) .
ls_columns-r_column->set_cell_design_fieldname( value = 'C2' ). " binding
........similarly continue for all the columns.
Now modify your internal table based on your condition and set the required color as follows,
LOOP AT lt_alv INTO ls_alv.
if pt1 is lowest.
ls_alv-color1 = '02'. " green
elseif pt2 is lowest.
ls_alv-color2 = '03'. "red
endif.
MODIFY lt_alv FROM ls_alv INDEX sy-tabix.
ENDLOOP.
* Bind Data to ALV
cn_alv->bind_table( lt_alv ).
Hope it helps!
Radhika. -
Color table cells depending on value of entry in row (UI5 & JSON)
Hello all,
I've stuck here a bit. There have been some discussions about how to color the cells of a table that has been bound to a JSON data model. I found some answers how to color individual cells (http://http://scn.sap.com/thread/3383698), but I have a hard time to fulfill the following requirement (rephrased for simplicity):
Given value "a" in the first cell of a table row, color the row cells 1 - 4 in blue, and 5-7 in red.
Given value "b" in the first cell of a table row, color the row cells 1 - 4 in yellow and 5-7 in green.
This wouldn't be a problem with normal HTML as I could easily assign style classes to every cell, however I can't find the solution for the UI5 table.
Any ideas?
Thanks,
ChristianHi Nishant,
not sure if I undestand you correctly.
When I scroll the table, the data scrolls with the table correctly, but in the "Last Name" column the formatting gets messed up.
To solve this, you need to remove the previously added classes:
// Approach 2
template = new sap.ui.commons.TextView().bindProperty("text", {
parts: [
{path: "***" },
{path: "lname" }
formatter: function(***, lname){
// Remove previously added classes
this.removeStyleClass("cyan").removeStyleClass("yellow");
if(*** == "m" ){
<!-- approach 2 step B : Add Css style class to element -->
this.addStyleClass("yellow");
} else if(*** == "f" )
this.addStyleClass("cyan");
return lname ;
oTable.addColumn(new sap.ui.table.Column({ label: "Last Name",
template: template,
Same for the first approach using where you have to remove the custom data instead if the class.
This should solve the problem. (By the way this is already mentioned in this thread in my post from Mar 10, 2014 11:40 AM)
Greeets,
ben -
Color a cell in ALV using CL_GUI_ALV_GRID
Hi,
How to color a cell using CL_GUI_ALV_GRID?
Thanks!Hi Ezachiael,
you dont have to trigger event DOUBLE_CLICK, it will be triggered, in case of double click :-).
You have to implent event handling class and event handler method - It is quite simple.
Check out this [Reference on SDN|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
Regards
REA -
How to color a particular cell in ALV.
hi,
I have a requirement where i need to select a particular cell of a column in ALV and upon selection , i need to change the color of the selected cell. I choose the color from the dropdown toolbar created by me.
plz help, thanks.REPORT ZTEST_DHR.
TYPE-POOLS : SLIS.
TYPES: BEGIN OF TY_MARA,
FLAG TYPE CHAR1,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
WESCH TYPE MARA-WESCH,
STYLE TYPE LVC_T_STYL,
CELLCOLR TYPE LVC_T_SCOL,
END OF TY_MARA.
DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA,
WA_MARA1 TYPE TY_MARA.
* for reuse alv grid display
*DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
* WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
* WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
* GV_REPID TYPE SY-REPID.
*for LVC Display
DATA : WA_SETTINGS TYPE LVC_S_GLAY.
DATA : WA_LAYOUT TYPE LVC_S_LAYO.
DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
WA_FIELDCATALOG TYPE LVC_S_FCAT.
DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
START-OF-SELECTION.
SELECT MATNR ERSDA ERNAM WESCH
FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
UP TO 10 ROWS.
END-OF-SELECTION.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
*& Form BUILD_FIELDCATALOG
* text
FORM BUILD_FIELDCATALOG .
WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
WA_FIELDCATALOG-OUTPUTLEN = 6.
WA_FIELDCATALOG-CHECKBOX = 'X'. "as checkbox
WA_FIELDCATALOG-EDIT = 'X'.
WA_FIELDCATALOG-SELTEXT = 'Check box'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Mat no'.
* wa_fieldcatalog-input = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
WA_FIELDCATALOG-OUTPUTLEN = 15.
WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Quantity'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
ENDFORM. "build_fieldcatalog
*& Form BUILD_LAYOUT
* text
FORM BUILD_LAYOUT .
CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
* WA_LAYOUT-NO_INPUT = LC_X.
WA_LAYOUT-CWIDTH_OPT = LC_X.
WA_LAYOUT-ZEBRA = LC_X.
WA_LAYOUT-STYLEFNAME = 'STYLE'.
WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* text
FORM DISPLAY_ALV_REPORT .
LS_EDIT-FIELDNAME = 'FLAG'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
LS_CELL_COLOR-FNAME = 'MATNR'.
LS_CELL_COLOR-COLOR-COL = '7'.
LS_CELL_COLOR-COLOR-INT = '1'.
INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
LOOP AT IT_MARA INTO WA_MARA.
IF WA_MARA-ERSDA EQ '20080625'.
MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
I_CALLBACK_USER_COMMAND = 'F_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 = 'Example of select and deselect'
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCATALOG
TABLES
T_OUTTAB = IT_MARA
* 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.
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = GV_REPID
* I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
* I_GRID_TITLE = 'Example of select and deselect'
* I_GRID_SETTINGS = WA_SETTINGS
* IS_LAYOUT = WA_LAYOUT
* IT_FIELDCAT = IT_FIELDCATALOG[]
* TABLES
* T_OUTTAB = IT_MARA.
* 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 f_set_status
* text
FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STATUS1'.
ENDFORM. " f_set_status
*& Form f_user_command
* text
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
* BREAK-POINT.
CASE R_UCOMM.
WHEN 'ASEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = 'X'.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DSEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = ' '.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DELETE'.
* BREAK-POINT.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
DELETE IT_MARA
WHERE FLAG = 'X'.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'INSERT'.
CLEAR WA_MARA.
APPEND WA_MARA TO IT_MARA.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
WHEN 'SAVEDB'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
* CODE TO BE WRITTEN TO SAVE in DB just an insert statement
*ENDLOOP.
ENDCASE.
ENDFORM.
REPORT ZTEST_DHR.
TYPE-POOLS : SLIS.
TYPES: BEGIN OF TY_MARA,
FLAG TYPE CHAR1,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
WESCH TYPE MARA-WESCH,
STYLE TYPE LVC_T_STYL,
CELLCOLR TYPE LVC_T_SCOL,
END OF TY_MARA.
DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA,
WA_MARA1 TYPE TY_MARA.
* for reuse alv grid display
*DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
* WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
* WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
* GV_REPID TYPE SY-REPID.
*for LVC Display
DATA : WA_SETTINGS TYPE LVC_S_GLAY.
DATA : WA_LAYOUT TYPE LVC_S_LAYO.
DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
WA_FIELDCATALOG TYPE LVC_S_FCAT.
DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
START-OF-SELECTION.
SELECT MATNR ERSDA ERNAM WESCH
FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
UP TO 10 ROWS.
END-OF-SELECTION.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
*& Form BUILD_FIELDCATALOG
* text
FORM BUILD_FIELDCATALOG .
WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
WA_FIELDCATALOG-OUTPUTLEN = 6.
WA_FIELDCATALOG-CHECKBOX = 'X'. "as checkbox
WA_FIELDCATALOG-EDIT = 'X'.
WA_FIELDCATALOG-SELTEXT = 'Check box'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Mat no'.
* wa_fieldcatalog-input = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
WA_FIELDCATALOG-OUTPUTLEN = 15.
WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
WA_FIELDCATALOG-OUTPUTLEN = 20.
WA_FIELDCATALOG-SELTEXT = 'Quantity'.
* wa_fieldcatalog-input = 'X'.
* wa_fieldcatalog-edit = 'X'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CLEAR WA_FIELDCATALOG.
ENDFORM. "build_fieldcatalog
*& Form BUILD_LAYOUT
* text
FORM BUILD_LAYOUT .
CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
* WA_LAYOUT-NO_INPUT = LC_X.
WA_LAYOUT-CWIDTH_OPT = LC_X.
WA_LAYOUT-ZEBRA = LC_X.
WA_LAYOUT-STYLEFNAME = 'STYLE'.
WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* text
FORM DISPLAY_ALV_REPORT .
LS_EDIT-FIELDNAME = 'FLAG'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
LS_CELL_COLOR-FNAME = 'MATNR'.
LS_CELL_COLOR-COLOR-COL = '7'.
LS_CELL_COLOR-COLOR-INT = '1'.
INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
LOOP AT IT_MARA INTO WA_MARA.
IF WA_MARA-ERSDA EQ '20080625'.
MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
I_CALLBACK_USER_COMMAND = 'F_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 = 'Example of select and deselect'
* I_GRID_SETTINGS =
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCATALOG
TABLES
T_OUTTAB = IT_MARA
* 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.
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = GV_REPID
* I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
* I_GRID_TITLE = 'Example of select and deselect'
* I_GRID_SETTINGS = WA_SETTINGS
* IS_LAYOUT = WA_LAYOUT
* IT_FIELDCAT = IT_FIELDCATALOG[]
* TABLES
* T_OUTTAB = IT_MARA.
* 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 f_set_status
* text
FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STATUS1'.
ENDFORM. " f_set_status
*& Form f_user_command
* text
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
* BREAK-POINT.
CASE R_UCOMM.
WHEN 'ASEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = 'X'.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DSEL'.
LOOP AT IT_MARA INTO WA_MARA.
WA_MARA-FLAG = ' '.
MODIFY IT_MARA FROM WA_MARA.
ENDLOOP.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'DELETE'.
* BREAK-POINT.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
DELETE IT_MARA
WHERE FLAG = 'X'.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'INSERT'.
CLEAR WA_MARA.
APPEND WA_MARA TO IT_MARA.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
WHEN 'SAVEDB'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
* CODE TO BE WRITTEN TO SAVE in DB just an insert statement
*ENDLOOP.
ENDCASE.
ENDFORM.
About Selecting a Color From Dropdown? even i need to check for now this is the how u do cell color in alv -
How to select a color of cell in REUSE_ALV_HIERSEQ_LIST_DISPLAY
Hi.
I need to select a color of a cell in REUSE_ALV_HIERSEQ_LIST_DISPLAY.
I have found an example, but
It shows how to select a color of sell in REUSE_ALV_LIST_DISPLAY.
Can you give me an example of code?
Thanks.Here ia a simple example of the method how to paint a cell / line / column using REUSE_ALV_HIERSEQ_LIST_DISPLAY function.
Programm: zalv_hierseq_color
Paint a line, a colomn, or a cell
using REUSE_ALV_HIERSEQ_LIST_DISPLAY
Victor Stupin, Russia 2009
REPORT zalv_hierseq_color.
TABLES: spfli.
TYPE-POOLS: slis.
SELECTION-SCREEN BEGIN OF BLOCK rad1.
PARAMETERS:
p_row TYPE i,
p_col TYPE i.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /1(50) comm1.
SELECTION-SCREEN COMMENT /1(50) comm2.
SELECTION-SCREEN COMMENT /1(50) comm3.
SELECTION-SCREEN END OF BLOCK rad1.
INITIALIZATION.
comm1 = 'Paint a line: fill ONLY p_row (p_col is empty)'.
comm2 = 'Paint a colomn: fill ONLY p_col (r_row is empty)'.
comm3 = 'Paint a cell: fill P_COL and R_ROW'.
DATA:
t_fieldcat TYPE slis_t_fieldcat_alv,
fs_fieldcat LIKE LINE OF t_fieldcat,
fs_layout TYPE slis_layout_alv ,
w_color(4) ,
w_row TYPE i,
w_fieldname(20),
w_prog TYPE sy-repid.
DATA:
BEGIN OF t_spfli OCCURS 0,
color(4),
checkbox ,
cell TYPE slis_t_specialcol_alv,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distance TYPE spfli-distance,
keyln TYPE int4,
box TYPE char1,
lineno TYPE int4,
END OF t_spfli.
DATA:
fs_cell LIKE LINE OF t_spfli-cell.
DATA: gt_item LIKE TABLE OF t_spfli WITH HEADER LINE,
gt_header LIKE TABLE OF t_spfli WITH HEADER LINE,
gs_keyinfo TYPE slis_keyinfo_alv.
START-OF-SELECTION.
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE t_spfli.
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 1.
fs_fieldcat-tabname = 'GT_HEADER'.
fs_fieldcat-fieldname = 'CARRID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 2.
fs_fieldcat-tabname = 'GT_HEADER'.
fs_fieldcat-fieldname = 'CONNID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 3.
fs_fieldcat-tabname = 'GT_HEADER'.
fs_fieldcat-fieldname = 'DISTANCE'.
fs_fieldcat-key = ' '.
fs_fieldcat-edit = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 4.
fs_fieldcat-tabname = 'GT_HEADER'.
fs_fieldcat-fieldname = 'CITYFROM'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = ' '.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 5.
fs_fieldcat-tabname = 'GT_ITEM'.
fs_fieldcat-fieldname = 'CARRID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat .
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 6.
fs_fieldcat-tabname = 'GT_ITEM'.
fs_fieldcat-fieldname = 'CONNID'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = 'X'.
fs_fieldcat-hotspot = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 7.
fs_fieldcat-tabname = 'GT_ITEM'.
fs_fieldcat-fieldname = 'DISTANCE'.
fs_fieldcat-key = ' '.
fs_fieldcat-edit = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
fs_fieldcat-row_pos = 1.
fs_fieldcat-col_pos = 8.
fs_fieldcat-tabname = 'GT_ITEM'.
fs_fieldcat-fieldname = 'CITYFROM'.
fs_fieldcat-ref_tabname = 'SPFLI'.
fs_fieldcat-key = ' '.
APPEND fs_fieldcat TO t_fieldcat.
p_col = p_col + 4.
LOOP AT t_fieldcat INTO fs_fieldcat WHERE tabname = 'GT_ITEM'.
IF fs_fieldcat-col_pos EQ p_col.
fs_fieldcat-emphasize = 'C600'.
w_fieldname = fs_fieldcat-fieldname.
IF p_row IS INITIAL AND p_col GT 0. " <---- paint only column if p_row is empty
MODIFY t_fieldcat FROM fs_fieldcat TRANSPORTING emphasize.
ENDIF.
ENDIF.
ENDLOOP.
fs_cell-fieldname = w_fieldname .
fs_cell-color-col = 6.
fs_cell-nokeycol = 'X'.
APPEND fs_cell TO t_spfli-cell.
IF p_row IS NOT INITIAL AND p_col IS NOT INITIAL. " <---- paint a cell
MODIFY t_spfli INDEX p_row TRANSPORTING cell.
ENDIF.
fs_layout-info_fieldname = 'COLOR'.
fs_layout-coltab_fieldname = 'CELL'.
fs_layout-f2code = '&ETA'.
gs_keyinfo-header01 = 'KEYLN'.
gs_keyinfo-item01 = 'KEYLN'.
LOOP AT t_spfli INTO gt_item.
gt_item-keyln = 1.
gt_item-lineno = gt_item-lineno + 1.
APPEND gt_item.
ENDLOOP.
READ TABLE t_spfli INDEX 1 INTO gt_header.
gt_header-keyln = 1.
gt_header-lineno = 0.
APPEND gt_header.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = t_fieldcat
i_tabname_header = 'GT_HEADER'
i_tabname_item = 'GT_ITEM'
is_keyinfo = gs_keyinfo
TABLES
t_outtab_header = gt_header
t_outtab_item = gt_item
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. -
How to print the row ,column,and particular cell in separate color
how to print the row ,column,and particular cell in separate color IN ALV GRID
HI,
Here you go good program links
<a href="http://www.sapfans.com/forums/viewtopic.php?t=52107">How to Set Color to a Cell in AVL</a>
<a href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm">ALV Grid Coloring</a>
Thanks
Mahesh -
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 paint a Custom Cell while you are editing on adjacent Cell in JTabl
Hi All,
I have two Columns in my Custom Table . Both Two Columns are Custom Cell Editors/Renderers.
I have made UI such that Column1 is Label , Column 2 is TextBox / Combo/ UI Input any
My Custom Table View when i edit some value against Max Conn. it should display Blue
=================================
Column A | Column B
==================================
Timeout | some_unchanged_value
*{color:#0000ff}Session{color}* | some_unchanged_value
Log File | some_unchanged_value
===================================
My issue is when i start typing in my Custom Editor suppose i Type /invoke Edtir of Index 2, Column 2 font should become Blue.
It becomes blue only when i debug this issue it perfectly works, without Debugger it doesnt changes the Font
MyDefaultRenderer is my Custom renderer - I have set Foregroud Color as BLUE
NOTE:_
In run method if table.repaint() instead of single renderer:
It turns Blue when i make call on table.repaint() methosd but i feel that repainting full table on every key Stroke should not be very good programming. Whats is more appropriate way?
I want to repaint only that particular cell against which i change the Value
private class MyDefaultEditor extends AbstractCellEditor implements TableCellEditor {
private JTextField txtField = null;
private int rowIndex;
public MyDefaultEditor() {
txtField = new JTextField();
txtField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
super.keyTyped(e);
System.out.println("########### Hello This is MyDefaultEditor");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Call Renderer adjacentt to input to turn Blue (Is this Valid Code ??)
MyDefaultRenderer defRen = (MyDefaultRenderer) thisTable.getCellRenderer(activeRowIndex, 0);
defRen.paintMe();
// table.repaint() works for me but i dont want to call it on evey ket type, that will be Heave rite???
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
rowIndex = row;
String valStr = "";
if (value != null && value instanceof String) {
valStr = value.toString();
txtField.repaint();
return txtField;
public Object getCellEditorValue() {
return txtField.getText();
}Edited by: Shubhadeep on Jun 27, 2009 1:58 AM
Edited by: Shubhadeep on Jun 27, 2009 2:01 AM
Edited by: Shubhadeep on Jun 27, 2009 2:06 AM
Edited by: Shubhadeep on Jun 27, 2009 2:12 AMWell, I think you need to add a custom renderer to the first column. The renderer would check if the table.isEditing(). If it is and the editing is done on the same row, then you set the font color blue, otherwise you use the default font color.
Then the next question is how do you repaint the cell. Well you can use the table.repaint(Rectangle) method. You can get the Rectangle to repaint by using the table.getCellRect(...) method.
Finally, you need to know when to repaint the cell. Well a PropertyChangeEvent is fired when a cell starts and stops editing. So you only need to handle these events. Don't use a KeyListener. The PropertyChangeListener you add to the table might be something like:
public void propertyChange(PropertyChangeEvent e)
if ("tableCellEditor".equals(e.getPropertyName()))
if (table.isEditing())
processEditingStarted();
else
processEditingStopped();
}So when editing is started you need to determine the "adjacent" cell you want to repaint to the blue font is used. You would save the cell Rectangle so you can restore the font when editing is stopped. -
How to color a particular row in a matrix
Hi All,
Using SBO, i am having two queries:
1. Is it possible to color single row, Cell in a matrix or a grid by any way.
2. And How to copy particular row from 1 matrix to another?. I want this by using drag n drop event of mouse. Only click and right click mouse events are available in SBO. But I want to use mouse down and mouse up events..Please help me, it's urgent.
Thanks in advance.Hi,
1) No, unfortunately, you cannot colour either a row or a single cell in the current versions of the matrix and grid controls. As a workaround, I use an image column as the first column in my matrices and then put coloured squares in this column for rows that I want to 'highlight'.
2) You can't drag and drop using the SBO controls. Personally, I use the right-click event and add a menu option to copy the selected rows to the other matrix and it works fine. Click is the Mouse Down event and Item Pressed is the Mouse Up but it is not fully supported on matrices or grids.
Kind Regards,
Owen -
ALV color a particular cell on meeting certain condition
hi all
i am working with ALV , my requirement is to color a particular cell if condition mate.
like .
i have two fields in my ITAB PlanedCost and ActualCost
If ACTUALCOST is >= 80% of PLANEDCOST then
ACTUALCOST cell must come in RED COLOR.
how to do so .
please guide me.Hi Rock,
I tried a program to color a cell based on its value, but it is not working. Am pasting the code below and please can u exactly tell me what is the problem it.
*& Report ZSAPCOLV
REPORT zsapcolv.
TABLES:mara.
TYPES:BEGIN OF ty_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
color1(4),
END OF ty_mara.
DATA:it_mara TYPE STANDARD TABLE OF ty_mara,
it_color TYPE TABLE OF lvc_s_scol,
wa_mara TYPE ty_mara,
wa_color TYPE lvc_s_scol,
is_layout TYPE lvc_s_layo.
DATA: t_newtable TYPE REF TO data,
t_newline TYPE REF TO data.
FIELD-SYMBOLS: <dyntab> TYPE STANDARD TABLE,
<wa_dyntab> TYPE ANY,
<gfs_wa> TYPE ANY.
TYPES: BEGIN OF ty_cmara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
tabcolor TYPE lvc_t_scol,
END OF ty_cmara. " Cell color
DATA:it_cmara TYPE STANDARD TABLE OF ty_cmara.
DATA:
gr_table TYPE REF TO cl_salv_table,
gr_functions TYPE REF TO cl_salv_functions,
gr_display TYPE REF TO cl_salv_display_settings.
DATA: it_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat.
DATA:it_fcat1 TYPE lvc_t_fcat, "with cell color
it_fcat2 TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF it_fcat1,
wa_cellcolors TYPE lvc_s_scol,
wa_is_layout TYPE lvc_s_layo.
FIELD-SYMBOLS:<t_cellcolors> TYPE lvc_t_scol,
<w_field> TYPE ANY.
DATA:t_line TYPE REF TO data .
*-----design selection screen for plant and material type.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.
SELECT-OPTIONS:
s_matnr FOR mara-matnr. "material type
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM fetch_data.
PERFORM display_data.
*& Form fetch_data
FORM fetch_data .
DATA:wa_cmara TYPE ty_cmara.
DATA: ls_tabcolor TYPE lvc_s_scol.
SELECT
FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_mara WHERE matnr IN s_matnr.
CHECK sy-subrc EQ 0.
PERFORM build_catalog USING '1' 'MATNR' 'Material number' 'Material Number' ' ' '18'.
PERFORM build_catalog USING '1' 'MTART' 'Material type' 'Material type' ' ' '10'.
it_fcat1[] = it_fcat[].
wa_fieldcat-fieldname = 'T_CELLCOLORS'.
wa_fieldcat-ref_field = 'COLTAB'.
wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
APPEND wa_fieldcat TO it_fcat.
cl_alv_table_create=>create_dynamic_table( EXPORTING it_fieldcatalog = it_fcat
IMPORTING ep_table = t_newtable ).
ASSIGN t_newtable->* TO <dyntab>.
CREATE DATA t_line LIKE LINE OF <dyntab>.
ASSIGN t_line->* TO <gfs_wa>.
PERFORM fill_data.
ENDFORM. " fetch_data
*& Form build_catalog
FORM build_catalog USING p_pos TYPE lvc_colpos
p_field TYPE lvc_fname
p_reptext TYPE reptext
p_coltext TYPE coltext
p_check TYPE lvc_checkb
p_len TYPE lvc_outlen.
wa_fcat-col_pos = p_pos.
wa_fcat-fieldname = p_field.
wa_fcat-reptext = p_reptext.
wa_fcat-checkbox = p_check.
wa_fcat-outputlen = p_len.
wa_fcat-emphasize = '6'.
IF p_check = 'X'.
wa_fcat-edit = 'X'.
ENDIF.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " catalog
*& Form fill_data
FORM fill_data .
FIELD-SYMBOLS: <wa_tmp> TYPE ANY,
<v_fld> TYPE ANY,
<color> TYPE ANY,
<wa_color> TYPE lvc_s_scol.
DATA: v_fld(20).
DATA : lv_cnt TYPE i,
t_newline1 type ref to data,
lv_cnt1 TYPE i.
FIELD-SYMBOLS: <ta_color> TYPE lvc_t_scol.
DATA : field(15) TYPE c,
col TYPE lvc_s_scol.
create data t_newline1 LIKE <wa_color>.
LOOP AT it_mara INTO wa_mara.
lv_cnt1 = lv_cnt1 + 1.
LOOP AT it_fcat INTO wa_fcat.
UNASSIGN <wa_tmp>.
ASSIGN COMPONENT wa_fcat-fieldname OF STRUCTURE <gfs_wa> TO <wa_tmp>.
CONCATENATE 'WA_MARA-' wa_fcat-fieldname INTO v_fld.
ASSIGN (v_fld) TO <v_fld>.
CHECK sy-subrc EQ 0.
IF <v_fld> = '000000000000000004'.
col-fname = wa_fcat-fieldname.
col-color-col = '5' .
col-color-int = '0' .
"ASSIGN COMPONENT wa_fcat-fieldname OF STRUCTURE <gfs_wa> TO <ta_color>.
ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <gfs_wa> TO <ta_color> .
APPEND col TO <ta_color>.
<wa_tmp> = <v_fld>.
lv_cnt = lv_cnt + 1.
ENDIF.
IF lv_cnt = 1.
APPEND <gfs_wa> TO <dyntab>.
ELSE.
MODIFY <dyntab> INDEX lv_cnt1 FROM <gfs_wa>.
ENDIF.
ENDLOOP.
lv_cnt = 0.
CLEAR wa_mara.
ENDLOOP.
ENDFORM. " fill_data
*& Form display_data
FORM display_data .
IF <dyntab> IS NOT INITIAL.
LOOP AT <dyntab> INTO <gfs_wa>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gfs_wa> TO <w_field>.
ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <gfs_wa> TO <t_cellcolors> .
CLEAR wa_cellcolors.
"wa_cellcolors-fname = 'MATNR'.
"IF <w_field> = '000000000000000004'.
"FORMAT INTENSIFIED COLOR = 6.
wa_cellcolors-fname = 'MATNR'.
wa_cellcolors-color-col = '7'.
wa_cellcolors-color-int = '1'.
"wa_cellcolors-color-inv = '1'.
"wa_cellcolors-NOKEYCOL = ''.
"ELSE.
"wa_cellcolors-color-col = '5'.
"ENDIF.
APPEND wa_cellcolors TO <t_cellcolors>.
MODIFY <dyntab> FROM <gfs_wa>.
ENDLOOP.
cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = <dyntab> ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'MARA DATA' ).
gr_table->display( ).
"ENDIF.
ENDFORM. " display_data
Maybe you are looking for
-
I have a program, astrodatabank, that I have been using since 2005 or so. The program ran well on Windows XP and Vista operating systems. I tried to load it into my desktop, which runs on the latest verison of Ubuntu. If I try to install from the dis
-
I have been using firefox to access bridgebase.com but all of a sudden as soon as I log in to that website, it says the connection is lost. It doesn't do that on my laptop, only on this desktop. Can you help?
-
How to merge photos in photo booth
how to merge photos in photo booth that they will be un one photo
-
I have come across certain pdf forms which when opened in acrobat X pro could not be edited as the edit button is disabled. Doubting it to be a XFA form I opened it in live cycle but it ask me to import the form as it was not originally created in L
-
QuickSilver 2002 G4 (933MHz) OS 9
I have OS 9.2.2 installed however it really is not friendly with many of my midi/audio/video programs: e.g. Emagic Silver will just freeze somewhere between startup or loading a midi/audio file. I want to install OS 9.1 on an external firewire drive