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
Similar Messages
-
Color a single cell in ALV using OO
Dear Gurus ,
I tried to color a cell using OO in ALV but i can't . I think my code is correct but i can't find the problem ...
Look my code please ...
DATA: BEGIN OF ITAB OCCURS 0,
PERNR LIKE PTRV_HEAD-PERNR,
ENAME LIKE PA0001-ENAME,
REINR LIKE PTRV_HEAD-REINR,
ZORT1 LIKE PTRV_HEAD-ZORT1,
* ZLAND LIKE PTRV_HEAD-ZLAND,
KUNDE LIKE PTRV_HEAD-KUNDE,
DATV1 LIKE PTRV_HEAD-DATV1,
DATB1 LIKE PTRV_HEAD-DATB1,
DAYS_DIFF TYPE I,
EXODAMET LIKE PTRV_SREC-REC_AMOUNT,
PAGIAMET LIKE PTRV_SREC-REC_AMOUNT,
DIFFMET TYPE P DECIMALS 2,
EXODAERG LIKE PTRV_SREC-REC_AMOUNT,
PAGIAERG LIKE PTRV_SREC-REC_AMOUNT,
DIFFERG LIKE PTRV_SREC-REC_AMOUNT,
CELLCOLOR TYPE LVC_T_SCOL,
END OF ITAB.
DATA : ITAB_WA LIKE LINE OF ITAB.
FORM SET_CELL_COLORS.
LOOP AT ITAB INTO ITAB_WA.
* L_INDEX = SY-TABIX.
IF ITAB_WA-PERNR = '231034'.
LS_CELLCOLOR-FNAME = 'DATB1'.
LS_CELLCOLOR-COLOR-COL = '7'.
LS_CELLCOLOR-COLOR-INT = '1'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB_WA-CELLCOLOR.
MODIFY ITAB FROM ITAB_WA TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
IS_VARIANT = LS_VARI
I_SAVE = GS_TEST-VARI_SAVE
I_DEFAULT = 'X' "GS_TEST-VARI_DEFAULT
IS_LAYOUT = GS_LAYOUT
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
CHANGING
IT_OUTTAB = ITAB[]
IT_FIELDCATALOG = GT_FIELDCAT
IT_SORT = LT_SORT
* IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4 .
IF SY-SUBRC <> 0.
*--Exception handling
ENDIF.
If i do it w/o OO i can do it ....
Can you see the problem ....?
Thanks a lot ...hi dimath,
I think your code is fine jst make sure you have mention in layout this:
w_layout-ctab_fname = 'CELLCOLOR' . and name in your ITAB and in layout ie cellcolor should be same.
Thanks,
Gaurav -
Issue with editable alv using cl_gui_alv_grid
Hello all,
its a table update program . user can save create new entry and delete the entires . the screen should be avaiable for multiple time inputs by the user . i achived it by method handle double click and i am refreshing the scrren and making the alv for ready for input . but user wants the screen shoukld get refreshed automatically once user clicks on save button .
how can I achive plz advise .
I am working on ALV by cl_gui_alv_grid , I am using the followingmethods of the class
1) METHODS: handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
2) METHODS: handle_user_command FOR EVENT
user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
check_changed_data.
3) METHODS: handle_double_click FOR EVENT
double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
4) METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
Thanks in advance .Hi Soumyaprakash,
SAve is an user command . I want to have the values which are changed by the user and again the output should be ready for any actions like change the data , create new and delete any entry .
basically the alv output screen should be reday for inputs any number of times untill user clicks on back button .
Thanks
Basavaraj -
Click Event on ALV using cl_gui_alv_grid (DYNPRO)
How can I implement a listener for a click on ALV.
If I click on my ALV grid, for example PBA should be triggered. Is that possible?
Now it seems that nothing happens when I click on ALV.
Can anyone help?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 -
Hi experts,
I have created a screen with custom control( cl_gui_custom_container ) and displayed a alv using cl_gui_alv_grid in the screen. I have to enter tha values into the alv displayed on screen.The problem here is i have to make 2 fields as mandatory on the alv displayed on the screen.
Is it possible to get screen name of these fields so that i can process it in the PBO or is their some way??
Thanks in advance
regards,
AshwinAnyway the fields that are getting displayed is from the structure u have created right?
So in PBO, u can use the field names like 'MATNR'.
If u want to process after selecting u have to right in PAI like
CASE sy-ucomm.
WHEN 'MATNR'.
In oops for selected row processing
CASE e_ucomm.
WHEN 'FCODE'.
CALL METHOD o_alvgrid->get_selected_rows
IMPORTING
et_index_rows = i_selected_rows
* ET_ROW_NO =
IF i_selected_rows[] IS INITIAL.
MESSAGE i153 WITH text-009.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR: w_reviewed_mat.
* w_reviewed_mat-reviewed = c_x.
* w_reviewed_mat-reviewedby = sy-uname.
* w_reviewed_mat-reviewedon = sy-datum.
LOOP AT i_selected_rows INTO w_selected_rows.
READ TABLE i_output INTO w_output INDEX w_selected_rows-index.
IF sy-subrc EQ 0.
w_reviewed_mat-matnr = w_output-matnr.
ENDIF.
APPEND w_reviewed_mat TO i_reviewed_mat.
CLEAR: w_reviewed_mat-matnr.
ENDLOOP.
* MODIFY zzcs_mat FROM TABLE i_reviewed_mat.
WHEN OTHERS.
ENDCASE. -
To color selected cells in dynamically created table in ALV.
Hi,
The requirement is to display a table (whose columns are dynamic) using ALV n to color few cells of the table based on some condition.
For creating the table dynamically i have used the method cl_alv_table_create=>create_dynamic_table.
Now for coloring the cells i tried to use the field EMPHASIZE .
But when I try this method the whole column is getting colored.
So any suggestions on how to color only particular cells.Hi,
Try this one...
DATA: gs_layout TYPE slis_layout_alv, "Define layout
gt_color TYPE lvc_t_scol WITH HEADER LINE. "Define Internal Table for Cell Colouring
Use below Sample Code after building a Field Catalog:
gs_layout-coltab_fieldname = 'COLINFO'.
" 'it' is the final internal table which contain positive & negative value of Field 'MENGE'
LOOP AT it.
REFRESH gt_color.
CLEAR gt_color.
IF it-menge GE 0.
CLEAR gt_color.
gt_color-fname = 'MENGE'.
gt_color-color-col = cl_gui_resources=>list_col_positive.
gt_color-color-int = 0.
APPEND gt_color.
ELSEIF it-menge LE 0.
CLEAR gt_color.
gt_color-fname = 'MENGE'.
gt_color-color-col = cl_gui_resources=>list_col_negative.
gt_color-color-int = 0.
APPEND gt_color.
ENDIF.
it-colinfo[] = gt_color[].
MODIFY it.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = ct_fieldcat
i_save = 'A'
TABLES
t_outtab = it
EXCEPTIONS
program_error = 1
OTHERS = 2.
Hope this solves your problem.
Regards,
Tarun -
Coloring an single field of an ALV using factory method
how can we color just a single field in ALV using factory method.
Hello Regi you may want to check this sample code, basically what you need is to use the lvc_s_colo structure and the set_color method of the class cl_salv_column_table.
METHOD set_colors.
*.....Color for COLUMN.....
DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
lo_col_tab TYPE REF TO cl_salv_column_table.
DATA: ls_color TYPE lvc_s_colo. " Colors strucutre
* get Columns object
lo_cols_tab = co_alv->get_columns( ).
INCLUDE <color>.
* Get ERDAT column & set the yellow Color fot it
TRY.
lo_col_tab ?= lo_cols_tab->get_column( 'ERDAT' ).
ls_color-col = col_total.
lo_col_tab->set_color( ls_color ).
CATCH cx_salv_not_found.
ENDTRY.
*.......Color for Specific Cell & Rows.................
* Applying color on the 3rd Row and Column AUART
* Applying color on the Entire 5th Row
DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol,
la_vbak LIKE LINE OF ct_vbak,
l_count TYPE i.
LOOP AT ct_vbak INTO la_vbak.
l_count = l_count + 1.
CASE l_count.
* Apply RED color to the AUART Cell of the 3rd Column
WHEN 3.
ls_s_color-fname = 'AUART'.
ls_s_color-color-col = col_negative.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
* Apply GREEN color to the entire row # 5
* For entire row, we don't pass the Fieldname
WHEN 5.
ls_s_color-color-col = col_positive.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
ENDCASE.
* Modify that data back to the output table
la_vbak-t_color = lt_s_color.
MODIFY ct_vbak FROM la_vbak.
CLEAR la_vbak.
CLEAR lt_s_color.
ENDLOOP.
* 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.
ENDMETHOD. "set_colors -
How to color cells according to particular condition in alv using field catalog?
thankshi
good
go through this report
tables used -
tables: mkpf,
mseg,
lfa1,
makt.
global hashed tables used
data: begin of wa_mkpf, "header
mblnr like mkpf-mblnr,
mjahr like mkpf-mjahr,
budat like mkpf-budat,
xblnr like mkpf-xblnr,
end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
with unique key mblnr mjahr
with header line.
data: st_mkpf like standard table of wa_mkpf
with header line.
data: begin of wa_mseg, " line items
mblnr like mseg-mblnr,
mjahr like mseg-mjahr,
zeile like mseg-zeile,
bwart like mseg-bwart,
charg like mseg-charg,
matnr like mseg-matnr,
lifnr like mseg-lifnr,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
with unique key mblnr mjahr zeile
with header line.
data st_mseg like standard table of wa_mseg
with header line.
cache structure for lfa1 records
data: begin of wa_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
with unique key lifnr
with header line.
cache structure for material related data
data: begin of wa_material,
matnr like makt-matnr,
maktx like makt-maktx,
end of wa_material.
data: ht_material like hashed table of wa_material
with unique key matnr
with header line.
result table
data: begin of wa_lst, "
budat like mkpf-budat,
mblnr like mseg-mblnr,
lifnr like mseg-lifnr,
name1 like lfa1-name1,
xblnr like mkpf-xblnr,
zeile like mseg-zeile,
charg like mseg-charg,
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
mjahr like mseg-mjahr,
end of wa_lst.
data: ht_lst like hashed table of wa_lst
with unique key mblnr mjahr zeile
with header line.
data: begin of wa_lst1, " sumary by material
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
celltab type LVC_T_STYL,
end of wa_lst1.
data: ht_lst1 like hashed table of wa_lst1
with unique key matnr
with header line.
structures for alv grid display.
itabs
type-pools: slis.
data: it_lst like standard table of wa_lst with header line,
it_fieldcat_lst type slis_t_fieldcat_alv with header line,
it_sort_lst type slis_t_sortinfo_alv,
it_lst1 like standard table of wa_lst1 with header line,
it_fieldcat_lst1 type slis_t_fieldcat_alv with header line,
it_sort_lst1 type slis_t_sortinfo_alv.
structures
data: wa_sort type slis_sortinfo_alv,
ls_layout type slis_layout_alv.
color management.
DATA : wa_color TYPE lvc_s_scol.
Internal table for color management.
DATA : it_color TYPE TABLE OF lvc_s_scol.
itab for input enabling.
DATA: lt_celltab TYPE lvc_t_styl. "
global varialbes
data: g_lines type i.
data: g_repid like sy-repid,
ok_code like sy-ucomm.
selection-screen
"text: Dates:
select-options: so_budat for mkpf-budat default sy-datum.
"text: Material numbers.
select-options: so_matnr for mseg-matnr.
selection-screen uline.
selection-screen skip 1.
"Text: show summary by material.
parameters: gp_bymat as checkbox default ''.
parameters: gp_hier as checkbox default 'X'.
start-of-selection.
perform get_data.
perform show_data.
end-of-selection.
FORM get_data *
form get_data.
select mblnr mjahr budat xblnr
into table ht_mkpf
from mkpf
where budat in so_budat. " make use of std index.
have we retrieved data from mkpf?
describe table ht_mkpf lines g_lines.
if g_lines > 0.
if true then retrieve all related records from mseg.
Doing this way we make sure that the access is by primary key
of mseg.
The reason is that is faster to filter them in memory
than to allow the db server to do it.
select mblnr mjahr zeile bwart charg
matnr lifnr erfmg erfme
into table ht_mseg
from mseg
for all entries in ht_mkpf
where mblnr = ht_mkpf-mblnr
and mjahr = ht_mkpf-mjahr.
endif.
fill t_lst or t_lst1 according to user's choice.
if gp_bymat = ' '.
perform fill_ht_lst.
else.
perform fill_ht_lst1.
endif.
endform.
form fill_ht_lst.
refresh ht_lst.
Example: how to discard unwanted data in an efficient way.
loop at ht_mseg.
filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
read header line.
read table ht_mkpf with table key mblnr = ht_mseg-mblnr
mjahr = ht_mseg-mjahr.
clear ht_lst.
* note : this may be faster if you specify field by field.
move-corresponding ht_mkpf to ht_lst.
move-corresponding ht_mseg to ht_lst.
perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
perform read_material using ht_mseg-matnr changing ht_lst-maktx.
insert table ht_lst.
endloop.
endform.
form fill_ht_lst1.
data: colorear.
refresh ht_lst1.
Example: how to discard unwanted data in an efficient way.
hot to simulate a collect in a faster way
loop at ht_mseg.
filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* note : this may be faster if you specify field by field.
read table ht_lst1 with table key matnr = ht_mseg-matnr
transporting erfmg.
if sy-subrc <> 0. " if matnr doesn't exist in sumary table
" insert a new record
clear ht_lst1.
ht_lst1-matnr = ht_mseg-matnr.
perform read_material using ht_mseg-matnr changing ht_lst1-maktx.
ht_lst1-erfmg = ht_mseg-erfmg.
ht_lst1-erfme = ht_mseg-erfme.
if colorear = ''.
colorear = 'X'.
refresh it_color.
ht_lst1-color_cell[] = it_color[].
MOVE 'C410' TO ht_lst1-color_line.
else.
colorear = ' '.
refresh it_color. clear it_color.
MOVE 'MATNR' TO wa_color-fname.
MOVE '6' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
MOVE 'MAKTX' TO wa_color-fname.
MOVE '3' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
MOVE 'ERFMG' TO wa_color-fname.
MOVE '5' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
ht_lst1-color_cell[] = it_color[].
clear ht_lst1-color_line.
endif.
insert table ht_lst1.
else." a record was found.
" collect erfmg. To do so, fill in the unique key and add
" the numeric fields.
ht_lst1-matnr = ht_mseg-matnr.
add ht_mseg-erfmg to ht_lst1-erfmg.
modify table ht_lst1 transporting erfmg.
endif.
endloop.
endform.
implementation of cache for lfa1.
form read_lfa1 using p_lifnr changing p_name1.
read table ht_lfa1 with table key lifnr = p_lifnr
transporting name1.
if sy-subrc <> 0.
clear ht_lfa1.
ht_lfa1-lifnr = p_lifnr.
select single name1
into ht_lfa1-name1
from lfa1
where lifnr = p_lifnr.
if sy-subrc <> 0. ht_lfa1-name1 = 'n/a in lfa1'. endif.
insert table ht_lfa1.
endif.
p_name1 = ht_lfa1-name1.
endform.
implementation of cache for material data
form read_material using p_matnr changing p_maktx.
read table ht_material with table key matnr = p_matnr
transporting maktx.
if sy-subrc <> 0.
ht_material-matnr = p_matnr.
select single maktx into ht_material-maktx
from makt
where spras = sy-langu
and matnr = p_matnr.
if sy-subrc <> 0. ht_material-maktx = 'n/a in makt'. endif.
insert table ht_material.
endif.
p_maktx = ht_material-maktx.
endform.
form show_data.
if gp_hier = 'X'. "no anda.
perform show_hierarchicalALV.
else.
if gp_bymat = ' '.
perform show_ht_lst.
else.
perform show_ht_lst1.
endif.
endif.
endform.
form show_hierarchicalALV.
st_mkpf[] = ht_mkpf[].
st_mseg[] = ht_mseg[].
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM =
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
i_tabname_header =
i_tabname_item =
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
is_keyinfo =
IS_PRINT =
IS_REPREP_ID =
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = st_mkpf
t_outtab_item = st_mseg
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.
form show_ht_lst.
"needed because the FM can't use a hashed table.
it_lst[] = ht_lst[].
perform fill_layout using 'full display'
changing ls_layout.
perform fill_columns_lst.
perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst[]
it_sort = it_sort_lst
tables
t_outtab = it_lst
exceptions
program_error = 1
others = 2.
endform.
form show_ht_lst1.
"needed because the FM can't use a hashed table.
it_lst1[] = ht_lst1[].
perform fill_layout using 'Sumary by matnr'
changing ls_layout.
perform fill_columns_lst1.
perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst1[]
it_sort = it_sort_lst
tables
t_outtab = it_lst1
exceptions
program_error = 1
others = 2.
endform.
form fill_layout using p_window_titlebar
changing cs_layo type slis_layout_alv.
clear cs_layo.
cs_layo-window_titlebar = p_window_titlebar.
cs_layo-edit = 'X'.
cs_layo-edit_mode = space.
MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
move 'CELLTAB' TO cs_layo-stylefname.
endform. " armar_layout_stock
form set_pf_status using rt_extab type slis_t_extab.
create a new status
and then select extras -> adjust template -> listviewer
set pf-status 'VISTA'.
endform. "set_pf_status
define add_lst.
clear it_fieldcat_lst.
it_fieldcat_lst-fieldname = &1.
it_fieldcat_lst-outputlen = &2.
it_fieldcat_lst-ddictxt = 'L'.
it_fieldcat_lst-seltext_l = &1.
it_fieldcat_lst-seltext_m = &1.
it_fieldcat_lst-seltext_m = &1.
if &1 = 'MATNR'.
it_fieldcat_lst-emphasize = 'C111'.
endif.
append it_fieldcat_lst.
end-of-definition.
define add_lst1.
clear it_fieldcat_lst.
it_fieldcat_lst1-fieldname = &1.
it_fieldcat_lst1-outputlen = &2.
it_fieldcat_lst1-ddictxt = 'L'.
it_fieldcat_lst1-seltext_l = &1.
it_fieldcat_lst1-seltext_m = &1.
it_fieldcat_lst1-seltext_m = &1.
append it_fieldcat_lst1.
end-of-definition.
form fill_columns_lst.
set columns for output.
refresh it_fieldcat_lst.
add_lst 'BUDAT' 10.
add_lst 'MBLNR' 10.
add_lst 'LIFNR' 10.
add_lst 'NAME1' 35.
add_lst 'XBLNR' 15.
add_lst 'ZEILE' 5.
add_lst 'CHARG' 10.
add_lst 'MATNR' 18.
add_lst 'MAKTX' 30.
add_lst 'ERFMG' 17.
add_lst 'ERFME' 5.
add_lst 'MJAHR' 4.
endform.
form fill_columns_lst1.
set columns for output.
refresh it_fieldcat_lst1.
add_lst1 'MATNR' 18.
add_lst1 'MAKTX' 30.
add_lst1 'ERFMG' 17.
add_lst1 'ERFME' 5..
endform.
Horacio Zapettini
Program to Calculate FI Opening Balance
How to find the Opening balance for a given period in FI Module for a Particular GL A/c.
I was calculated opening balance, code is below maybe it will be helpful.
*find period.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = s_budat-low
i_periv = i_tab-periv "'K4'
IMPORTING
e_buper = v_donem
e_gjahr = v_gjahr
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
*calc opening balance hesabý
SELECT * FROM knc1 WHERE kunnr = i_tab-kunnr
AND bukrs = i_tab-bukrs " s_bukrs
AND gjahr EQ v_gjahr.
v_dnm = v_donem.
opening balance first calc > old year ,
WHILE v_dnm > 1.
v_dnm = v_dnm - 1.
CONCATENATE 'knc1-um' v_dnm 's' INTO v_field_name_borc.
CONCATENATE 'knc1-um' v_dnm 'h' INTO v_field_name_alacak.
ASSIGN (v_field_name_borc) TO old
add days which is from selected date-low month
IF v_donem > 1.
v_dnm = v_donem - 1.
ELSE.
v_dnm = v_donem.
ENDIF.
SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv "'K4'
AND bdatj = s_budat-low+0(4)
AND poper = v_dnm.
t009b-butag = t009b-butag + 1.
IF s_budat-low+6(2) NE t009b-butag.
v_date_high = s_budat-low - 1.
IF v_donem = 1.
v_date_low = s_budat-low.
v_date_low+4(4) = '0101'.
ELSE.
CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO
v_date_low.
ENDIF.
SELECT * FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
IF bsad-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).
ELSEIF bsad-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr ).
ENDIF.
ENDSELECT.
SELECT * FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
AND gsber IN gsber.
IF bsid-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr ).
ELSEIF bsid-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr ).
ENDIF.
ENDSELECT.
ENDIF.
"opening balance ( þirket bazlý )z1 degeri
i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).
for israel
i_tab-dmbtril_s = i_tab-dmbtr_s .
i_tab-dmbtril_h = i_tab-dmbtr_h .
ENDSELECT.
thanks
mrutyun^ -
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 -
Color a particular cell in ALV
Hi all,
I am working with ALV using class cl_salv_table. i can colorize a particular colomn using cl_salv_column_table->set_color method. I was able to do it. I have done it for an amount column. Now I want to show the amount in some other color if it is 0. Let me know whether that possibility is there or not. If yes, please let me know the corresponding class and method and how we can implement it.
Thank u.Hi ,
fill emphasize of field catelog
wa_fcat-emphasize = color_code eg 'C400' .
Colour code :
Colour is a 4-char field where :
- 1st char = C (color property)
- 2nd char = color code (from 0 to 7)
0 = background color
1 = blue
2 = gray
3 = yellow
4 = blue/gray
5 = green
6 = red
7 = orange
- 3rd char = intensified (0=off, 1=on)
- 4th char = inverse display (0=off, 1=on)
hope it helps ..... -
Possible to have vertical scroll bar for a cell in ALV Grid (using methods)
Hi All,
I have a field with length 100 characters on a ALV Grid (using methods)..User doesn't want to scroll all the 100 characters horizontally to see the whole text rather he wants to have a vertical scroll bar for the cell so that he can scroll vertically.
Is it possible to have split the cell text into lines and have a vertical scroll bar for a cell in ALV Grid?
Regards
Jaker.Thanks for the suggestion Balu.I tried this , but while scrolling,headers also getting scrolled.
Becoz of this , if i scroll down to the last row,headers are getting hidden.
Headers should always be static.only the data should scroll.
Since h:datatable is being rendered as one table , i can div tag for this table alone.
If i have seperate datatable for headers alone i can do this .But i should not use two datatables. -
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. -
Row Selection in ALV Grid created using CL_GUI_ALV_GRID
Hi,
I have ALV grid using cl_gui_alv_grid. I want to capture the row selection and display the selected rows in 2nd ALV grid (using cl_gui_alv_grid).
Method CALL METHOD Grid->get_selected_rows giving right no. of selected records first time and process these records by POST button and hence shows these records in next alv grid. but when i came back to 1st ALV by pressing BACK button on 2nd ALV then if I again select records on the same 1st ALV grid the same Method CALL METHOD Grid->get_selected_rows fires again. but this times it wouldn't give the selected records. I mean first time this gives me correct no. of selected records but 2nd time wouldn't.
how do I capture the row selection.?
Kindly suggest me. helpful answer will be appreciated.
Thanx in Advance.
RobinHi,
Write this code, you have to free the container.
MODULE user_command_0101 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
c_container->free( ).
c_container1->free( ). " this is the container of secondary list.
clear: r_grid, r_grid1, c_container, c_container1.
LEAVE TO SCREEN 100.
ENDCASE.
Regards and Best wishes. -
One editable cell in alv grid using function module
Hello all,
Any one have an idea how to make a single editable cell in alv grid using function module, i mean to say
with out using object oriented programming.
Regards,
PrakashHi,
Using ALV List display it is possible.
Try this.
TYPE-POOLS:SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA:IT_EVENTS TYPE SLIS_T_EVENT.
data: begin of it_chg occurs 0,
index type sy-tabix,
end of it_chg.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
NAME(10) TYPE C,
ZTERM TYPE C,
END OF ITAB.
PERFORM FILL_TABLE.
loop at itab where zterm = 'A'.
it_chg-index = sy-tabix + 3.
" addition 3 IS FOR FIELD LABELS
append it_chg.
clear it_chg.
endloop.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
**fieldcatalog
X_FIELDCAT-FIELDNAME = 'NAME'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-FIELDNAME = 'ZTERM'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
**events
REFRESH:IT_EVENTS.
CLEAR:X_EVENTS,IT_EVENTS.
X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
X_EVENTS-FORM = 'MODIFY_LIST'.
APPEND X_EVENTS TO IT_EVENTS.
CLEAR X_EVENTS.
END-OF-SELECTION.
data lv_repid type sy-repid.
lv_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = lv_REPID
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*& Form FILL_TABLE
text
FORM FILL_TABLE.
ITAB-NAME = 'AAA'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ABC'.
ITAB-ZTERM = 'B'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'TEST'.
ITAB-ZTERM = 'C'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'BBB'.
ITAB-ZTERM = 'D'.
APPEND ITAB.
clear itab.
ITAB-NAME = '123'.
ITAB-ZTERM = 'E'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'GEN'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALV'.
ITAB-ZTERM = 'F'.
APPEND ITAB.
clear itab.
ITAB-NAME = 'ALVTEST'.
ITAB-ZTERM = 'A'.
APPEND ITAB.
clear itab.
ENDFORM. "FILL_TABLE
*& Form MODIFY_LIST
text
FORM MODIFY_LIST.
data: l_lines type i.
describe table itab lines l_lines.
L_LINES = L_LINES + 3.
"because we have 3 lines extra occupied by lables.
"if we have header,i mean top of page add the no.of lines
"how many ever top of page have + 3 for labels.
DO L_LINES TIMES.
read table it_chg with key INDEX = sy-index.
if sy-subrc = 0.
**This code is for reading the out put line
**and modify accordinlg to our requiremnet.
**don't chnage this.
READ LINE SY-INDEX INDEX SY-LSIND.
IF SY-SUBRC = 0.
MODIFY LINE SY-INDEX INDEX SY-LSIND
FIELD FORMAT ITAB-NAME INPUT.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "MODIFY_LIST -
To change the colour of the particular cell of ALV report in Grid display.
Hai Friends,
I have created an Alv report in grid display .In that i want to change the colour of the particular cell.Plz provide the answer with a solved example.
Thank u.This works for a Custom Control and OO ALV in a Dialog Module
TABLES: kna1.
* Data (for the ALV Grid)
TYPES:
BEGIN OF t_alv_data,
cust_id TYPE kunnr, "Customer Number
cust_name TYPE name1_gp, "Customer Name
cust_color TYPE i,
* cell coloring field
color TYPE lvc_t_scol, "Cell coloring
END OF t_alv_data.
DATA:
v_alv_data TYPE t_alv_data,
i_alv_data TYPE STANDARD TABLE OF t_alv_data.
* ALV grid containers and objects
DATA:
o_alv_grid TYPE REF TO cl_gui_alv_grid,
o_alv_cont TYPE REF TO cl_gui_custom_container.
* ALV field catalog
DATA:
i_alv_fc TYPE lvc_t_fcat,
v_alv_fc LIKE lvc_s_fcat.
* ALV Layout (colors)
DATA:
v_alv_layout TYPE lvc_s_layo,
i_alv_color TYPE lvc_t_scol,
v_alv_color TYPE lvc_s_scol,
v_alv_color_cell TYPE lvc_s_colo.
* ALV variant
DATA:
v_alv_variant TYPE disvariant.
PARAMETERS:
p_alvvar TYPE disvariant-variant DEFAULT 'DEFAULT'.
DATA: ok_code LIKE sy-ucomm.
* Class for event handling
* CLASS lcl_event_receiver DEFINITION
* [+] Event listener for the ALV grid
* [+] Handles hotspots and data changes
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
* Hotspot clicking
hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
* Data changed (such as checkbox clicking)
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
* [+] Implementation of the ALV Grid event handler class
CLASS lcl_event_receiver IMPLEMENTATION.
* METHOD hotspot_click *
* [+] Calls evvent_hotspot_click when a hotspot is clicked in the ALV
METHOD hotspot_click.
PERFORM event_hotspot_click
USING e_row_id
e_column_id.
ENDMETHOD. "hotspot_click
* METHOD handle_data_changed *
* [+] Updates the source data when the data in the ALV display has
* been changed, such as by clicking a checkbox.
METHOD handle_data_changed.
DATA: lv_changed TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_good_cells INTO lv_changed
WHERE fieldname = 'CUST_NAME'.
READ TABLE i_alv_data INTO v_alv_data INDEX lv_changed-row_id.
IF sy-subrc = 0.
MOVE lv_changed-value TO v_alv_data-cust_name.
MODIFY i_alv_data FROM v_alv_data INDEX lv_changed-row_id.
ENDIF.
ENDLOOP.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* Reference to the event listener class
DATA: event_receiver TYPE REF TO lcl_event_receiver.
* FORM build_event_listener
* [+] Set the event handler on the ALV Grid
FORM build_event_listener.
* Assigning the event listener to the ALV
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_data_changed FOR o_alv_grid.
SET HANDLER event_receiver->hotspot_click FOR o_alv_grid.
ENDFORM. "build_event_listener
* AT SELECTION-SCREEN
* ON VALUE-REQUEST FOR p_alvvar
* [+] Calls choose_alv_variant to ask the user to select an alv grid
* layout variant
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvvar.
PERFORM choose_alv_variant
CHANGING
p_alvvar
v_alv_variant.
* START_OF_SELECTION
START-OF-SELECTION.
PERFORM get_data.
SET PF-STATUS 'ALVSCREEN' IMMEDIATELY.
CALL SCREEN 2000.
* FORM get_data
* [+] Gets the data for the ALV grid
FORM get_data.
SELECT kunnr name1
INTO (v_alv_data-cust_id,
v_alv_data-cust_name)
FROM kna1.
APPEND v_alv_data TO i_alv_data.
ENDSELECT.
ENDFORM. "get_data
* MODULE build_alv_grid
* THIS SHOULD BE IN THE "PROCESS BEFORE OUTPUT" OF THE ALV SCREEN
* [+] Builds the ALV Grid objects
* [+] Calls to build the field catalog table
* [+] Loads the field catalog table into the ALV Grid
* [+] Loads the table data into the ALV Grid
MODULE build_alv_grid OUTPUT.
SET TITLEBAR '2000'.
* Also enables layout saving
PERFORM set_alv_variant
USING
p_alvvar
CHANGING
v_alv_variant.
* Building the grid and container on the screen
* NOTE: the container name MUST be upper-case
* Also, we don't want the objects to be created if in batch mode!
IF sy-batch IS INITIAL.
CREATE OBJECT o_alv_cont
EXPORTING
container_name = 'O_ALV_TABLE'.
ENDIF.
CREATE OBJECT o_alv_grid
EXPORTING
i_parent = o_alv_cont.
* builds the event listener
PERFORM build_event_listener.
* Color the cells
PERFORM color_cells.
* Build the field catalog
PERFORM build_alv_fc.
* Loads the data into the grid
CALL METHOD o_alv_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_variant = v_alv_variant
is_layout = v_alv_layout
CHANGING
it_outtab = i_alv_data
it_fieldcatalog = i_alv_fc.
ENDMODULE. "build_alv_grid OUTPUT
* FORM build_alv_fc
* [+] Constructs the ALV Grid field catalog table
FORM build_alv_fc.
CLEAR i_alv_fc.
REFRESH i_alv_fc.
* NOTE: the field name MUST be upper-case
* field heading hide hot
* name zero spot just
PERFORM:
alv_field USING 'CUST_ID' 'Cust ID' ' ' 'X' 'R',
alv_field USING 'CUST_NAME' 'Customer Name' ' ' ' ' 'L',
alv_field USING 'CUST_COLOR' 'Color' ' ' ' ' 'R'.
ENDFORM. "build_alv_fc
* FORM alv_field
* [+] Describes and constructs a single field for the ALV Grid field
* catalog. The field length and type are both obtained from the
* actual field passed in to this method.
* [+] Adds the constructed field to the ALV Grid field catalog table
FORM alv_field
USING
p_field_name TYPE c
p_heading TYPE c
p_hide_zeros TYPE c
p_hotspot TYPE c
p_justify TYPE c.
CLEAR v_alv_fc.
DATA:
lv_type(1) TYPE c,
lv_length TYPE i,
lv_heading_length TYPE i.
* get the type and length of this field
FIELD-SYMBOLS <field>.
ASSIGN p_field_name TO <field>.
DESCRIBE FIELD <field> TYPE lv_type OUTPUT-LENGTH lv_length.
* re-adjust the length to the length of the header, if too short
lv_heading_length = strlen( p_heading ).
IF lv_length < lv_heading_length.
lv_length = lv_heading_length.
ENDIF.
* NOTE: the field name MUST be upper-case
v_alv_fc-fieldname = p_field_name.
TRANSLATE v_alv_fc-fieldname TO UPPER CASE.
v_alv_fc-inttype = lv_type.
v_alv_fc-outputlen = lv_length.
v_alv_fc-coltext = p_heading.
v_alv_fc-seltext = p_heading.
v_alv_fc-hotspot = p_hotspot.
* Determining which fields should show zeros
IF p_hide_zeros = 'X'.
v_alv_fc-no_zero = 'X'.
v_alv_fc-lzero = ' '.
ELSE.
v_alv_fc-no_zero = ' '.
v_alv_fc-lzero = 'X'.
ENDIF.
v_alv_fc-just = p_justify.
* Add the field to the field catalog
APPEND v_alv_fc TO i_alv_fc.
ENDFORM. "alv_field
* FORM choose_alv_variant
* [+] Shows a popup that allows the user to choose the layout variant
* for the alv grid of the current program
* [+] Usually called by an AT SELECTION-SCREEN method.
FORM choose_alv_variant
CHANGING
p_variant_name TYPE disvariant-variant
p_variant TYPE disvariant.
CLEAR p_variant.
DATA:
p_exit_check(1) TYPE c.
MOVE sy-repid TO p_variant-report.
CALL FUNCTION 'LVC_VARIANT_F4'
EXPORTING
is_variant = p_variant
i_save = 'A'
IMPORTING
e_exit = p_exit_check
es_variant = p_variant
EXCEPTIONS
not_found = 1
OTHERS = 99.
IF sy-subrc = 0.
IF p_exit_check <> 'X'.
p_variant_name = p_variant-variant.
ENDIF.
ENDIF.
ENDFORM. "choose_alv_variant
* FORM set_alv_variant
* [+] Sets the alv grid layout variant. Used for setting the variant
* when its name is entered in a parameter rather than by using the
* popup, or when loading the variant from a variable of type C
FORM set_alv_variant
USING
p_variant_name TYPE disvariant-variant
CHANGING
p_variant TYPE disvariant.
MOVE sy-repid TO p_variant-report.
p_variant-variant = p_variant_name.
ENDFORM. "set_alv_variant
* FORM color_cells
* [+] Loop through the data and apply coloring
FORM color_cells.
DATA:
my_color TYPE i.
* tell the ALV grid what field in v_alv_data contains color information
v_alv_layout-ctab_fname = 'COLOR'.
my_color = 0.
* loop through each row of the table
LOOP AT i_alv_data INTO v_alv_data.
* clear the variables
CLEAR:
v_alv_color,
v_alv_color_cell,
i_alv_color.
REFRESH:
i_alv_color.
v_alv_data-cust_color = my_color.
PERFORM color_cell USING 'CUST_COLOR' my_color. "negative
* apply the colors
* IF v_alv_data-cust_name = 'Testing Credit'.
* PERFORM color_cell USING 'CUST_NAME' 6. "negative
* ELSEIF v_alv_data-cust_name = 'Goober Goober Also'.
* PERFORM color_cell USING 'CUST_NAME' 5. "positive
* ENDIF.
* set the color data for this table row
v_alv_data-color = i_alv_color.
MODIFY i_alv_data FROM v_alv_data.
my_color = my_color + 1.
IF my_color GT 7.
CLEAR my_color.
ENDIF.
ENDLOOP.
ENDFORM. "color_cells
* FORM color_cell
* [+] Colors a cell in the ALV grid
FORM color_cell
USING
p_cellname TYPE c
p_color TYPE i.
CLEAR:
v_alv_color_cell,
v_alv_color.
* set the color for the cell
* IF p_color = 0.
* v_alv_color_cell-col = 0. "cl_gui_resources=>list_col_background.
* ELSEIF p_color = 1.
* v_alv_color_cell-col = 1. "cl_gui_resources=>list_col_heading.
* ELSEIF p_color = 2.
* v_alv_color_cell-col = 2. "cl_gui_resources=>list_col_normal.
* ELSEIF p_color = 3.
* v_alv_color_cell-col = 3. "cl_gui_resources=>list_col_total.
* ELSEIF p_color = 4.
* v_alv_color_cell-col = 4. "cl_gui_resources=>list_col_key.
* ELSEIF p_color = 5.
* v_alv_color_cell-col = 5. "cl_gui_resources=>list_col_positive.
* ELSEIF p_color = 6.
* v_alv_color_cell-col = 6. "cl_gui_resources=>list_col_negative.
* ELSEIF p_color = 7.
* v_alv_color_cell-col = 7. "cl_gui_resources=>list_col_group.
* ENDIF.
v_alv_color_cell-col = p_color.
v_alv_color-nokeycol = 'X'.
v_alv_color-fname = p_cellname.
* v_alv_color-color = p_color.
v_alv_color-color = v_alv_color_cell.
APPEND v_alv_color TO i_alv_color.
ENDFORM. "color_cell
* FORM event_hotspot_click
* [+] What to do when clicking on a hotspot in the ALV Grid
FORM event_hotspot_click
USING
p_row TYPE lvc_s_row
p_column TYPE lvc_s_col.
DATA:
lv_docnum TYPE kunnr.
READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
IF p_column = 'CUST_ID'.
* call a transaction when the cust_id is clicked
SET PARAMETER ID 'AUN' FIELD v_alv_data-cust_id.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM. "event_hotspot_click
*& Module USER_COMMAND_2000 INPUT
* text
MODULE user_command_2000 INPUT.
CASE ok_code.
WHEN 'BACK'
OR 'STOP'
OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_2000 INPUT
Maybe you are looking for
-
Unresponsive screen and red/blue lines.
Today I took my phone off the charger and as I was trying to access my phone the screen was unresponsive. Then I noticed thin red and blue lines that occasionally show up. I researched this problem, but no help. I restarted my phone, factory restarte
-
Financial Reporting - member Selection
Hi All, I have a scenario where the client wants a report which will have Pov: Period,Year,... Page: Entity(HR Org) Row: Account Column:Employee Name,Job Codes,Position,Grants,and They need the HR Org as a column. for example HR Org: -----HA10(level
-
Help on MERGE - update or insert problem
Dear Everybody, I've a DB with 3 tables to serve for Staff Time Attendance purpose, table tbl_TimeSheetIn(EmpCode, CardID, DateClock, TimeClock) using for input RAW text file exported from TimeMachine, the same for tbl_TimeSheetOut (EmpCode, CardID,
-
Nokia Email Application problem since 06.07.2011
Hi all, I'm using E71. Yesterday my Nokia email stopped synchronising my accounts and just displayed a password request field and a drop down menu for access point (on the usual pink background). However, I can't log in with my account password (the
-
Database Authentication with CMP
Hi all, I was curious if there was any way to have the login credentials for the underlying datasource that my CMP 2.0 entity bean uses be passed in somehow at "access" time (i.e. via some context object, properties, JAAS, etc). Basically I want to h