ROWS IN ALV
Hi All,
i need to display ALV with certain structure but i dont want to show some values initially , it should be kind of input screen. so how can i display empty rows initially in my ALV
Points for sure
Regards
Anuj Goyal
Hi,
in the Filed catalog of each field pass
wa_fieldcat-EDIT = 'X'.
This will make fields editable.
THen pass either 0 or "." dot in the text fields of the internal table. Pass the same internal table to ALV FM.
Best regards,
Prashant
Similar Messages
-
Hi experts...
I want single row in alv report.
I have use loop for fatch data into internal table using loop when i am passing data in alv report then the data comes according loop. i want onlu one data in alv row.
how can i do such, plz help me.decleare two internal table.
read table itab into wa index 1.
append wa to itab2.
pass itab2 only one record display. -
Hi ,
I need to insert a row in ALV output. On click of a Inser Row button a pop up should show with a parameter.Once the value in entered in the parameter enter is hit , the first column of the new row should have value put in that parameter as non editable field.
The Insert row of standard toolbar inserts a blank row . Is there any way to incorporate the above logic in the standard toolbar?
I'm using CL_GUI_ALV_GRID to display the ALV.
It would be helpful if you provide sample coding.
Thanks.
Ajith
Edited by: Ajith Krishna on Oct 28, 2008 8:01 PMHello Ajith
The enhanced version of sample report ZUS_SDN_ALVGRID_EDITABLE_8A demonstrates how to implement your requirement.
*& ZUS_SDN_ALVGRID_EDITABLE_8A
*& Thread: Insert a row in ALV
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1105097"></a>
*& Thread: Blanking values on ALV Grid Row Duplicate
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1057161"></a>
*& Thread: Delete line event in ALV
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="945471"></a>
REPORT zus_sdn_alvgrid_editable_8a.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knb1.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gt_outtab TYPE ty_t_outtab.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
mt_sel_rows TYPE lvc_t_row.
CLASS-METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
sender,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_toolbar.
* define local data
DATA: ls_button TYPE stb_button.
LOOP AT e_object->mt_toolbar INTO ls_button.
CASE ls_button-function.
when cl_gui_alv_grid=>MC_FC_LOC_INSERT_ROW.
ls_button-function = 'INSERT_ROW'.
MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
WHEN cl_gui_alv_grid=>mc_fc_loc_delete_row.
ls_button-function = 'DELETE_ROW'.
MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
WHEN cl_gui_alv_grid=>mc_fc_loc_copy_row OR
cl_gui_alv_grid=>mc_fc_loc_copy.
ls_button-function = 'COPY_ROW'.
MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
WHEN OTHERS.
CONTINUE.
ENDCASE.
ENDLOOP.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
* define local data
DATA: lt_rows TYPE lvc_t_row,
ls_row TYPE lvc_s_row.
REFRESH: mt_sel_rows.
CASE e_ucomm.
when 'INSERT_ROW'.
WHEN 'DELETE_ROW'.
WHEN 'COPY_ROW'.
WHEN OTHERS.
RETURN.
ENDCASE.
" User wants to delete or copy rows => store them in class attribute
" and trigger PAI afterwards where we actually delete /copy the rows
" and do the recalculations (in case of deletion)
CALL METHOD sender->get_selected_rows
IMPORTING
et_index_rows = mt_sel_rows
* et_row_no =
* Trigger PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = e_ucomm
* IMPORTING
* rc =
ENDMETHOD. "user_command
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
START-OF-SELECTION.
SELECT * FROM knb1 INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO 15 ROWS
WHERE bukrs = p_bukrs.
PERFORM init_controls.
SET HANDLER:
lcl_eventhandler=>handle_toolbar FOR go_grid,
lcl_eventhandler=>handle_user_command FOR go_grid.
" Used to replace standard toolbar function code with custom FC
go_grid->set_toolbar_interactive( ).
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
** CALL METHOD go_grid1->refresh_table_display
*** EXPORTING
*** IS_STABLE =
*** I_SOFT_REFRESH =
** EXCEPTIONS
** FINISHED = 1
** others = 2
** IF sy-subrc <> 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
** ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'INSERT_ROW'.
perform INSERT_ROW.
WHEN 'DELETE_ROW'.
PERFORM delete_rows.
WHEN 'COPY_ROW'.
PERFORM copy_rows.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
CALL METHOD go_grid->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Only non-key fields are editable
ls_fcat-edit = 'X'.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING edit
WHERE ( key NE 'X' ).
ENDFORM. " BUILD_FIELDCATALOG_KNB1
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid->set_table_for_first_display
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Form delete_rows
* text
* --> p1 text
* <-- p2 text
FORM delete_rows .
* define local data
DATA: ls_row TYPE lvc_s_row.
SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
DELETE gt_outtab INDEX ls_row-index.
ENDLOOP.
" After deleting rows do RE-CALCULATION
* perform RECALCULATION.
ENDFORM. " delete_rows
*& Form COPY_ROWS
* text
* --> p1 text
* <-- p2 text
FORM copy_rows .
* define local data
DATA: ld_next TYPE i,
ls_row TYPE lvc_s_row,
ls_outtab TYPE ty_s_outtab.
SORT lcl_eventhandler=>mt_sel_rows BY index DESCENDING. " !!!
LOOP AT lcl_eventhandler=>mt_sel_rows INTO ls_row.
READ TABLE gt_outtab INTO ls_outtab INDEX ls_row-index.
CLEAR: ls_outtab-akont. " In your case: clear GUID
ld_next = ls_row-index + 1.
INSERT ls_outtab INTO gt_outtab INDEX ld_next.
ENDLOOP.
ENDFORM. " COPY_ROWS
*& Form INSERT_ROW
* text
* --> p1 text
* <-- p2 text
form INSERT_ROW .
* define local data
DATA: ld_value1 type SPOP-VARVALUE1,
ls_outtab TYPE ty_s_outtab.
CALL FUNCTION 'POPUP_TO_GET_ONE_VALUE'
EXPORTING
textline1 = 'Enter Value (4 Chars):'
* TEXTLINE2 = ' '
* TEXTLINE3 = ' '
titel = 'Enter Value'
valuelength = 4
IMPORTING
* ANSWER =
VALUE1 = ld_value1
EXCEPTIONS
TITEL_TOO_LONG = 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.
ls_outtab-kunnr = ld_value1.
ls_outtab-bukrs = ld_value1.
append ls_outtab to gt_outtab.
endform. " INSERT_ROW
Regards
Uwe -
Insert Blank row After every Row in alv report
How to insert blank row After every row in Alv report
what do you mean by a 'blank row'? ALV displays tabular data with 'any' number of columns. Now if you actually want a blank row (no columns at all, just a row), then that is just not possible. If I'm not mistaken, this question was posted before, so try to do a search on SCN. See what is says.
-
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 -
Deleting rows in alv report.
Hi Experts,
I want to delete a row in alv report output, It is duplicating records in the report and 'GRAND TOTAL' also be displayed . In under the report . <<removed_by_moderator>>
Thanks,
Dinesh.B
Edited by: Vijay Babu Dudla on May 11, 2009 9:15 AMHi,
use the following code for deleting duplicate and adjacent records from itab
delete ADJACENT DUPLICATES FROM itab.
or
sort itab by pernr.
delete ADJACENT DUPLICATE FROM itab COMPARING pernr.
Also, for grand total you can use fieldcat-do_sum = 'X' with the field catalog. It will give you total for the required column.
Hope this solves your problem.
Regards,
Ibrar Munsif. -
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. -
How to select multiple row in ALV report
Hi friends,
1. How to select multiple row in ALV report
( How to set tab in ALV report and want to select multiple line.)
Thanking you.
SubashHi Sahoo,
If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
in layout structure you will find field SEL_MODE
pass :
LS_LAYOUT-SEL_MODE = 'A'.
In PAI.
CALL METHOD GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = T_ROWS
ET_ROW_NO = T_ROWID.
Hope these will solve your problem.
Regards,
Kumar M. -
How to delete a particular row in ALV table
Hi,
How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
Thanks
Bala DuvvuriHello Bala,
Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
data : lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_config TYPE REF TO cl_salv_wd_config_table.
lr_table_settings ?= lr_config.
** Setting the ALV selection to multiple selection with no lead selection
lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
Next delete the selected rows in the action triggered by the button:
METHOD onactiondelete_rows .
DATA: wd_node TYPE REF TO if_wd_context_node,
lt_node1 TYPE ig_componentcontroller=>elements_node,
wa_temp TYPE REF TO if_wd_context_element,
lt_temp TYPE wdr_context_element_set,
row_number TYPE i VALUE 0.
wd_node = wd_context->get_child_node( name = 'NODE' ).
CALL METHOD wd_node->get_selected_elements
RECEIVING
set = lt_temp.
LOOP AT lt_temp INTO wa_temp.
wd_node->remove_element( EXPORTING element = wa_temp ).
ENDLOOP.
CALL METHOD wd_node->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_node1.
wd_node->bind_table( new_items = lt_node1 ).
ENDMETHOD.
If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
Regards,
Uday -
How to change the colour of row in ALV depending on condition?
Hi All,
I want to change the color(from green to red )of perticular row in ALV depending on certain conditions like if amount in some field in row is more than 5000.
Can anybody please tell me how to do that?
expecting early reply.
Thanks in advance,
Rohini.Hi
Check this sample report
*& Report ZALVCOLOR *
REPORT ZALVCOLOR .
DATA : mara TYPE mara. " General Material Data
TYPE-POOLS: slis. " ALV Global types
FIELD-SYMBOLS :
<data> TYPE table. " Data to display
SELECT-OPTIONS :
s_matnr FOR mara-matnr. " Material number
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Maximum of lines to display'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form f_read_data
FORM f_read_data.
FIELD-SYMBOLS :
<field> TYPE ANY,
<field2> TYPE ANY,
<header> TYPE ANY,
<header2> TYPE ANY,
<lt_data> TYPE table. " Data read from DB
DATA:
lp_struct TYPE REF TO data,
lp_struct2 TYPE REF TO data,
lp_table TYPE REF TO data, " Pointer to dynamic table
lp_table2 TYPE REF TO data, " Pointer to dynamic table
ls_lvc_cat TYPE lvc_s_fcat,
lt_lvc_cat TYPE lvc_t_fcat. " Field catalog
* First column
CLEAR ls_lvc_cat.
ls_lvc_cat-fieldname = 'MATNR'.
ls_lvc_cat-ref_table = 'MARA'.
APPEND ls_lvc_cat TO lt_lvc_cat.
* 2nd column
CLEAR ls_lvc_cat.
ls_lvc_cat-fieldname = 'MAKTX'.
ls_lvc_cat-ref_table = 'MAKT'.
APPEND ls_lvc_cat TO lt_lvc_cat.
* 3rd column
CLEAR ls_lvc_cat.
ls_lvc_cat-fieldname = 'MATKL'.
ls_lvc_cat-ref_table = 'MARA'.
APPEND ls_lvc_cat TO lt_lvc_cat.
* Create 1st internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = lt_lvc_cat
IMPORTING ep_table = lp_table.
ASSIGN lp_table->* TO <lt_data>.
* Read data into 1st internal table
SELECT matnr maktx matkl
INTO TABLE <lt_data>
FROM v_matnr
UP TO p_max ROWS
WHERE matnr IN s_matnr.
* Create 2nd internal table
* Checkbox
CLEAR ls_lvc_cat.
ls_lvc_cat-fieldname = 'CHECKBOX'.
APPEND ls_lvc_cat TO lt_lvc_cat.
* Table color
CLEAR ls_lvc_cat.
ls_lvc_cat-fieldname = 'TABCOLOR'.
ls_lvc_cat-ref_table = 'CALENDAR_TYPE'.
ls_lvc_cat-ref_field = 'COLTAB'.
APPEND ls_lvc_cat TO lt_lvc_cat.
* Create 2nd internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = lt_lvc_cat
IMPORTING ep_table = lp_table2.
ASSIGN lp_table2->* TO <data>.
* Create structure = structure of the 1st internal table
CREATE DATA lp_struct LIKE LINE OF <lt_data>.
ASSIGN lp_struct->* TO <header>.
* Create structure = structure of the 2nd internal table
CREATE DATA lp_struct2 LIKE LINE OF <data>.
ASSIGN lp_struct2->* TO <header2>.
* Move data from 1st internal table --> 2nd internal table
LOOP AT <lt_data> ASSIGNING <header>.
DESCRIBE TABLE lt_lvc_cat.
CLEAR <header2>.
* Fill the internal to display <data>
DO sy-tfill TIMES.
READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index.
* For each field of lt_lvc_cat.
ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header>
TO <field>.
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE <header2>
TO <field2>.
IF sy-subrc NE 0. EXIT .ENDIF.
<field2> = <field>.
ENDDO.
* Modify color
ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE <header2>
TO <field2>.
IF sy-subrc EQ 0.
PERFORM f_modify_color USING 'MAKTX' <field2>.
PERFORM f_modify_color USING 'MATKL' <field2>.
ENDIF.
APPEND <header2> TO <data> .
ENDLOOP.
ENDFORM. " f_read_data
* Form F_DISPLAY_DATA
FORM f_display_data.
* Macro definition
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-down = 'X'.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv. " Field catalog
* Build Fieldcatalog - First column
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-ref_tabname = 'MARA'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO lt_fieldcat.
* Build Fieldcatalog - 2nd column
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-ref_tabname = 'MAKT'.
APPEND ls_fieldcat TO lt_fieldcat.
* Build Fieldcatalog - 3rd column
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATKL'.
ls_fieldcat-ref_tabname = 'MARA'.
APPEND ls_fieldcat TO lt_fieldcat.
* Layout
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-box_fieldname = 'CHECKBOX'.
ls_layout-coltab_fieldname = 'TABCOLOR'.
m_sort 'MATNR'. " Sort by creation date
* Display data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = <data>.
ENDFORM. " F_DISPLAY_DATA
* Form F_modify_color
FORM f_modify_color USING u_fieldname TYPE lvc_fname
ut_tabcolor TYPE table.
DATA:
l_rnd_value TYPE datatype-integer2,
ls_tabcolor TYPE lvc_s_scol.
* Random value
CALL FUNCTION 'RANDOM_I2'
EXPORTING
rnd_min = 0
rnd_max = 3
IMPORTING
rnd_value = l_rnd_value.
CLEAR ls_tabcolor.
ls_tabcolor-fname = u_fieldname.
CASE l_rnd_value.
WHEN 0.
ls_tabcolor-color-col = 1. " Blue.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 1.
ls_tabcolor-color-col = 3. " Yellow.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 2.
ls_tabcolor-color-col = 5. " Green.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
WHEN 3.
ls_tabcolor-color-col = 6. " Red.
ls_tabcolor-color-int = 0.
ls_tabcolor-color-inv = 0.
ENDCASE.
INSERT ls_tabcolor INTO TABLE ut_tabcolor.
ENDFORM. " F_MODIFY_COLOR
Reward all helpfull answers
Regards
Pavan -
Hiding a particular row in ALV
Hi can anyone please tell me how to hide a particular row in ALV grid display depending upon certain value
Actually iam displaying values of an consignment idoc in the ALV grid but i don't want to display a particular segment of that idoc in ALV.Like i have an idoc with E1MBXYH segment and E1MBXYI segment sometimes this E1MBXYI segment will have ZSADATI segment.In this case i want to hide zsadati segment in ALV but
i need some values in ZSADATI segment so i just want to hide it.Can you please help me -
How to Gray out a row in ALV ?
Hi Experts,
I am having a requirement to gray a specific row in ALV . Is it possible through List Display ? Or Is it possible through Grid Display ?
If it is possible, please let me know how to achieve this .
Thanks and regards,
Kiran.Hello kiran kumar ,
you can colour a cell in AlV ie. in turn you can colour entire row in one Colour...just check out the blew given link
http://wiki.sdn.sap.com/wiki/display/Snippets/ColorindividualcellsofanALVGRID
Hope it helps. -
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! -
How to get column value of a selected row of ALV
Hello ,
I have application POWL POWL_UI_COMP uses another component POWL_TABLE_COMP.
This POWL_TABLE_COMP uses SALV_WD_TABLE.
I want to select value of ORDER id and it need to be passed whenever user selects a display order button(Which is self defined function generated in POWL_TABLE_COMP) . I am calling a display order on action of this display button(http://nap60.nalco.one.net:8042/sap/bc/webdynpro/sap/mt_order_app?IV_ACTIVITYTYPE=A&IV_EQUIPMENT=aaaa&IV_ORDERID=90001511&IV_ORDERTYPE=STD&IV_QMNUM=00&IV_TPLNR=00)
ORDERID is one column value of selected row of ALV table.
So please can you suggest , how to read ORDERID and pass it to the self defined function..
thanks in advance,
SharadaAnoop,
I have plcaed this code in event handler of on_lead_select.
Its giving error the element doesnt exist.
static_attributes should give me row data but it's giving short dump saying
Pl can you suggest.
data: set_of_element type WDR_CONTEXT_ELEMENT_SET,
element1 type ref to IF_WD_CONTEXT_ELEMENT,
result type POWL_CRESULT_STY,
table_helper type ref to CL_POWL_TABLE_HELPER,
context_node type ref to IF_WD_CONTEXT_NODE,
lt_selected_elements TYPE wdr_context_element_set,
static_attributes type ref to data.
table_helper = wd_comp_controller->mr_table_helper.
context_node = table_helper->get_data_node( ).
context_node = wd_comp_controller->mr_table_helper->get_data_node( ).
context_node->get_static_attributes( exporting index = r_param->index
importing static_attributes = static_attributes ).
thanks,
Sharada -
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. -
How to display multiple lines of texts in a single rows in ALV
Hi,
I have a unique requirement in which i have to display multiple lines if texts for a single rows in ALV Grid. Right now in my output it is coming in single line which is not visible fully because that text is more than 255 character. So i want to display the test by splitting into multiple lines and show it on output. Please suggest some solution for this if this is possible in ALV.
Thanks,
RaghavHi Raghavendra,
Its not possible to display multiple line in one row of an alv, but i think you can acheive it by splitting the whole text into multiple sub-text.
For example, if your requirement is as below:
Field #1 Field #2
1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(200 characters)
2 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy(220 character)
then you can break Field#2 value into say 50 character and then populate the internal table with repetative entries of Field#1 and the finally sort it by Field#1 value... as a result of which you output will be somewhat as below:
Field#1 Field#2
1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyy
Hope it will help you in meeting your requirement.
Regards,
Shradha
Maybe you are looking for
-
How do I find missing music from my i-tunes library?
My iPod classic 30 GB will not sync and now my entire library of songs is gone. How can I get them back?
-
Having Problems Downloading Photoshop for Creative Cloud
Hi all, I just bought Photoshop CC 2015. I used the annual pre-paid method. I think something got messed up. I bought the program. I received the confirmation E-mail. I clicked on 'Download' on the Photoshop app located on the Desktop on this site. O
-
Java VM Version & Date for JDev 3.0
Hi, I skimmed through the document: "JDeveloper 3.0 Oracle Business Components for Java Technical White Paper" and could not find out which version of the VM 3.0 is going to support. 2 questions: - 1: Which version of the JVM? - 2: General availabili
-
Adobe Air necessary for CS6?
On a fresh install of Lion, I now see Adobe Air Installer and Uninstaller. Not sure what they do, but wanted to see if they are needed by CS6. I'm only running Photoshop, Illustrator, InDesign and Adobe Bridge. Thanks for any help.
-
NVIDIA NVS Graphic adapter support KVM-Intel AMT/vPro?
Hi there, I have a Thinkpad T410, Intel core i7, Intel Centrino Advanced-N 6200 AGN and the NVIDIA NVS 3100m Graphic adapter, I asked to Intel and that adapter does not support KVM: http://software.intel.com/en-us/forums/showthread.php?t=78585&o=a&s=