Set specific rows in ALV grid ready for input
Hi everyone,
I have a question about how to set specific rows in ALV grid ready for input.
I know that I can make some columns ready for input before the ALV displayed,but I have no idea how to make specific rows displayed in the ALV ready for input.
Hello Aaron
For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.
The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:
*§1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0. "with header line
include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_outtab[].
Note: in the sample report only field SEATSMAX is editable. In your case you need
to fill CELLTAB for all fields in a row.
*§2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
LOOP AT gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
if gt_outtab-seatsmax ge 300.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX l_index.
ENDLOOP.
ENDFORM. " SELECT_DATA_AND_INIT_STYLE
NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the
INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended
to the CELLTAB itab).
IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
Regards
Uwe
Similar Messages
-
Cl_salv_table - How to set grid ready for input
Hi,
I am using the class "cl_salv_table" on a 6.40 system to display an ALV grid. How can I set the grid cells are ready for input/editing?
( Something similar to slis_layout_alv-edit parameter
use in the REUSE_ALV_GRID_DISPLAY function )
I have looked at the demo programs SALV_TEST_TABLE* and
SALV_DEMO_TABLE*. Unless I am blind I cannot find a way.
Any suggestions?
Lukas
Message was edited by: van vuuren lukasHi,
thanks for the reply,
I do not call the SET_TABLE_FOR_FIRST_DISPLAY,
as far as I can tell SALV does not require this.
Here is in short what my program looks like:
data: lr_salvgrid type ref to cl_salv_table,
lr_columns type ref to cl_salv_columns_table,
lr_column type ref to cl_salv_column,
gt_matdoc type mb_mkpf.
I call method cl_salv_table=>factory to get a reference to my itab:
call method cl_salv_table=>factory
exporting
list_display = if_salv_c_bool_sap=>false
importing
r_salv_table = lr_salvgrid
changing
t_table = gt_matdoc.
Then for fieldcatalogue:
i.e. hide columns etc
lr_columns = lr_salvgrid->get_columns( ).
lr_columns->set_optimize( abap_true ).
lr_column = lr_columns->get_column( 'MANDT' ).
lr_column->set_visible( abap_false ).
Then to display:
lr_salvgrid->display( ).
I would have thought that the edit parameter would be somewhere in the fieldcat ( in class CL_SALV_COLUMN )
but I cannot find it there. Everything else like text/edit mask/currency/visible etc is here but not edit. -
Color a specific row in ALV GRID display when user clicks on that row
hi
i have the entire code ready of how to check the line selected by the user and also to color that line but after settings those parameters
for to refresh the GRID so that the row apppears coloured .plz reply soon.... points will be awarded.....
wat i have done is
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND'
is_layout = it_layout
it_fieldcat = int_fieldcat
TABLES
t_outtab = int
EXCEPTIONS
program_error = 1
OTHERS = 2.
to display the GRID then when user clicks on any row this module gets called
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE int INDEX rs_selfield-tabindex.
int-rowcolor = 'C410'.
MODIFY int INDEX rs_selfield-tabindex TRANSPORTING rowcolor.
it_layout-info_fieldname = 'ROWCOLOR'.
then again i call 'REUSE_ALV_GRID_DISPLAY'
to display the GRID with the user selected line colored . the problem with this is when u go back from this screen u go to the previously displayed grid ....... whihc i dont want .....
ENDFORM. "user_commandHi,
By using following code,you can set the colors for each row,
Change this based on your requirement.
TABLES VBAK.
TYPE-POOLS SLIS.
Data Declaration
TYPES: BEGIN OF T_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
AUDAT TYPE VBAK-AUDAT,
VBTYP TYPE VBAK-VBTYP,
NETWR TYPE VBAK-NETWR,
VKORG TYPE VBAK-VKORG,
VKGRP TYPE VBAK-VKGRP,
LINE_COLOR(4) TYPE C,
END OF T_VBAK.
DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
WA_VBAK TYPE T_VBAK.
ALV Data Declaration
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID TYPE SY-REPID.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BLD_FLDCAT.
PERFORM BLD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
Build Field Catalog for ALV Report
FORM BLD_FLDCAT.
FLDCAT-FIELDNAME = 'VBELN'.
FLDCAT-SELTEXT_M = 'Sales Document'.
FLDCAT-COL_POS = 0.
*FLDCAT-EMPHASIZE = 'C411'.
FLDCAT-OUTPUTLEN = 20.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERDAT'.
FLDCAT-SELTEXT_L = 'Record Date created'.
FLDCAT-COL_POS = 1.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERNAM'.
FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'AUDAT'.
FLDCAT-SELTEXT_M = 'Document Date'.
FLDCAT-COL_POS = 3.
FLDCAT-EMPHASIZE = 'C110'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VBTYP'.
FLDCAT-SELTEXT_L = 'SD Document category'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'NETWR'.
FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.
FLDCAT-COL_POS = 5.
FLDCAT-OUTPUTLEN = 60.
FLDCAT-DO_SUM = 'X'.
FLDCAT-DATATYPE = 'CURR'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKORG'.
FLDCAT-SELTEXT_L = 'Sales Organization'.
FLDCAT-COL_POS = 6.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKGRP'.
FLDCAT-SELTEXT_M = 'Sales Group'.
FLDCAT-COL_POS = 7.
FLDCAT-EMPHASIZE = 'C801'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
ENDFORM.
Build Layout for ALV Grid Report
FORM BLD_LAYOUT.
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
GD_LAYOUT-CONFIRMATION_PROMPT = 'X'. This asks the confirmation before leaving the screen.
ENDFORM.
Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
IS_LAYOUT = GD_LAYOUT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'SALES DOCUMENT HEADER'
IT_FIELDCAT = FLDCAT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_VBAK
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.
Retrieve data from VBAK table and populate itab IT_VBAK
FORM DATA_RETRIEVAL.
DATA LD_COLOR(1) TYPE C.
SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG
UP TO 20 ROWS
FROM VBAK
INTO TABLE IT_VBAK.
LOOP AT IT_VBAK INTO WA_VBAK.
LD_COLOR = LD_COLOR + 1.
IF LD_COLOR = 8.
LD_COLOR = 1.
ENDIF.
CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.
MODIFY IT_VBAK FROM WA_VBAK.
ENDLOOP.
ENDFORM.
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER.
W_HEADER-TYP = 'H'.
W_HEADER-INFO = 'WELCOME HEADER LIST'.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'REPORT:'.
W_HEADER-INFO = SY-REPID.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'DATE:'.
CONCATENATE SY-DATUM6(2) ' / ' SY-DATUM4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
ENDFORM.
Reward points,if it is useful.
Thanks,
chandu. -
PrePositioning Scroll to a specific Row in ALV Grid
I have an object of type cl_gui_alv_grid which is about to display, let's say, 200 rows.
I want it to come up pre-scrolled down to say row 80 - any ideas ?
I still want 200 rows available.
Any ideas (via a public method) ?
Is there an option that can be passed through set_table_for_first_display() ?
...MikeHi,
try SET_SCROLL_INFO* methods of CL_GUI_ALV_GRID.
Regards,
Przemysław -
Deactivate the double click/ hot spot for a particular row in alv grid.
Hello,
As per a certain condition how to deactivate the double click/ hot spot for a particular row in alv grid.
Regards,
Sarojwhere u define layout there is a field hotspot.like
data: var.
if con is true
var = 'X'. (show hotspot)
else.
var = ' '. (deactive hotspot)
elseif ws_fieldcat-fieldname = 'DMBTR'
AND ws_fieldcat-tabname = 'T_MTAB'.
ws_fieldcat-do_sum = C_X.
<b>ws_fieldcat-hotsopts = var.</b>
MODIFY Wt_fieldcat FROM ws_fieldcat
TRANSPORTING DO_SUM.
It is helpful for u. if any problen send me ur coding i will change it.
Regards
Manish Kumar -
How to change a color for a row in ALV grid display
Hi,
how to change a color for a row in ALV grid display based on a condition.Any sample code plzHello Ramya,
Did you check in [SCN|How to color a row of alv grid]
Thanks! -
Add row to ALV grid highlighting mandatory fields
hello experts,
I am using grid object of cl_gui_alv_grid to display output table. Rows can be added to grid using Insert Row button of ALV toolbar (No custom button added here). The requirement is to highlight the mandatory input cells either with border or display them in different color.
This needs to be done immediatly after pressing the Insert row button, but before the row is displayed on the screen as ready for input ( NOT as a part of data validation on save or enter button).
I tried following method:
- I SET HANDLER event_receiver->handle_user_command FOR obj_grid.
- I am handling EVENT before_user_command OF cl_gui_alv_grid
- I thought of modifying CELLTAB of inserted row in this event to set display properties of required entry fields
However, the problem I am facing here is, Insert_Row button directly populates a row on display screen without triggering before_user_command event.
Is there any way I can highlight the cells of inserted row when it's populated on screen?Hi,
Indeed this event is not triggered for some standard function. Anyhow you could do some trick:
- hide standard insert row button
- add custom button with same icon on in
- then once you press it, you will be able to hanlde it in before_user_commnad event
If you want to stick to standard solution. maybe there is some flag which must be set with some SET.. or REGISTER... method. Unfortunatelly I am not aware of such switch.
Regards
Marcin -
Multiple Input Rows In ALV Grid (Editable)
Hi,
I have an editable ALV grid and need to have multiple blank rows ready for input. Something similar to what happens when you click the "New Entries" button in SM30 (Table Maintainance).
There is a local function for appending lines in the ALV grid toolbar but this only allows a single entry.
I have replaced the local function with my own button (same icon etc) and on user_command event, I am appending several blank lines to my output table.
However these lines are not being shown on the screen. I have looked through the layout and field catalog but there is no field to allow blank lines to be shown.
My 2 questions are:
1. Is there some standard way of entering multiple entries in ALV Grid Editable.
2. If not then how to allow blank lines to be shown as ready for input.
Also if someone could suggest a way to do error checking for all entries on the screen especially duplicate entries I will be extremely grateful.
Many Thanks,
PreetHi, Preet!
You can easily do whatever checks you wish. You should declare an event handling method for event DATA_CHANGED and call the ADD_PROTOCOL_ENTRY method of the ER_DATA_CHANGED event parameter (it's an object of the class CL_ALV_CHANGED_DATA_PROTOCOL). You must not forget to set handler for your ALV grid.
For example, this piece of code checks for all changed fields resulting in error message if they are initial. In short, this makes all the fields obligatory.
METHODS: on_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
SET HANDLER your_object->on_data_changed FOR your_alv_grid.
METHOD on_data_changed.
DATA: s_mod_cell TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_mod_cells INTO s_mod_cell.
IF s_mod_cell-value IS INITIAL.
* issue message 'Make an entry in all required fields'
CALL METHOD er_data_changed->add_protocol_entry
EXPORTING i_msgid = '00'
i_msgno = '055'
i_msgty = 'E'
i_fieldname = s_mod_cell-fieldname
i_row_id = s_mod_cell-row_id.
ENDIF.
ENDMETHOD.
Furthermore, if you make your class inherited from CL_GUI_ALV_GRID you can make use of protected attribute MT_OUTTAB which is a data object referencing your output table. Then you can have:
FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
ASSIGN me->mt_outtab->* TO <outtab>.
* do whatever you want with <outtab>
Hope this helps.
Kind regards,
Igor
P.S. Regarding the blank lines that you need, what's wrong with standard ALV grid buttons "Append row" and "Insert row" which appear whenever the grid is editable (unless you deliberately remove them)? They work just fine with me (just like on SM30). I don't see reason for programatically appending lines to your internal table. -
Coloring of a (specific) row in ALV report-How?
Hi Experts,
Am looking to assign a color for a (specific)row in ALV report.......so, pls. let me know How to get it done?
thanqTABLES: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.
Reward points if useful. -
Hi my friends,
I have written a small ALV Grid where some rows should be colored, dependend on their status in a table. But it's not working and I can't find out, why it is not working. I've already studied all the topics in this forum, which are related to 'row color alv grid', but I can't find the mistake in my code. Is anyone able to find out what is wrong here?
Thanks a lot for your help!
*& Report /BMC_TST_SHOWLOG
REPORT /BMC_TST_SHOWLOG.
TYPES: BEGIN OF log_table.
TYPES: log_level TYPE /bmc_log_message,
cr_date TYPE /bmc_cr_date,
message TYPE /bmc_log_message,
linecolor(4) TYPE c.
TYPES: END OF log_table.
DATA: lt_log TYPE TABLE OF log_table with HEADER LINE,
lt_log2 TYPE TABLE OF log_table with HEADER LINE,
lt_log_list TYPE TABLE OF log_table,
lt_line LIKE LINE OF lt_log_list,
container_r TYPE REF TO cl_gui_custom_container,
grid_r TYPE REF TO cl_gui_alv_grid,
gc_custom_control_name TYPE scrfname VALUE 'CONTAINER_LOG',
fieldcat_r TYPE lvc_t_fcat,
layout_r TYPE lvc_s_layo,
logA TYPE /bmc_log_level,
logB TYPE /bmc_log_level,
logC TYPE /bmc_log_level,
logD TYPE /bmc_log_level,
logE TYPE /bmc_log_level,
ls_ct TYPE lvc_s_scol,
ok_code LIKE sy-ucomm.
*DATA BEGIN OF ls_log_list OCCURS 0.
*DATA: log_level TYPE /bmc_log_message,
* cr_date TYPE /bmc_cr_date,
* message TYPE /bmc_log_message,
* rowcolor(4) TYPE c.
*DATA END OF ls_log_list.
*DATA: lt_log_list TYPE TABLE OF log_table.
PARAMETERS: loglevlA TYPE c AS CHECKBOX,
loglevlB TYPE c as CHECKBOX,
loglevlC TYPE c As CHECKBOX,
loglevlD TYPE c aS CHECKBOX,
loglevlE TYPE c AS CHECKBOX,
dateA TYPE /bmc_cr_date OBLIGATORY,
dateB TYPE /bmc_cr_date.
CALL SCREEN 0200.
MODULE user_command_0200 INPUT.
CASE ok_code.
WHEN 'BACK'.
SET SCREEN 0.
MESSAGE ID 'BC400' TYPE 'S' NUMBER '057'.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
MODULE clear_ok_code OUTPUT.
CLEAR ok_code.
ENDMODULE.
MODULE status_0200 OUTPUT.
SET PF-STATUS 'DYNPRO200'.
SET TITLEBAR 'D0200'.
ENDMODULE.
MODULE display_alv OUTPUT.
PERFORM display_alv.
ENDMODULE.
FORM display_alv.
IF grid_r IS INITIAL.
*----Creating custom container instance
CREATE OBJECT container_r
EXPORTING
container_name = gc_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Creating ALV Grid instance
CREATE OBJECT grid_r
EXPORTING
i_parent = container_r
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
PERFORM get_log_data.
*----Preparing field catalog.
PERFORM prepare_field_catalog CHANGING fieldcat_r.
*----Preparing layout structure
PERFORM prepare_layout CHANGING layout_r.
*----Here will be additional preparations
*--e.g. initial sorting criteria, initial filtering criteria, excluding
*--functions
CALL METHOD grid_r->set_table_for_first_display
EXPORTING
is_layout = layout_r
CHANGING
it_outtab = lt_log2[]
it_fieldcatalog = fieldcat_r
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ELSE.
CALL METHOD grid_r->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ENDIF.
CALL METHOD grid_r->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD grid_r->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDFORM.
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = '/BMC_LOG'
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc ne 0.
*--Exception handling
ENDIF.
LOOP AT pt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'UUID'.
ls_fcat-no_out = 'X'.
MODIFY pt_fieldcat FROM ls_fcat.
WHEN 'LOG_LEVEL'.
ls_fcat-coltext = 'Meldungsart'.
ls_fcat-outputlen = '25'.
MODIFY pt_fieldcat FROM ls_fcat.
WHEN 'CR_DATE'.
ls_fcat-coltext = 'Erstellungsdatum'.
ls_fcat-outputlen = '20'.
MODIFY pt_fieldcat FROM ls_fcat.
WHEN 'CR_TIME'.
ls_fcat-no_out = 'X'.
MODIFY pt_fieldcat FROM ls_fcat.
WHEN 'MESSAGE'.
ls_fcat-coltext = 'Nachricht'.
ls_fcat-outputlen = '50'.
MODIFY pt_fieldcat FROM ls_fcat.
ENDCASE.
* CASE ls_fcat-value.
* WHEN '1'.
* ls_fcat-line_color = 'c100'.
* ENDCASE.
ENDLOOP.
ENDFORM.
FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
ps_layout-zebra = 'X'.
ps_layout-grid_title = 'Log'.
ps_layout-smalltitle = 'X'.
ps_layout-info_fname = 'linecolor'.
ENDFORM.
FORM get_log_data.
if loglevlA = 'X'.
logA = '1'.
ENDIF.
if loglevlB = 'X'.
logB = '2'.
ENDIF.
if loglevlC = 'X'.
logC = '3'.
ENDIF.
if loglevlD = 'X'.
logD = '4'.
ENDIF.
if loglevlE = 'X'.
logE = '5'.
ENDIF.
IF dateB ne 0.
SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA and cr_date <= dateB.
ELSE.
SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA.
ENDIF.
* and cr_date >= dateA.
SORT lt_log_list ASCENDING.
LOOP AT lt_log_list INTO lt_line.
IF lt_line-log_level = '1'.
lt_line-log_level = 'Info'.
lt_line-linecolor = 'C100'.
ENDIF.
IF lt_line-log_level = '2'.
lt_line-log_level = 'Warning'.
lt_line-linecolor = 'C200'.
ENDIF.
IF lt_line-log_level = '3'.
lt_line-log_level = 'Error'.
lt_line-linecolor = 'C300'.
ENDIF.
IF lt_line-log_level = '4'.
lt_line-log_level = 'Debug'.
lt_line-linecolor = 'C400'.
ENDIF.
IF lt_line-log_level = '5'.
lt_line-log_level = 'Trace'.
lt_line-linecolor = 'C500'.
ENDIF.
APPEND lt_line TO lt_log2.
ENDLOOP.
ENDFORM.
SELECTION-SCREEN BEGIN OF SCREEN 0100 TITLE text-001 AS WINDOW.
SELECTION-SCREEN END OF SCREEN 0100.> change to this
>
> <b>ps_layout-stylefname = 'LINECOLOR'.</b>
>
> sorry ignore the above line
>
> just debug and check what is happening
>
> Message was edited by:
> Chandrasekhar Jagarlamudi
Hi,
I've changed the line to <b>ps_layout-stylefname = 'LINECOLOR'.</b>, but then I'm getting a runtime error 'ASSIGN_TYPE_CONFLICT' in program 'SAPLSLVC in line 2975'...
I don't have any idea what is causing that. -
Displaying the selected rows in ALV Grid output
Hi Experts,
I am developing one interactive ALV Grid report where user can process the selected records/rows from the ALV Grid output.
for displaying the ALV Grid, I have used the class CL_GUI_ALV_GRID class. I am working on ECC 6.0 system.
when I select any records/rows from output and then press any Application Toolbar button, PAI and then PBO modules of the screen gets executed as per the normal flow.
however After PBO, when same ALV output comes, all the selected/highlighted rows appear as unselected, that means I want to retain the ALV
rows selection during the round trip.
please advise.
Regards,
JageshHi,
Feiyun Wu is correct.
Get_selected_rows and set_selected_rows are the methods to be used .
Some code:
Note the sequence of code:
FORM set_gui_alv_grid_1 .
DATA: wa_layout TYPE lvc_s_layo ,
wa_print TYPE lvc_s_prnt .
DATA: it_sort TYPE lvc_t_sort ,
wa_sort TYPE LINE OF lvc_t_sort .
DATA: it_fieldcatalog TYPE lvc_t_fcat.
IF gui_custom_container_1 IS INITIAL .
CREATE OBJECT gui_custom_container_1
EXPORTING
container_name = 'GUI_CUSTOM_CONTAINER_1'
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.
ENDIF.
PERFORM get_field_catalog
USING gc_log_group_1
CHANGING it_fieldcatalog .
CREATE OBJECT gui_alv_grid_1
EXPORTING i_parent = gui_custom_container_1.
CREATE OBJECT ob_event_receiver_1
EXPORTING log_group = gc_log_group_1 .
* registers the event handlers
SET HANDLER ob_event_receiver_1->handle_toolbar FOR gui_alv_grid_1 .
SET HANDLER ob_event_receiver_1->handle_user_command FOR gui_alv_grid_1 .
SET HANDLER ob_event_receiver_1->print_top_of_page FOR gui_alv_grid_1 .
SET HANDLER ob_event_receiver_1->hotspot_click FOR gui_alv_grid_1 .
wa_layout-cwidth_opt = abap_true .
* wa_layout-excp_fname = gc_excp_fname .
* wa_layout-ctab_fname = gc_ctab_fname.
* wa_layout-excp_led = abap_true .
CALL METHOD gui_alv_grid_1->set_table_for_first_display
EXPORTING
is_layout = wa_layout
is_print = wa_print
i_save = 'A'
is_variant = gs_disvariant_1
CHANGING
it_sort = it_sort
it_fieldcatalog = it_fieldcatalog
it_outtab = it_alv_grid_1.
ELSE .
CALL METHOD gui_alv_grid_1->refresh_table_display.
* Restore selections
CALL METHOD gui_alv_grid_1->set_selected_rows
EXPORTING
it_index_rows = ob_event_receiver_1->it_rows.
* Restore position
CALL METHOD gui_alv_grid_1->set_scroll_info_via_id
EXPORTING
is_col_info = ob_event_receiver_1->wa_col
is_row_no = ob_event_receiver_1->wa_roid.
ENDIF.
ENDFORM . "set_gui_alv_grid_1
Regards. -
How to transpose rows to columns and columns to rows in alv grid
can u plz tell me in alv grid how to
display data from itab having data
1
2
3 and so on
how to print in alv in a single row ie
1 2 3 and so onchk this code...
REPORT Z_TRANSPOSEALV .
* Type pools declaration for ALV
TYPE-POOLS: slis.
*Declarations for ALV, dynamic table and col no for transpose
DATA: l_col TYPE sy-tabix,
l_structure TYPE REF TO data,
l_dyntable TYPE REF TO data,
wa_lvc_cat TYPE lvc_s_fcat,
lt_lvc_cat TYPE lvc_t_fcat,
lt_fieldcatalogue TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_layout TYPE slis_layout_alv.
*Field symbols declarations
FIELD-SYMBOLS :
<header> TYPE ANY,
<dynheader> TYPE ANY,
<dyndata> TYPE ANY,
<ls_table> TYPE ANY,
<dynamictable> TYPE STANDARD TABLE,
<it_table> TYPE STANDARD TABLE.
*Input the name of the table
PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY.
*Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
* Create internal table of dynamic type
CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN l_dyntable->* TO <it_table>.
*select statement to select data from the table as input into
*our dynamic internal table.
*Here i have restricted only till 5 rows.
*You can set a variable and give no of rows to be fetched
*The variable can be set in your select statement
SELECT * INTO CORRESPONDING FIELDS OF TABLE <it_table>
FROM (p_table) up to 5 rows.
*Fieldcatalogue definitions
wa_lvc_cat-fieldname = 'COLUMNTEXT'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.
wa_fieldcat-fieldname = 'COLUMNTEXT'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
wa_fieldcat-key = 'X'..
APPEND wa_fieldcat TO lt_fieldcat.
DESCRIBE TABLE <it_table>.
DO sy-tfill TIMES.
* For each line, a column 'VALUEx' is created in the fieldcatalog
* Build Fieldcatalog
WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.
CONCATENATE 'VALUE' wa_lvc_cat-fieldname
INTO wa_lvc_cat-fieldname.
wa_lvc_cat-ref_field = 'VALUE'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.
* Build Fieldcatalog
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = wa_lvc_cat-fieldname.
wa_fieldcat-ref_fieldname = 'VALUE'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
APPEND wa_fieldcat TO lt_fieldcat.
ENDDO.
* Create dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_lvc_cat
IMPORTING
ep_table = l_dyntable. ASSIGN l_dyntable->* TO <dynamictable>.
* Create structure as structure of the internal table
CREATE DATA l_structure LIKE LINE OF <dynamictable>.
ASSIGN l_structure->* TO <header>.
* Create structure = structure of the internal table
CREATE DATA l_structure LIKE LINE OF <it_table>.
ASSIGN l_structure->* TO <ls_table>.
* Create field catalog from our table structure
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
CHANGING
ct_fieldcat = lt_fieldcatalogue
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. DESCRIBE TABLE lt_fieldcatalogue.
* Fill the internal to display <dynamictable>
DO sy-tfill TIMES.
IF sy-index = 1.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.
ENDIF.
* For each field of it_table
ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <dynheader>.
IF sy-subrc NE 0. EXIT .ENDIF.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.
* Fill 1st column
<dynheader> = wa_fieldcat-seltext_m.
IF <dynheader> IS INITIAL.
<dynheader> = wa_fieldcat-fieldname.
ENDIF.
*Filling the other columns
LOOP AT <it_table> INTO <ls_table>.
l_col = sy-tabix + 1.
ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO <dyndata>.
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT l_col OF STRUCTURE <header> TO
<dynheader>.
IF sy-subrc NE 0. EXIT .ENDIF.
WRITE <dyndata> TO <dynheader> LEFT-JUSTIFIED.
ENDLOOP.
APPEND <header> TO <dynamictable>.
ENDDO.
*Layout for ALV output
lt_layout-zebra = 'X'.
lt_layout-no_colhead = 'X'..
lt_layout-colwidth_optimize ='X'.
lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'.
*ALV Grid output for display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = lt_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = <dynamictable>. -
Changing font size(bold) or color of a particular row in ALV Grid Digplay
Hi Experts ,
I am having a requirment to highlight some particular rows in ALV Grid Display . To achieve this i need to change font size or make it bold or change color of that row .
Please give me some inputs .
Thanks in Advance.
VijyetaHi
Coloring An Entire Row
Coloring a row is a bit (really a bit) more complicated. , you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row.
First you have to declaration of our list data table u201Cgt_listu201D.
DATA BEGIN OF gt_list OCCURS 0 .
INCLUDE STRUCTURE SFLIGHT .
DATA rowcolor(4) TYPE c .
DATA END OF gt_list .
Adding the field that will contain row color data
As you guess, you should fill the color code to this field. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field u201CINFO_FNAMEu201D of the layout structure.
e.g.
ps_layout-info_fname = <field_name_containing_color_codes>. u201Ce.g. u2018ROWCOLORu2019
You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
Try this link also:
Possible functionalities in ALV
Regards
Neha -
Hi Group,
My requirement is to show 10 default rows in ALV grid (with 4 fields in ALV grid), whenever Create radio button is selected in Selection Screen.
Please could you help me with this.
Thanks and Regards,
Kumar.Thanks for your reply.
Sorry I forgot to mention earlier.
I have to show default 10 empty rows (editable) whenever the Create radio button is selected on the Sel Screen.
Kindly assist with this regard.
Thanks and Regards,
Kumar. -
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID?
HI.
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID????
GABRY =)You need to use
data : grid1 type ref to cl_gui_alv_grid.
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
a®
Maybe you are looking for
-
Multiple file processing in ODI
Hi, I am currently processing some files in ODI using a combination of odifilewait and odifilemove. This is what i want to achieve: We have multiple files coming into a directory (SRC_DIR) from different source systems. Each file will come with a con
-
FAGSLKF in ECC6.0 - NewGL
In ECC6.0 - NewGL, I'm trying to insert a new layout FAGSLKF. Because I'd like insert Statistical Key Figure values for each combinations of dimensions. How can I make it? Can I insert a custom field like dimension??? Let me know, thank you.
-
At some point after applying a version upgrade we went from showing only a few Enterprise cals were needed to now showing all clients need enterprise CAL's. Is there a check that can be ran to see what system setting changed causing this count change
-
E-mail sending with progress bar
OK so I have a application that allows the user to send an e-mail with multiple attachments. It works fine but I want to add a progress bar - when the user clicks SEND, a new window should pop-up with a progress bar and a OK button after the mail has
-
*Hi all,* *i m writing a BDC report for creating sales order using VA01 tcode...i have four fields in a upload file..the file will contain something like this...* *soldto shipto matnr quantity* *880 770 112