Need Infor coloring cells in ALV
H all,
I am working ALV in webdynpro. I got two requirements.
1) I need to change the color for the cell Level based on the data.
with different colors
2) I want to color the entire row based on the condition
pl help to proceed
Thanks in advance
Kar
Hello,
Please see this: [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2bweb%2bdynpro%2balv%2b-%2bchange%2bcell%2bcolour%2bbased%2bon%2bcontent].
Regards.
Similar Messages
-
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^ -
Hi Team,
I have a scenario where the ALV table cells are colored based on certain rules. I have successfully achieved this by using the ALV Cell Design. I have a problem specifically with the Cell Design Code = "18", Cell Design Value = " TWO". This color is a pure yellow and when used, it forcefully aligns the cell values to LEFT and the font size is reduced. We specifically need this color in our application. Anyone faced this problem?
Is this a bug in the Cell Design option for code "18"? Is there any other way I can get this color in the ALV cell?
Please help. Any pointers will be appreciated.
Thanks for your time.
Best Regards
SanjayHi Team,
Any thoughts on this issue? Is this a standard bug or there is another way to achieve the same functionality? I tried using cell variants also, but the "Text View" and "Input Field" don't have a background color attribute for them.
Any pointers?
Thanks
Sanjay -
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 -
ALV with colored cell exporting to Excel
Hi all,
I have an ALV-Table in my webdynpro appliation. There are some dropdownbykey fields in the alv and some cells are colored.
After export to excel the colored cells are no more colored.
Is there a possibility to export the color too.
Best regards
MarcusHave you found a solution to this issue? I am searching for the same.
-
In ALV I need to color the records when ever material number changes
Hi ,
I need to color the records in alv when ever the material changes.
for ex : I have 10 records .
1 to 3 records same material number so yellow color
4 to 8 records same material numberso blue color
9 to 10 recrods same material number so yellow color.
Please do the favour..
thank you.
karthik.Hi,
Have one more column in the final table as
ROWCOLOR(4), "reqd only if row is color
Do the coding like this.
Keep canging the Row number to get different colors. Like C410 etc.
LOOP AT T_FINAL.
IF T_FINAL-NUMBER = 'XXX'. " <b>Do your comparison operation here</b>.
T_FINAL-ROWCOLOR = 'C510'.
MODIFY T_FINAL TRANSPORTING ROWCOLOR.
ENDIF.
ENDLOOP.
Also modify the layout giving the field as
DATA : W_LAYOUT TYPE SLIS_LAYOUT_ALV.
W_LAYOUT-INFO_FIELDNAME = 'ROWCOLOR'.
Hope this helps you.
Regards,
Subbu. -
"Custom" grouping and / or colored lines in ALV
Hi!
Two questions:
1. Is it possible to use colors in the ALV for a given set of rows? I'd like to mark rows with a color, which are logically belongs together.
2. Other approach would be to sort the ALV and via that the "similar" rows (i.e. some column values in the rows have the same value ) would be grouped.
The normal ALV grouping feature is too general. E.g if the ALV contains a lot of empty cells, then those cells will be grouped as well, nevertheless they are logically don't belong together -> looks quite weird.
If the custom grouping cannot be realized, then my approach would be the following:
1. Sorting the table. -> rows where the content partially equal are in succession.
2. Manually clear the cells in the second (in my business case only two lines can be partially equal, others are unique) row, which are the same as in the previous row.
3. Use coloring to indicate that these two lines are belonging together.
Best regards,
PeterHi Peter,
It is possible to assign colors to a specific row. But you need to have some work around.
You have to create an extra attribute for each column that you have in your table. The type of that attribute should be of WDUI_TABLE_CELL_DESIGN.
After Instatiating your ALV Component you have to use the following statement for the column that you have to apply the color.
ls_column-r_column->set_cell_design_fieldname( COLUMN1_DESIGN ). Assuming ls_column-r_column will have COLUMN1 as filed name.
There are 16 colors that are defined and each combination from '00' to '15' will define one color.
Look at the structure below. Its a table with 4 columns(2nd and 4th represents colors for first and third columns)
value11 00 value12 00
value21 00 value22 00
value31 02 value32 02.
If you consider the above struture as your output table 3 rows and 4 columns then your third row will be highlighted in green color because 02 represents green. You can hide your second column and fourth column in above example because they represents colors. Use the following statement to hide those columns.
ls_column-r_column->set_visible(
cl_wd_uielement=>e_visible-none ). "ls_column-r_column will have 'COLUMN1_DESIGN'
Let me know if you know more code.
Thank You,
Gajendra. -
Changing colour based on cells for ALV in Web Dynpro ABAP
Hi,
I have a requirement where I need to change the font color for some cells of ALV in Web Dynpro ABAP. I am able to change the font color for whole row or whole column but need to know how to change it based on cells.
My output should be something like the picture attached to this discussion. The coloumns/cells where I need the font colour can change for different rows, based on some internal condition.
Please let me know how to achieve this...... Thank you.
- Divya PosanpallyHi Divya,
Your requirement can be achieved as below
Create an attribute for each column of alv i.e. COLOR_F1, COLOR_F2, COLOR_F3...... COLOR_F10 of type WDY_UIE_LIBRARY_ENUM_TYPE in the context node which holds the color value
Now while configuring ALV, set the field name of semantic color for each column as below
data lv_color_fld_name type string.
data lo_text_view type ref to cl_salv_wd_uie_text_view.
loop at lt_columns into ls_column.
concatenate 'COLOR' ls_column-id into lv_color_fld_name separated by '_'.
lo_text_view ?= ls_column-r_column->get_cell_editor( ).
if lo_text_view is bound.
lo_text_view->SET_SEMANTIC_COLOR_FIELDNAME( value = lv_color_fld_name ).
endif.
endloop.
Set the color based on the condition
loop at lt_data into ls_data.
if ..... "your condition here.
ls_data-color_f1 = cl_wd_text_view=>e_semantic_color-NEGATIVE.
ls_data-color_f2 = cl_wd_text_view=>e_semantic_color-POSITIVE.
elseif...... " another condition
endif.
endloop.
Note: You can optimize the code as per your requirement
Hope this helps you.
Regards,
Rama -
I'm develoing a production report using ALV. In this report i need to color a particuler cell based on Some condition.
i can do it in classic report., but
How could i do this in ALV?*& Report ZALV_DS
REPORT zalv_ds LINE-SIZE 35.
TYPE-POOLS:slis.
TABLES:mara,
makt,
marc.
DATA:BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
werks LIKE marc-werks,
mtart LIKE mara-mtart,
matkl LIKE mara-matkl,
meins LIKE mara-meins,
ntgew LIKE mara-ntgew,
rowcolor(4) TYPE c,
cellcolors TYPE lvc_t_scol,
END OF itab.
DATA:t_fcat TYPE slis_t_fieldcat_alv,
t_eve TYPE slis_t_event.
DATA : st_layout TYPE slis_layout_alv.
SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:mat FOR mara-matnr. " no intervals no-extension.
*PARAMETERS:mat LIKE mara-matnr.
SELECTION-SCREEN:END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_cata USING t_fcat.
PERFORM build_event.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM display_data.
*& Form build_cata
text
-->TEMP_FCAT text
FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.
sy-tvar0 = sy-uname.
WRITE sy-datum TO sy-tvar1.
DATA:wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-ref_tabname = 'MARA'.
wa_fcat-ref_fieldname = 'MATNR'.
wa_fcat-col_pos = 1.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Description'.
wa_fcat-fix_column = 'x'.
wa_fcat-key = 'X'. "To color a column
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
wa_fcat-key = ' '.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MTART'.
wa_fcat-ddic_outputlen = 4.
wa_fcat-row_pos = 2.
wa_fcat-ref_tabname = 'MARA'.
wa_fcat-ref_fieldname = 'MTART'.
wa_fcat-seltext_m = 'Type'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-ref_tabname = 'MARA'.
wa_fcat-row_pos = 2.
wa_fcat-ref_fieldname = 'MATKL'.
wa_fcat-seltext_m = 'Group'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-ref_tabname = ' '.
wa_fcat-ref_fieldname = ' '.
wa_fcat-row_pos = 2.
wa_fcat-seltext_m = 'Measurement Unit'.
APPEND wa_fcat TO temp_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'NTGEW'.
wa_fcat-seltext_m = 'Net Value'.
wa_fcat-row_pos = 2.
wa_fcat-no_out = ' '.
APPEND wa_fcat TO temp_fcat.
ENDFORM. "build_cata
*& Form build_event
text
FORM build_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "build_event
*& Form data_retrieval
text
FORM data_retrieval.
SELECT maramatnr maramtart maramatkl marameins mara~ntgew
maktmaktx marcwerks
INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara INNER JOIN makt ON
maramatnr = maktmatnr
INNER JOIN marc ON
maramatnr = marcmatnr
WHERE mara~matnr IN mat.
SORT itab BY matnr.
DELETE ADJACENT DUPLICATES FROM itab.
ENDFORM. "data_retrieval
*& Form display_data
text
FORM display_data.
*******************************For setting Cell Color*******************************************
DATA ls_cellcolor TYPE lvc_s_scol .
st_layout-coltab_fieldname = 'CELLCOLORS'.
LOOP AT itab WHERE meins EQ 'KG'.
READ TABLE itab INDEX 5 .*
ls_cellcolor-fname = 'MEINS' .
ls_cellcolor-color-col = '1' .
ls_cellcolor-color-int = '1' .
APPEND ls_cellcolor TO itab-cellcolors .
MODIFY itab TRANSPORTING cellcolors .
ENDLOOP.
st_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_DS'
is_layout = st_layout
i_save = 'A'
it_fieldcat = t_fcat
it_events = t_eve
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_data
reward if useful..
Edited by: Dhwani shah on Dec 28, 2007 12:09 PM -
I have a normal report , i need to make it into ALV,
Hi,
i have a normal report and i need to make it into ALV Report in ECC5.0version. when i making it into ALV its giving blank.
can any one help me out to make below code in to ALV report.
REPORT ZSAMPLE line-size 260
line-count 65
no standard page heading.
====================================================================
TABLES *********************************
====================================================================
tables : bseg,
bkpf,
kna1,
bsid,
bsad,
knb1.
data : begin of customer_tab occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
flag(1) type c,
end of customer_tab.
data : begin of customerdoc_tab occurs 0,
kunnr like kna1-kunnr,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
monat like bkpf-monat,
end of customerdoc_tab.
data : begin of doc_tab occurs 0,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
monat like bkpf-monat,
end of doc_tab.
DATA: BEGIN OF BSID_TAB OCCURS 0,
BUKRS LIKE BSID-BUKRS,
PRCTR LIKE BSID-PRCTR,
KUNNR LIKE BSID-KUNNR,
FLAG(1),
UMSKZ LIKE BSID-UMSKZ,
BLART LIKE BSID-BLART,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
NETDT LIKE BSID-ZFBDT,
ZFBDT LIKE BSID-ZFBDT,
BUDAT LIKE BSID-BUDAT,
BLDAT LIKE BSID-BLDAT,
BSCHL LIKE BSID-BSCHL,
DMBTR LIKE BSID-DMBTR,
SHKZG LIKE BSID-SHKZG,
ZBD1T LIKE BSID-ZBD1T,
ZBD2T LIKE BSID-ZBD2T,
ZBD3T LIKE BSID-ZBD3T,
REBZG LIKE BSID-REBZG,
REBZT LIKE BSID-REBZT,
KOART LIKE BSEG-KOART,
SK1DT LIKE FAEDE-SK1DT,
SK2DT LIKE FAEDE-SK2DT,
DAYSD LIKE SY-TABIX,
END OF BSID_TAB.
ranges : r_bukrs for bsid-bukrs,
r_kunnr for kna1-kunnr.
===================================================================
VARIABLES *******************************
===================================================================
data : v_belnr like bseg-belnr,
v_gjahr like bkpf-gjahr,
v_monat like bkpf-monat,
v_ttlc type p,
v_flag(1) type c,
V_COUNT1(4) TYPE N,
V_COUNT2(4) TYPE N,
V_COUNT3(4) TYPE N,
V_COUNT4(4) TYPE N,
V_COUNT5(4) TYPE N,
V_COUNT6(4) TYPE N,
V_COUNT7(4) TYPE N,
V_COUNT8(4) TYPE N,
V_COUNT9(4) TYPE N,
V_COUNT10(4) TYPE N,
V_NET1 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 1
V_NET2 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 2
V_NET3 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 3
V_NET4 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 4
V_NET5 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 5
V_NET6 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 6
V_NET7 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 7
V_NET8 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 8
V_NET9 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 9
V_NET10 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 10
V_NET11 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 11
V_NET LIKE BSID-DMBTR, "Total Balance of Customer
V_ttlNET1 LIKE BSID-DMBTR,
V_ttlNET2 LIKE BSID-DMBTR,
V_ttlNET3 LIKE BSID-DMBTR,
V_ttlNET4 LIKE BSID-DMBTR,
V_ttlNET5 LIKE BSID-DMBTR,
V_ttlNET6 LIKE BSID-DMBTR,
V_ttlNET7 LIKE BSID-DMBTR,
V_ttlNET8 LIKE BSID-DMBTR,
V_ttlNET9 LIKE BSID-DMBTR,
V_ttlNET10 LIKE BSID-DMBTR,
V_ttlNET11 LIKE BSID-DMBTR,
V_ttlNET LIKE BSID-DMBTR,
v_kunnr like bseg-kunnr,
V_BUTXT like t001-butxt.
===================================================================
SELECTION SCREEN ****************************
===================================================================
selection-screen begin of block b1 with frame title text-001.
parameters : p_bukrs like bseg-bukrs obligatory.
select-options : s_kunnr for kna1-kunnr,
s_BRSCH for kna1-BRSCH,
s_REGIO for kna1-REGIO,
s_KTOKD for kna1-KTOKD,
s_BUSAB for knb1-BUSAB.
selection-screen: end of block b1.
selection-screen begin of block b2 with frame title text-003.
PARAMETERS: DAT LIKE SY-DATUM DEFAULT SY-DATUM.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 01(30) TEXT-002.
SELECTION-SCREEN POSITION POS_LOW.
*PARAMETERS: RASTBIS1 LIKE RFPDO1-ALLGROGR DEFAULT '000'.
*PARAMETERS: RASTBIS2 LIKE RFPDO1-ALLGROGR DEFAULT '030'.
*PARAMETERS: RASTBIS3 LIKE RFPDO1-ALLGROGR DEFAULT '060'.
*PARAMETERS: RASTBIS4 LIKE RFPDO1-ALLGROGR DEFAULT '090'.
*PARAMETERS: RASTBIS5 LIKE RFPDO1-ALLGROGR DEFAULT '120'.
PARAMETERS: RASTBIS1(4) type n DEFAULT '0000'.
PARAMETERS: RASTBIS2(4) type n DEFAULT '0030'.
PARAMETERS: RASTBIS3(4) type n DEFAULT '0060'.
PARAMETERS: RASTBIS4(4) type n DEFAULT '0090'.
PARAMETERS: RASTBIS5(4) type n DEFAULT '0120'.
PARAMETERS: RASTBIS6(4) type n DEFAULT '0150'.
PARAMETERS: RASTBIS7(4) type n DEFAULT '0180'.
PARAMETERS: RASTBIS8(4) type n DEFAULT '0210'.
PARAMETERS: RASTBIS9(4) type n DEFAULT '0240'.
PARAMETERS: RASTBIS0(4) type n DEFAULT '0270'.
SELECTION-SCREEN END OF LINE.
Noted item removed as per FI instruction
PARAMETERS: P_STAND AS CHECKBOX default 'X',
P_NOTED AS CHECKBOX ,
P_SPCAL AS CHECKBOX .
selection-screen: end of block b2.
selection-screen begin of block b3 with frame.
PARAMETERS: allgline like RFPDO1-allgline .
Parameters : p_balyes type c radiobutton group grp9 default 'X',
p_balno type c radiobutton group grp9.
selection-screen: end of block b3.
Check for the Select option
AT SELECTION-SCREEN.
IF P_STAND = '' AND P_SPCAL = '' .
MESSAGE E398(00) WITH 'PLEASE CHOOSE AT LEAST ONE G/L INDICATOR!'.
ENDIF.
Check for Company code Authorization
authority-check object 'F_BKPF_BUK'
ID 'BUKRS' FIELD p_bukrs
ID 'ACTVT' FIELD '03'.
if sy-subrc ne 0.
message e398(00) with 'You are not Authorized for CC ' p_bukrs.
Endif.
===================================================================
START-OF-SELECTION ****************************
===================================================================
START-OF-SELECTION.
V_COUNT1 = RASTBIS1 + 1.
V_COUNT2 = RASTBIS2 + 1.
V_COUNT3 = RASTBIS3 + 1.
V_COUNT4 = RASTBIS4 + 1.
V_COUNT5 = RASTBIS5 + 1.
V_COUNT6 = RASTBIS6 + 1.
V_COUNT7 = RASTBIS7 + 1.
V_COUNT8 = RASTBIS8 + 1.
V_COUNT9 = RASTBIS9 + 1.
V_COUNT10 = RASTBIS0 + 1.
perform extract_data.
===================================================================
At line Selection *****************************
===================================================================
at line-selection.
if sy-lilli >= 9 .
refresh r_bukrs.
move p_bukrs to r_bukrs-low.
move 'I' to r_bukrs-sign.
move 'EQ' to r_bukrs-option.
append r_bukrs.
refresh r_kunnr.
move customer_tab-kunnr to r_kunnr-low.
move 'I' to r_kunnr-sign.
move 'EQ' to r_kunnr-option.
append r_kunnr.
submit ZFARVR0040 and return
with p_bukrs = p_bukrs
with dat = dat
with p_stand = p_stand
with p_spcal = P_SPCAL
with s_kunnr in r_kunnr.
endif.
===================================================================
Top of Page *******************************
===================================================================
TOP-OF-PAGE.
SELECT SINGLE BUTXT FROM T001 INTO V_BUTXT
WHERE BUKRS = p_BUKRS .
WRITE:/73'Customers Aging Analysis',140'PAGE NO.',
SY-PAGNO.
WRITE:/002 'COMPANY',
011 P_BUKRS,
017 V_BUTXT,
055 allgline centered,
140 'DATE :',
150 sy-datum .
write:/002 'User',
011 sy-UNAME,
140 'Time :',
150 sy-UZEIT.
SKIP.
format color col_heading intensified off.
WRITE:/ SY-ULINE,
SY-VLINE,002 'Customer',
012 SY-VLINE,013 'Name',
043 SY-VLINE,048 'CURRENT',
061 SY-VLINE,065 'FROM ',V_COUNT1,
079 SY-VLINE,083 'FROM ',V_COUNT2,
097 SY-VLINE,101 'FROM ',V_COUNT3,
115 SY-VLINE,119 'FROM ',V_COUNT4,
133 SY-VLINE,137 'FROM ',V_COUNT5,
151 SY-VLINE,155 'FROM ',V_COUNT6,
169 SY-VLINE,173 'FROM ',V_COUNT7,
187 SY-VLINE,191 'FROM ',V_COUNT8,
205 SY-VLINE,209 'FROM ',V_COUNT9,
223 SY-VLINE,228 'FROM ',V_COUNT10,
243 SY-VLINE,248 'TOTAL',
268 SY-VLINE.
WRITE:/ SY-VLINE,002 'Number',
12 SY-VLINE,
43 SY-VLINE,
061 SY-VLINE,065 'TO ',RASTBIS2,
079 SY-VLINE,083 'TO ',RASTBIS3,
097 SY-VLINE,101 'TO ',RASTBIS4,
115 SY-VLINE,119 'TO ',RASTBIS5,
133 SY-VLINE,137 'FROM ',RASTBIS6,
151 SY-VLINE,155 'FROM ',RASTBIS7,
169 SY-VLINE,173 'FROM ',RASTBIS8,
187 SY-VLINE,191 'FROM ',RASTBIS9,
205 SY-VLINE,209 'FROM ',RASTBIS0,
223 SY-VLINE,
243 SY-VLINE,
268 SY-VLINE,
SY-ULINE.
format color off.
===================================================================
END-OF-SELECTION ***************************
===================================================================
end-of-selection.
===================================================================
Form : Extract_Data *
===================================================================
form extract_data.
Select the Customers
Select t1~kunnr t2~name1
into corresponding fields of table customer_tab
from knb1 as t1 inner join kna1 as t2
on t2~kunnr = t1~kunnr
where t1~bukrs = p_bukrs
and t1~kunnr in s_kunnr
and t1~BUSAB in s_busab
and t2~regio in s_regio
and t2~BRSCH in s_BRSCH
and t2~KTOKD in s_KTOKD.
if sy-subrc <> 0.
message e398(00) with 'No Customers Selected'.
endif.
sort customer_tab.
describe table customer_tab lines v_ttlc.
v_ttlc = v_ttlc + 10.
loop at customer_tab.
v_net1 = 0.
v_net2 = 0.
v_net3 = 0.
v_net4 = 0.
v_net5 = 0.
v_net6 = 0.
v_net7 = 0.
v_net8 = 0.
v_net9 = 0.
v_net10 = 0.
v_net11 = 0.
v_net = 0.
perform calculate_ageing
using
p_bukrs
customer_tab-kunnr
dat
RASTBIS1
RASTBIS2
RASTBIS3
RASTBIS4
RASTBIS5
RASTBIS6
RASTBIS7
RASTBIS8
RASTBIS9
RASTBIS0
P_STAND
' ' "noted item
P_SPCAL
changing
v_net1
v_net2
v_net3
v_net4
v_net5
v_net6
v_net7
v_net8
v_net9
v_net10
v_net11
v_net.
if p_balyes = 'X' or v_net > 0.
format color col_total.
write:/ sy-vline,
002 customer_tab-kunnr,
012 SY-VLINE,013(30) customer_tab-name1,
043 SY-VLINE,044(16) v_net1,
061 SY-VLINE,062(16) v_net2,
079 SY-VLINE,080(16) v_net3,
097 SY-VLINE,098(16) v_net4,
115 SY-VLINE,116(16) v_net5,
133 SY-VLINE,134(16) v_net6,
151 SY-VLINE,152(16) v_net7,
169 SY-VLINE,170(16) v_net8,
187 SY-VLINE,188(16) v_net9,
205 SY-VLINE,206(16) v_net10,
223 SY-VLINE,224(16) v_net11,
239 SY-VLINE,240(16) v_net,
258 SY-VLINE.
format color off.
hide : customer_tab-kunnr.
v_ttlnet1 = v_ttlnet1 + v_net1.
v_ttlnet2 = v_ttlnet2 + v_net2.
v_ttlnet3 = v_ttlnet3 + v_net3.
v_ttlnet4 = v_ttlnet4 + v_net4.
v_ttlnet5 = v_ttlnet5 + v_net5.
v_ttlnet6 = v_ttlnet6 + v_net6.
v_ttlnet7 = v_ttlnet7 + v_net7.
v_ttlnet8 = v_ttlnet8 + v_net8.
v_ttlnet9 = v_ttlnet9 + v_net9.
v_ttlnet10 = v_ttlnet10 + v_net10.
v_ttlnet11 = v_ttlnet11 + v_net11.
v_ttlnet = v_ttlnet + v_net.
endif.
endloop.
ULINE.
format color col_total.
write:/ sy-vline,
012 SY-VLINE,012(30) ' T O T A L',
043 SY-VLINE,044(16) v_ttlnet1,
061 SY-VLINE,062(16) v_ttlnet2,
079 SY-VLINE,080(16) v_ttlnet3,
097 SY-VLINE,098(16) v_ttlnet4,
115 SY-VLINE,116(16) v_ttlnet5,
133 SY-VLINE,134(16) v_ttlnet6,
151 SY-VLINE,152(16) v_ttlnet7,
169 SY-VLINE,170(16) v_ttlnet8,
187 SY-VLINE,188(16) v_ttlnet9,
205 SY-VLINE,206(16) v_ttlnet10,
223 SY-VLINE,224(16) v_ttlnet11,
239 SY-VLINE,240(16) v_ttlnet,
258 SY-VLINE.
format color off.
ULINE.
endform.
Function to Calculate Aging.
Form calculate_ageing using
bukrs
kunnr
dat
RASTBIS1
RASTBIS2
RASTBIS3
RASTBIS4
RASTBIS5
RASTBIS6
RASTBIS7
RASTBIS8
RASTBIS9
RASTBIS0
P_STAND
P_NOTED
P_SPCAL
changing
v_net1
v_net2
v_net3
v_net4
v_net5
v_net6
v_net7
v_net8
v_net9
v_net10
v_net11
v_net.
DATA: BEGIN OF BSID_TAB1 OCCURS 0,
BUKRS LIKE BSID-BUKRS,
PRCTR LIKE BSID-PRCTR,
KUNNR LIKE BSID-KUNNR,
FLAG(1),
UMSKZ LIKE BSID-UMSKZ,
BLART LIKE BSID-BLART,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
NETDT LIKE BSID-ZFBDT,
ZFBDT LIKE BSID-ZFBDT,
BUDAT LIKE BSID-BUDAT,
BLDAT LIKE BSID-BLDAT,
BSCHL LIKE BSID-BSCHL,
DMBTR LIKE BSID-DMBTR,
SHKZG LIKE BSID-SHKZG,
ZBD1T LIKE BSID-ZBD1T,
ZBD2T LIKE BSID-ZBD2T,
ZBD3T LIKE BSID-ZBD3T,
REBZG LIKE BSID-REBZG,
REBZT LIKE BSID-REBZT,
KOART LIKE BSEG-KOART,
SK1DT LIKE FAEDE-SK1DT,
SK2DT LIKE FAEDE-SK2DT,
DAYSD LIKE SY-TABIX,
END OF BSID_TAB1.
RANGES: R_UMSKZ FOR BSID-UMSKZ.
Data : V_ZFBDT Like bsid-ZFBDT,
V_ZBD1T Like bsid-ZBD1T,
V_ZBD2T Like bsid-ZBD2T,
V_ZBD3T Like bsid-ZBD3T,
V_LINES(8) TYPE n.
IF P_NOTED = 'X'. "CHECK NOTED ITEMS
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'D'.
APPEND R_UMSKZ.
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'L'.
APPEND R_UMSKZ.
ENDIF.
IF P_STAND = 'X'. "CHECK STANDARD ITEMS
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = ' '.
APPEND R_UMSKZ.
ENDIF.
IF P_SPCAL = 'X'. "CHECK SPECIAL G/L TRANSACTION
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'A'.
APPEND R_UMSKZ.
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'B'.
APPEND R_UMSKZ.
ENDIF.
SELECT * FROM BSID INTO CORRESPONDING FIELDS OF TABLE BSID_TAB
WHERE BUKRS = BUKRS AND
budat <= dat AND
KUNNR = KUNNR AND
UMSKZ in R_UMSKZ.
SELECT * FROM BSAD appending CORRESPONDING FIELDS OF TABLE BSID_TAB
WHERE BUKRS = BUKRS AND
budat <= dat AND
augdt >= dat AND
KUNNR = KUNNR AND
UMSKZ in R_UMSKZ.
DESCRIBE TABLE BSID_TAB LINES V_LINES.
LOOP AT BSID_TAB.
if bsid_tab-BLART = 'DZ'.
Select single ZFBDT ZBD1T ZBD2T ZBD3T
into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
from bsid where BUKRS = BUKRS
and kunnr = bsid_tab-kunnr
and BELNR = bsid_tab-REBZG.
if sy-subrc = 0.
bsid_tab-ZFBDT = V_ZFBDT.
bsid_tab-ZBD1T = V_ZBD1T.
bsid_tab-ZBD2T = V_ZBD2T.
bsid_tab-ZBD3T = V_ZBD3T.
else.
Select single ZFBDT ZBD1T ZBD2T ZBD3T
into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
from bsad where BUKRS = BUKRS
and kunnr = bsid_tab-kunnr
and BELNR = bsid_tab-REBZG.
if sy-subrc <> 0.
bsid_tab-ZFBDT = V_ZFBDT.
bsid_tab-ZBD1T = V_ZBD1T.
bsid_tab-ZBD2T = V_ZBD2T.
bsid_tab-ZBD3T = V_ZBD3T.
endif.
endif.
endif.
IF BSID_TAB-SHKZG = 'H'.
BSID_TAB-DMBTR = BSID_TAB-DMBTR * ( - 1 ).
ENDIF.
bsid_tab-netdt = bsid_tab-ZFBDT.
bsid_tab-netdt = bsid_tab-budat.
bsid_tab-koart = 'D'.
MODIFY BSID_TAB.
PERFORM CALC_DUE_DATE USING BSID_TAB.
BSID_TAB-DAYSD = DAT - BSID_TAB-NETDT.
IF BSID_TAB-DAYSD <= RASTBIS1.
V_NET1 = V_NET1 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS2.
V_NET2 = V_NET2 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS3.
V_NET3 = V_NET3 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS4.
V_NET4 = V_NET4 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
V_NET5 = V_NET5 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS6.
V_NET6 = V_NET6 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS7.
V_NET7 = V_NET7 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
V_NET8 = V_NET8 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS9.
V_NET9 = V_NET9 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS0.
V_NET10 = V_NET10 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD > RASTBIS0.
V_NET11 = V_NET11 + BSID_TAB-DMBTR.
ENDIF.
V_NET = V_NET + BSID_TAB-DMBTR.
MODIFY BSID_TAB.
ENDLOOP.
endform.
Calculate Due Date
FORM CALC_DUE_DATE USING P_BSID_TAB STRUCTURE BSID_TAB.
DATA : REFE TYPE P.
IF P_BSID_TAB-KOART = 'K' OR P_BSID_TAB-KOART = 'D'.
IF P_BSID_TAB-ZFBDT IS INITIAL.
P_BSID_TAB-ZFBDT = P_BSID_TAB-BLDAT.
ENDIF.
*Nettofälligkeit bestimmen--
IF NOT P_BSID_TAB-ZBD3T IS INITIAL.
REFE = P_BSID_TAB-ZBD3T.
ELSE.
IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
REFE = P_BSID_TAB-ZBD2T.
ELSE.
REFE = P_BSID_TAB-ZBD1T.
ENDIF.
ENDIF.
*Nichtrechnungsbezogene Gutschriften sind sofort fällig--
IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
IF P_BSID_TAB-REBZG IS INITIAL.
REFE = 0.
ENDIF.
ENDIF.
P_BSID_TAB-NETDT = P_BSID_TAB-ZFBDT + REFE.
*Skontofälligkeiten bestimmen--
IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
P_BSID_TAB-SK2DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD2T.
ELSE.
P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
ENDIF.
IF NOT P_BSID_TAB-ZBD1T IS INITIAL
OR NOT P_BSID_TAB-ZBD2T IS INITIAL.
P_BSID_TAB-SK1DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD1T.
ELSE.
P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
ENDIF.
*Nichtrechnungsbezogene Gutschriften sind sofort fällig--
IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
IF P_BSID_TAB-REBZG IS INITIAL.
P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
ENDIF.
ENDIF.
ELSE.
MESSAGE E122 RAISING ACCOUNT_TYPE_NOT_SUPPORTED.
ENDIF.
E_FAEDE = FAEDE.
ENDFORM.Hi,
As vijay said...
1.Declare One final Internal table which you want to show the data
2 . populate the fieldcatalog using the FM or Manually using the itab in step1
3. Collect the Data into final internal table which you created in Step 1.
4. pass the fieldcat and Internal table to ALV FM.
chk out the prg below i have created your program but i donn knw wht are the output fields... chk your prg
*REPORT ZALVTEST .
REPORT ZSAMPLE line-size 260
line-count 65
no standard page heading.
TYPE-POOLS: SLIS.
====================================================================
TABLES *********************************
====================================================================
tables : bseg,
bkpf,
kna1,
bsid,
bsad,
knb1.
data : begin of customer_tab occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
flag(1) type c,
end of customer_tab.
data : begin of customerdoc_tab occurs 0,
kunnr like kna1-kunnr,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
monat like bkpf-monat,
end of customerdoc_tab.
data : begin of doc_tab occurs 0,
belnr like bkpf-belnr,
gjahr like bkpf-gjahr,
monat like bkpf-monat,
end of doc_tab.
DATA: BEGIN OF BSID_TAB OCCURS 0,
BUKRS LIKE BSID-BUKRS,
PRCTR LIKE BSID-PRCTR,
KUNNR LIKE BSID-KUNNR,
FLAG(1),
UMSKZ LIKE BSID-UMSKZ,
BLART LIKE BSID-BLART,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
NETDT LIKE BSID-ZFBDT,
ZFBDT LIKE BSID-ZFBDT,
BUDAT LIKE BSID-BUDAT,
BLDAT LIKE BSID-BLDAT,
BSCHL LIKE BSID-BSCHL,
DMBTR LIKE BSID-DMBTR,
SHKZG LIKE BSID-SHKZG,
ZBD1T LIKE BSID-ZBD1T,
ZBD2T LIKE BSID-ZBD2T,
ZBD3T LIKE BSID-ZBD3T,
REBZG LIKE BSID-REBZG,
REBZT LIKE BSID-REBZT,
KOART LIKE BSEG-KOART,
SK1DT LIKE FAEDE-SK1DT,
SK2DT LIKE FAEDE-SK2DT,
DAYSD LIKE SY-TABIX,
END OF BSID_TAB.
ranges : r_bukrs for bsid-bukrs,
r_kunnr for kna1-kunnr.
===================================================================
VARIABLES *******************************
===================================================================
data : v_belnr like bseg-belnr,
v_gjahr like bkpf-gjahr,
v_monat like bkpf-monat,
v_ttlc type p,
v_flag(1) type c,
V_COUNT1(4) TYPE N,
V_COUNT2(4) TYPE N,
V_COUNT3(4) TYPE N,
V_COUNT4(4) TYPE N,
V_COUNT5(4) TYPE N,
V_COUNT6(4) TYPE N,
V_COUNT7(4) TYPE N,
V_COUNT8(4) TYPE N,
V_COUNT9(4) TYPE N,
V_COUNT10(4) TYPE N,
V_NET1 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 1
V_NET2 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 2
V_NET3 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 3
V_NET4 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 4
V_NET5 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 5
V_NET6 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 6
V_NET7 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 7
V_NET8 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 8
V_NET9 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 9
V_NET10 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 10
V_NET11 LIKE BSID-DMBTR, "CALCULATE CUSTOMER AGE 11
V_NET LIKE BSID-DMBTR, "Total Balance of Customer
V_ttlNET1 LIKE BSID-DMBTR,
V_ttlNET2 LIKE BSID-DMBTR,
V_ttlNET3 LIKE BSID-DMBTR,
V_ttlNET4 LIKE BSID-DMBTR,
V_ttlNET5 LIKE BSID-DMBTR,
V_ttlNET6 LIKE BSID-DMBTR,
V_ttlNET7 LIKE BSID-DMBTR,
V_ttlNET8 LIKE BSID-DMBTR,
V_ttlNET9 LIKE BSID-DMBTR,
V_ttlNET10 LIKE BSID-DMBTR,
V_ttlNET11 LIKE BSID-DMBTR,
V_ttlNET LIKE BSID-DMBTR,
v_kunnr like bseg-kunnr,
V_BUTXT like t001-butxt.
********Declare Data Areas for List Viewer ***********
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT,
FIELD TYPE SLIS_FIELDNAME,
COL_POS TYPE I ,
PGM LIKE SY-REPID,
FIELD_VALUE(20),
TABLE_NAME(10).
===================================================================
SELECTION SCREEN ****************************
===================================================================
selection-screen begin of block b1 with frame title text-001.
parameters : p_bukrs like bseg-bukrs obligatory.
select-options : s_kunnr for kna1-kunnr,
s_BRSCH for kna1-BRSCH,
s_REGIO for kna1-REGIO,
s_KTOKD for kna1-KTOKD,
s_BUSAB for knb1-BUSAB.
selection-screen: end of block b1.
selection-screen begin of block b2 with frame title text-003.
PARAMETERS: DAT LIKE SY-DATUM DEFAULT SY-DATUM.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 01(30) TEXT-002.
SELECTION-SCREEN POSITION POS_LOW.
*PARAMETERS: RASTBIS1 LIKE RFPDO1-ALLGROGR DEFAULT '000'.
*PARAMETERS: RASTBIS2 LIKE RFPDO1-ALLGROGR DEFAULT '030'.
*PARAMETERS: RASTBIS3 LIKE RFPDO1-ALLGROGR DEFAULT '060'.
*PARAMETERS: RASTBIS4 LIKE RFPDO1-ALLGROGR DEFAULT '090'.
*PARAMETERS: RASTBIS5 LIKE RFPDO1-ALLGROGR DEFAULT '120'.
PARAMETERS: RASTBIS1(4) type n DEFAULT '0000'.
PARAMETERS: RASTBIS2(4) type n DEFAULT '0030'.
PARAMETERS: RASTBIS3(4) type n DEFAULT '0060'.
PARAMETERS: RASTBIS4(4) type n DEFAULT '0090'.
PARAMETERS: RASTBIS5(4) type n DEFAULT '0120'.
PARAMETERS: RASTBIS6(4) type n DEFAULT '0150'.
PARAMETERS: RASTBIS7(4) type n DEFAULT '0180'.
PARAMETERS: RASTBIS8(4) type n DEFAULT '0210'.
PARAMETERS: RASTBIS9(4) type n DEFAULT '0240'.
PARAMETERS: RASTBIS0(4) type n DEFAULT '0270'.
SELECTION-SCREEN END OF LINE.
Noted item removed as per FI instruction
PARAMETERS: P_STAND AS CHECKBOX default 'X',
P_NOTED AS CHECKBOX ,
P_SPCAL AS CHECKBOX .
selection-screen: end of block b2.
selection-screen begin of block b3 with frame.
PARAMETERS: allgline like RFPDO1-allgline .
Parameters : p_balyes type c radiobutton group grp9 default 'X',
p_balno type c radiobutton group grp9.
selection-screen: end of block b3.
Check for the Select option
AT SELECTION-SCREEN.
IF P_STAND = '' AND P_SPCAL = '' .
MESSAGE E398(00) WITH 'PLEASE CHOOSE AT LEAST ONE G/L INDICATOR!'.
ENDIF.
Check for Company code Authorization
authority-check object 'F_BKPF_BUK'
ID 'BUKRS' FIELD p_bukrs
ID 'ACTVT' FIELD '03'.
if sy-subrc ne 0.
message e398(00) with 'You are not Authorized for CC ' p_bukrs.
Endif.
===================================================================
START-OF-SELECTION ****************************
===================================================================
START-OF-SELECTION.
V_COUNT1 = RASTBIS1 + 1.
V_COUNT2 = RASTBIS2 + 1.
V_COUNT3 = RASTBIS3 + 1.
V_COUNT4 = RASTBIS4 + 1.
V_COUNT5 = RASTBIS5 + 1.
V_COUNT6 = RASTBIS6 + 1.
V_COUNT7 = RASTBIS7 + 1.
V_COUNT8 = RASTBIS8 + 1.
V_COUNT9 = RASTBIS9 + 1.
V_COUNT10 = RASTBIS0 + 1.
perform extract_data.
Build Field Catalogs **************************
PERFORM BUILD_FIELDCAT.
*******Start List Viewer *******************************
PERFORM START_LIST_VIEWER.
===================================================================
At line Selection *****************************
===================================================================
at line-selection.
if sy-lilli >= 9 .
refresh r_bukrs.
move p_bukrs to r_bukrs-low.
move 'I' to r_bukrs-sign.
move 'EQ' to r_bukrs-option.
append r_bukrs.
refresh r_kunnr.
move customer_tab-kunnr to r_kunnr-low.
move 'I' to r_kunnr-sign.
move 'EQ' to r_kunnr-option.
append r_kunnr.
submit ZFARVR0040 and return
with p_bukrs = p_bukrs
with dat = dat
with p_stand = p_stand
with p_spcal = P_SPCAL
with s_kunnr in r_kunnr.
endif.
===================================================================
Top of Page *******************************
===================================================================
TOP-OF-PAGE.
SELECT SINGLE BUTXT FROM T001 INTO V_BUTXT
WHERE BUKRS = p_BUKRS .
WRITE:/73'Customers Aging Analysis',140'PAGE NO.',
SY-PAGNO.
WRITE:/002 'COMPANY',
011 P_BUKRS,
017 V_BUTXT,
055 allgline centered,
140 'DATE :',
150 sy-datum .
write:/002 'User',
011 sy-UNAME,
140 'Time :',
150 sy-UZEIT.
SKIP.
format color col_heading intensified off.
WRITE:/ SY-ULINE,
SY-VLINE,002 'Customer',
012 SY-VLINE,013 'Name',
043 SY-VLINE,048 'CURRENT',
061 SY-VLINE,065 'FROM ',V_COUNT1,
079 SY-VLINE,083 'FROM ',V_COUNT2,
097 SY-VLINE,101 'FROM ',V_COUNT3,
115 SY-VLINE,119 'FROM ',V_COUNT4,
133 SY-VLINE,137 'FROM ',V_COUNT5,
151 SY-VLINE,155 'FROM ',V_COUNT6,
169 SY-VLINE,173 'FROM ',V_COUNT7,
187 SY-VLINE,191 'FROM ',V_COUNT8,
205 SY-VLINE,209 'FROM ',V_COUNT9,
223 SY-VLINE,228 'FROM ',V_COUNT10,
243 SY-VLINE,248 'TOTAL',
268 SY-VLINE.
WRITE:/ SY-VLINE,002 'Number',
12 SY-VLINE,
43 SY-VLINE,
061 SY-VLINE,065 'TO ',RASTBIS2,
079 SY-VLINE,083 'TO ',RASTBIS3,
097 SY-VLINE,101 'TO ',RASTBIS4,
115 SY-VLINE,119 'TO ',RASTBIS5,
133 SY-VLINE,137 'FROM ',RASTBIS6,
151 SY-VLINE,155 'FROM ',RASTBIS7,
169 SY-VLINE,173 'FROM ',RASTBIS8,
187 SY-VLINE,191 'FROM ',RASTBIS9,
205 SY-VLINE,209 'FROM ',RASTBIS0,
223 SY-VLINE,
243 SY-VLINE,
268 SY-VLINE,
SY-ULINE.
format color off.
===================================================================
END-OF-SELECTION ***************************
===================================================================
end-of-selection.
===================================================================
Form : Extract_Data *
===================================================================
form extract_data.
Select the Customers
Select t1~kunnr t2~name1
into corresponding fields of table customer_tab
from knb1 as t1 inner join kna1 as t2
on t2~kunnr = t1~kunnr
where t1~bukrs = p_bukrs
and t1~kunnr in s_kunnr
and t1~BUSAB in s_busab
and t2~regio in s_regio
and t2~BRSCH in s_BRSCH
and t2~KTOKD in s_KTOKD.
if sy-subrc <> 0.
message e398(00) with 'No Customers Selected'.
endif.
sort customer_tab.
describe table customer_tab lines v_ttlc.
v_ttlc = v_ttlc + 10.
loop at customer_tab.
v_net1 = 0.
v_net2 = 0.
v_net3 = 0.
v_net4 = 0.
v_net5 = 0.
v_net6 = 0.
v_net7 = 0.
v_net8 = 0.
v_net9 = 0.
v_net10 = 0.
v_net11 = 0.
v_net = 0.
perform calculate_ageing
using
p_bukrs
customer_tab-kunnr
dat
RASTBIS1
RASTBIS2
RASTBIS3
RASTBIS4
RASTBIS5
RASTBIS6
RASTBIS7
RASTBIS8
RASTBIS9
RASTBIS0
P_STAND
' ' "noted item
P_SPCAL
changing
v_net1
v_net2
v_net3
v_net4
v_net5
v_net6
v_net7
v_net8
v_net9
v_net10
v_net11
v_net.
if p_balyes = 'X' or v_net > 0.
format color col_total.
write:/ sy-vline,
002 customer_tab-kunnr,
012 SY-VLINE,013(30) customer_tab-name1,
043 SY-VLINE,044(16) v_net1,
061 SY-VLINE,062(16) v_net2,
079 SY-VLINE,080(16) v_net3,
097 SY-VLINE,098(16) v_net4,
115 SY-VLINE,116(16) v_net5,
133 SY-VLINE,134(16) v_net6,
151 SY-VLINE,152(16) v_net7,
169 SY-VLINE,170(16) v_net8,
187 SY-VLINE,188(16) v_net9,
205 SY-VLINE,206(16) v_net10,
223 SY-VLINE,224(16) v_net11,
239 SY-VLINE,240(16) v_net,
258 SY-VLINE.
format color off.
hide : customer_tab-kunnr.
v_ttlnet1 = v_ttlnet1 + v_net1.
v_ttlnet2 = v_ttlnet2 + v_net2.
v_ttlnet3 = v_ttlnet3 + v_net3.
v_ttlnet4 = v_ttlnet4 + v_net4.
v_ttlnet5 = v_ttlnet5 + v_net5.
v_ttlnet6 = v_ttlnet6 + v_net6.
v_ttlnet7 = v_ttlnet7 + v_net7.
v_ttlnet8 = v_ttlnet8 + v_net8.
v_ttlnet9 = v_ttlnet9 + v_net9.
v_ttlnet10 = v_ttlnet10 + v_net10.
v_ttlnet11 = v_ttlnet11 + v_net11.
v_ttlnet = v_ttlnet + v_net.
endif.
endloop.
ULINE.
format color col_total.
write:/ sy-vline,
012 SY-VLINE,012(30) ' T O T A L',
043 SY-VLINE,044(16) v_ttlnet1,
061 SY-VLINE,062(16) v_ttlnet2,
079 SY-VLINE,080(16) v_ttlnet3,
097 SY-VLINE,098(16) v_ttlnet4,
115 SY-VLINE,116(16) v_ttlnet5,
133 SY-VLINE,134(16) v_ttlnet6,
151 SY-VLINE,152(16) v_ttlnet7,
169 SY-VLINE,170(16) v_ttlnet8,
187 SY-VLINE,188(16) v_ttlnet9,
205 SY-VLINE,206(16) v_ttlnet10,
223 SY-VLINE,224(16) v_ttlnet11,
239 SY-VLINE,240(16) v_ttlnet,
258 SY-VLINE.
format color off.
ULINE.
endform.
Function to Calculate Aging.
Form calculate_ageing using
bukrs
kunnr
dat
RASTBIS1
RASTBIS2
RASTBIS3
RASTBIS4
RASTBIS5
RASTBIS6
RASTBIS7
RASTBIS8
RASTBIS9
RASTBIS0
P_STAND
P_NOTED
P_SPCAL
changing
v_net1
v_net2
v_net3
v_net4
v_net5
v_net6
v_net7
v_net8
v_net9
v_net10
v_net11
v_net.
DATA: BEGIN OF BSID_TAB1 OCCURS 0,
BUKRS LIKE BSID-BUKRS,
PRCTR LIKE BSID-PRCTR,
KUNNR LIKE BSID-KUNNR,
FLAG(1),
UMSKZ LIKE BSID-UMSKZ,
BLART LIKE BSID-BLART,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
NETDT LIKE BSID-ZFBDT,
ZFBDT LIKE BSID-ZFBDT,
BUDAT LIKE BSID-BUDAT,
BLDAT LIKE BSID-BLDAT,
BSCHL LIKE BSID-BSCHL,
DMBTR LIKE BSID-DMBTR,
SHKZG LIKE BSID-SHKZG,
ZBD1T LIKE BSID-ZBD1T,
ZBD2T LIKE BSID-ZBD2T,
ZBD3T LIKE BSID-ZBD3T,
REBZG LIKE BSID-REBZG,
REBZT LIKE BSID-REBZT,
KOART LIKE BSEG-KOART,
SK1DT LIKE FAEDE-SK1DT,
SK2DT LIKE FAEDE-SK2DT,
DAYSD LIKE SY-TABIX,
END OF BSID_TAB1.
RANGES: R_UMSKZ FOR BSID-UMSKZ.
Data : V_ZFBDT Like bsid-ZFBDT,
V_ZBD1T Like bsid-ZBD1T,
V_ZBD2T Like bsid-ZBD2T,
V_ZBD3T Like bsid-ZBD3T,
V_LINES(8) TYPE n.
IF P_NOTED = 'X'. "CHECK NOTED ITEMS
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'D'.
APPEND R_UMSKZ.
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'L'.
APPEND R_UMSKZ.
ENDIF.
IF P_STAND = 'X'. "CHECK STANDARD ITEMS
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = ' '.
APPEND R_UMSKZ.
ENDIF.
IF P_SPCAL = 'X'. "CHECK SPECIAL G/L TRANSACTION
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'A'.
APPEND R_UMSKZ.
R_UMSKZ-SIGN = 'I'.
R_UMSKZ-OPTION = 'EQ'.
R_UMSKZ-LOW = 'B'.
APPEND R_UMSKZ.
ENDIF.
SELECT * FROM BSID INTO CORRESPONDING FIELDS OF TABLE BSID_TAB
WHERE BUKRS = BUKRS AND
budat <= dat AND
KUNNR = KUNNR AND
UMSKZ in R_UMSKZ.
SELECT * FROM BSAD appending CORRESPONDING FIELDS OF TABLE BSID_TAB
WHERE BUKRS = BUKRS AND
budat <= dat AND
augdt >= dat AND
KUNNR = KUNNR AND
UMSKZ in R_UMSKZ.
DESCRIBE TABLE BSID_TAB LINES V_LINES.
LOOP AT BSID_TAB.
if bsid_tab-BLART = 'DZ'.
Select single ZFBDT ZBD1T ZBD2T ZBD3T
into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
from bsid where BUKRS = BUKRS
and kunnr = bsid_tab-kunnr
and BELNR = bsid_tab-REBZG.
if sy-subrc = 0.
bsid_tab-ZFBDT = V_ZFBDT.
bsid_tab-ZBD1T = V_ZBD1T.
bsid_tab-ZBD2T = V_ZBD2T.
bsid_tab-ZBD3T = V_ZBD3T.
else.
Select single ZFBDT ZBD1T ZBD2T ZBD3T
into (V_ZFBDT,V_ZBD1T,V_ZBD2T,V_ZBD3T)
from bsad where BUKRS = BUKRS
and kunnr = bsid_tab-kunnr
and BELNR = bsid_tab-REBZG.
if sy-subrc <> 0.
bsid_tab-ZFBDT = V_ZFBDT.
bsid_tab-ZBD1T = V_ZBD1T.
bsid_tab-ZBD2T = V_ZBD2T.
bsid_tab-ZBD3T = V_ZBD3T.
endif.
endif.
endif.
IF BSID_TAB-SHKZG = 'H'.
BSID_TAB-DMBTR = BSID_TAB-DMBTR * ( - 1 ).
ENDIF.
bsid_tab-netdt = bsid_tab-ZFBDT.
bsid_tab-netdt = bsid_tab-budat.
bsid_tab-koart = 'D'.
MODIFY BSID_TAB.
PERFORM CALC_DUE_DATE USING BSID_TAB.
BSID_TAB-DAYSD = DAT - BSID_TAB-NETDT.
IF BSID_TAB-DAYSD <= RASTBIS1.
V_NET1 = V_NET1 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS2.
V_NET2 = V_NET2 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS3.
V_NET3 = V_NET3 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS4.
V_NET4 = V_NET4 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
V_NET5 = V_NET5 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS6.
V_NET6 = V_NET6 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS7.
V_NET7 = V_NET7 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS5.
V_NET8 = V_NET8 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS9.
V_NET9 = V_NET9 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD <= RASTBIS0.
V_NET10 = V_NET10 + BSID_TAB-DMBTR.
ELSEIF BSID_TAB-DAYSD > RASTBIS0.
V_NET11 = V_NET11 + BSID_TAB-DMBTR.
ENDIF.
V_NET = V_NET + BSID_TAB-DMBTR.
MODIFY BSID_TAB.
ENDLOOP.
endform.
Calculate Due Date
FORM CALC_DUE_DATE USING P_BSID_TAB STRUCTURE BSID_TAB.
DATA : REFE TYPE P.
IF P_BSID_TAB-KOART = 'K' OR P_BSID_TAB-KOART = 'D'.
IF P_BSID_TAB-ZFBDT IS INITIAL.
P_BSID_TAB-ZFBDT = P_BSID_TAB-BLDAT.
ENDIF.
*Nettofälligkeit bestimmen--
IF NOT P_BSID_TAB-ZBD3T IS INITIAL.
REFE = P_BSID_TAB-ZBD3T.
ELSE.
IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
REFE = P_BSID_TAB-ZBD2T.
ELSE.
REFE = P_BSID_TAB-ZBD1T.
ENDIF.
ENDIF.
*Nichtrechnungsbezogene Gutschriften sind sofort fällig--
IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
IF P_BSID_TAB-REBZG IS INITIAL.
REFE = 0.
ENDIF.
ENDIF.
P_BSID_TAB-NETDT = P_BSID_TAB-ZFBDT + REFE.
*Skontofälligkeiten bestimmen--
IF NOT P_BSID_TAB-ZBD2T IS INITIAL.
P_BSID_TAB-SK2DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD2T.
ELSE.
P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
ENDIF.
IF NOT P_BSID_TAB-ZBD1T IS INITIAL
OR NOT P_BSID_TAB-ZBD2T IS INITIAL.
P_BSID_TAB-SK1DT = P_BSID_TAB-ZFBDT + P_BSID_TAB-ZBD1T.
ELSE.
P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
ENDIF.
*Nichtrechnungsbezogene Gutschriften sind sofort fällig--
IF P_BSID_TAB-KOART = 'D' AND P_BSID_TAB-SHKZG = 'H'
OR P_BSID_TAB-KOART = 'K' AND P_BSID_TAB-SHKZG = 'S'.
IF P_BSID_TAB-REBZG IS INITIAL.
P_BSID_TAB-SK2DT = P_BSID_TAB-NETDT.
P_BSID_TAB-SK1DT = P_BSID_TAB-NETDT.
ENDIF.
ENDIF.
ELSE.
MESSAGE E122 RAISING ACCOUNT_TYPE_NOT_SUPPORTED.
ENDIF.
E_FAEDE = FAEDE.
ENDFORM.
*& Form BUILD_FIELDCAT
FORM BUILD_FIELDCAT .
PGM = SY-REPID.
FIELD = 'give field name'.
TABLE_NAME = 'give table name'.
PERFORM FIELDCAT_FILL USING FIELD.
and so on for the no. of fields you want to display
ENDFORM. " BUILD_FIELDCAT
*& Form START_LIST_VIEWER
FORM START_LIST_VIEWER.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = PGM
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = FINAL TAB(OUTPUT STATEMENTS TABLE)
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " START_LIST_VIEWER
*& Form FIELDCAT_FILL
text
FORM FIELDCAT_FILL USING FIELD_VALUE.
ADD 1 TO COL_POS.
FIELDCAT_LN-REF_TABNAME = TABLE_NAME.
FIELDCAT_LN-FIELDNAME = FIELD_VALUE.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-COL_POS = COL_POS.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM. " FIELDCAT_FILL
Reward points if you find this helpful
Regards,
Harini -
Problem with coloring cells in dynamic fieldcatalog
Hi All,
I am trying to color cells based on the values in the cells. Here we are using dynamic fieldcatalog and internal table to build the ALV grid.I am getting problem in adding a field to the fieldcatlog which is of type lvc_t_scol. This Part of the code is used to build fieldcatlog dynamically.
DEFINE add_cat.
add 1 to lv_count1.
lwa_fldcat-col_pos = lv_count1.
lwa_fldcat-fieldname = &1 .
lwa_fldcat-reptext = &2.
lwa_fldcat-inttype = &3.
lwa_fldcat-intlen = &4.
append lwa_fldcat to lt_fldcat .
END-OF-DEFINITION.
*Add Columns to the fieldcatalog
add_cat c_proj 'Project' 'C' '30'.
add_cat c_cust 'Customer' 'C' '30'.
lwa_fldcat-col_pos = 12.
lwa_fldcat-fieldname = 'cellcolor' .
lwa_fldcat-reptext = 'cell color'.
<b> lwa_fldcat-inttype = 'lvc_t_scol'.</b>
append lwa_fldcat to lt_fldcat .
Here i want to assign internal table(lvc_t_scol) to the fieldcatalog as a field.But lwa_fldcat-inttype is of size 1 which will take one char. Is there any way that we can assign field of type internal table to the field catalog. Becoz of this i am unable to color cells in my ALV grid.
ThanksIt is not possible with the METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
I have tried to do it with the code and I got the dynamic table created after at the end of the program.
In the code,
<DYN_TABLE> has same effect as your <table> variable
<DYN_WA> has same effect as your <HEADER>
REPORT ZTEST_NP_DYNAMIC.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
FIELD-SYMBOLS: <FS> TYPE ANY.
* To generate the Dyanmic table with the COLOR
DATA: LS_SOURCE TYPE STRING.
DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
DATA: L_NAME LIKE SY-REPID.
DATA: L_MESSAGE(240) TYPE C,
L_LINE TYPE I,
L_WORD(72) TYPE C.
DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
APPEND LT_SOURCE.
LT_SOURCE = 'FORM TABLE_CREATE USING I_FS TYPE ANY.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
APPEND LT_SOURCE.
* you can add your fields here.....
LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '. " <<
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
APPEND LT_SOURCE.
LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'I_FS = POINTER.'.
APPEND LT_SOURCE.
LT_SOURCE = 'ENDFORM. '.
APPEND LT_SOURCE.
L_NAME = 'ZTEST_SUBROUTINE_POOL'.
CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD. "#EC CI_GENERATE
ENDCATCH.
IF NOT L_MESSAGE IS INITIAL.
MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
ENDIF.
ASSIGN DY_TABLE TO <FS>.
PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
* Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Write: 'bye'.
Regards,
Naimesh Patel -
How to change the selected row color in an alv grid display ?
Hello ,
I WANT TO CHANGE THE COLOR OF THE SELECTED RECORDS IN AN ALV GRID DISPLAY ?
ITS URGENT..
WILL BE REWARDED...hai Ssnagh Samala
EXicut This report >
Hope It Will Meet U r Requirement.
If Found Helpfull Reward.
REPORT zcuitest_alv_07.
Use of colours in ALV grid (cell, line and column) *
Table
TABLES : mara.
Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*& Module status_2000 OUTPUT
text
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*& Module user_command_2000 INPUT
text
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*& Module alv_grid OUTPUT
text
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*& Form create_objects
text
--> p1 text
<-- p2 text
FORM create_objects.
Ratio must be included in http://5..95
CREATE OBJECT w_docking_container
EXPORTING
ratio = 95
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_docking_container.
ENDFORM. " create_objects
*& Form display_alv_grid
text
--> p1 text
<-- p2 text
FORM display_alv_grid.
CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT * FROM mara UP TO 5 ROWS.
CLEAR : wa_mara-color_line, wa_mara-color_cell.
MOVE-CORRESPONDING mara TO wa_mara.
ADD 1 TO wa_mara-counter.
MOVE 'Blabla' TO wa_mara-free_text.
IF wa_mara-counter = '0002'
AND p_line = 'X'.
Color line
MOVE 'C410' TO wa_mara-color_line.
ELSEIF wa_mara-counter = '0004'
AND p_cell = 'X'.
Color cell
MOVE 'FREE_TEXT' 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.
wa_mara-color_cell] = it_color[.
ENDIF.
APPEND wa_mara TO it_mara.
ENDSELECT.
ENDFORM. " get_data
*& Form fill_catalog
text
--> p1 text
<-- p2 text
FORM fill_catalog.
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) *
Colour overwriting priority : *
1. Line *
2. Cell *
3. Column *
DATA : w_position TYPE i VALUE '1'.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATNR' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATNR' TO wa_fieldcat-ref_field.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATKL' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATKL' TO wa_fieldcat-ref_field.
Color column
IF p_column = 'X'.
MOVE 'C610' TO wa_fieldcat-emphasize.
ENDIF.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'COUNTER' TO wa_fieldcat-fieldname.
MOVE 'N' TO wa_fieldcat-inttype.
MOVE '4' TO wa_fieldcat-intlen.
MOVE 'Counter' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
MOVE 'C' TO wa_fieldcat-inttype.
MOVE '20' TO wa_fieldcat-intlen.
MOVE 'Text' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " fill_catalog
*& Form fill_layout
text
--> p1 text
<-- p2 text
FORM fill_layout.
Field that identify color line in internal table
MOVE 'COLOR_LINE' TO is_layout-info_fname.
Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
ENDFORM. " fill_layout
Regards.
Eshwar. -
Display only cell in ALV Grid in OO
Hi Folks,
Hope someone can help me with this little issue. I have a series of columns in my ALV grid that are editable, but I need to a) make some of the cells on specific lines uneditable and b) display time based fields on this line as blank (presently they shoe 00:00:00).
For problem a) I have set the layout style frame as 'cellstyles'
es_layout-stylefname = 'CELLSTYLES'.
I have also set the edit flag in the field catalog for the individual columns to 'X' eg
WHEN 'CUSTTS_DATE_N'.
ls_fieldcat-edit = 'X'.
And coded:
gwa_stylerow-fieldname = 'CUSTTS_DATE_N'.
gwa_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND gwa_stylerow TO gt_stylerow.
wa_delivery_list-cellstyle[] = gt_stylerow[].
APPEND wa_delivery_list TO it_delivery_list.
Yet, the ALV cells are still being displayed as editable. Can't for the life of me figure out what's missing. The only other thought I had around this is that the wa_delivery_list-cellstyle table is being set in the data extraction code, before the ALV grid is built, and that the cell formats are being overwritten/on not being called by the field catalog entries. Any thoughts on how to make these fields/cells display only when the ALV is first displayed would be greatly appreciated.
As for option b) I'm clueless, as the cell style commands are not being picked up (see problem a.). Again any thoughts would be appreciated, and points will be rewarded for solutions/suggestions that lead to solutions.
Cheers,
Stephen KeamHello Stephen
I have created a simple report ZUS_SDN_ALV_EDITABLE_1B which shows how to use editability on cell level.
The crucial parts of the coding for your requirements are shown below, followed by the entire report.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPTIM'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ls_fcat-no_zero = abap_true. " suppresses 00:00:00
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
*& Form SET_CELL_EDITABLE
* text
* --> p1 text
* <-- p2 text
FORM set_cell_editable .
* define local data
DATA: ld_idx TYPE i,
ls_outtab TYPE ty_s_outtab,
ls_style TYPE lvc_s_styl.
LOOP AT gt_outtab INTO ls_outtab.
ld_idx = syst-tabix.
REFRESH: ls_outtab-celltab.
" NOTE: if you change the year of column ERDAT to 2008 then two columns will become non-editable
IF ( ls_outtab-erdat+0(4) = '2008' ).
CLEAR: ls_style.
ls_style-fieldname = 'UPDAT'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
CLEAR: ls_style.
ls_style-fieldname = 'UPTIM'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
ELSE.
ENDIF.
MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
TRANSPORTING celltab.
ENDLOOP.
ENDFORM. " SET_CELL_EDITABLE
*& Report ZUS_SDN_ALV_EDITABLE
*& Thread: Display only cell in ALV Grid in OO
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="765083"></a>
* Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
**PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
**PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
*& GUI-Status: ok-codes BACK, EXIT, CANC
REPORT zus_sdn_alv_editable_1b.
TYPE-POOLS: abap.
CONSTANTS:
gc_tabname TYPE tabname VALUE 'KNB1'.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE knb1 AS knb1.
TYPES: celltab TYPE lvc_t_styl.
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,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
DATA:
gs_outtab TYPE ty_s_outtab,
gt_outtab TYPE ty_t_outtab,
gt_outtab_pbo TYPE ty_t_outtab.
DATA:
gd_answer TYPE c.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
" Just trigger PAI followed by PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH'
* IMPORTING
* rc =
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM (gc_tabname) INTO CORRESPONDING FIELDS
OF TABLE gt_outtab UP TO 99 ROWS.
gt_outtab_pbo = gt_outtab. " set PBO data
PERFORM init_controls.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& 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.
" NOTE: not required
* set handler:
* lcl_eventhandler=>handle_data_changed for go_grid.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
PERFORM set_cell_editable.
*§3.Optionally register ENTER to raise event DATA_CHANGED.
* (Per default the user may check data by using the check icon).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
SET HANDLER: lcl_eventhandler=>handle_data_changed FOR go_grid.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
i_save = 'A'
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.
* NOTE:
* Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
*I_SAVE
*Determines the options available to the user for saving a layout:
*? 'X': global saving only
*? 'U': user-specific saving only
*? 'A': corresponds to 'X' and 'U'
*? SPACE: no saving
* 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.
ENDFORM. " INIT_CONTROLS
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
" NOTE: retrieve changed data from frontend (grid control) into
" the backend (itab in ABAP)
go_grid->check_changed_data( ).
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'REFRESH'.
PERFORM set_cell_editable.
" NOTE: Refresh required
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.
WHEN 'SAVE'.
IF ( gt_outtab = gt_outtab_pbo ).
MESSAGE 'No data changed' TYPE 'S'.
ELSE.
CLEAR: gd_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = 'Save data?'
* TEXT_BUTTON_1 = 'Ja'(001)
* ICON_BUTTON_1 = ' '
* TEXT_BUTTON_2 = 'Nein'(002)
* ICON_BUTTON_2 = ' '
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = gd_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 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.
IF ( gd_answer = '1' ). " yes
MESSAGE 'Data successfully saved' TYPE 'S'.
gt_outtab_pbo = gt_outtab. " update PBO data !!!
ELSE.
MESSAGE 'Action cancelled by user' TYPE 'S'.
ENDIF.
ENDIF.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = gc_tabname
* 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.
ls_fcat-edit = abap_true.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING edit
WHERE ( key NE abap_true ).
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPTIM'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ls_fcat-no_zero = abap_true. " suppresses 00:00:00
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'UPDAT'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
INSERT ls_fcat INTO gt_fcat INDEX 7.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
IF ( syst-tabix > 10 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
*& Form SET_CELL_EDITABLE
* text
* --> p1 text
* <-- p2 text
FORM set_cell_editable .
* define local data
DATA: ld_idx TYPE i,
ls_outtab TYPE ty_s_outtab,
ls_style TYPE lvc_s_styl.
LOOP AT gt_outtab INTO ls_outtab.
ld_idx = syst-tabix.
REFRESH: ls_outtab-celltab.
IF ( ls_outtab-erdat+0(4) = '2008' ).
CLEAR: ls_style.
ls_style-fieldname = 'UPDAT'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
CLEAR: ls_style.
ls_style-fieldname = 'UPTIM'.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_style INTO TABLE ls_outtab-celltab.
ELSE.
ENDIF.
MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
TRANSPORTING celltab.
ENDLOOP.
ENDFORM. " SET_CELL_EDITABLE
Regards
Uwe -
hi experts ,
any one tell me how to colour a cell in alve. give me some sample code.
reward points.......Hi
Fareeda
this is w2ht the code example u asked
if u found it helpfull plzz reward
TABLES: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.
Plzzz dont forget to reward -
Sorting colored cell in JTable
First, i'm sory for my bad english
I've made a JTable that have a column contains different colored cell each row depend on value at that cell. Like some post at many forums, I'm using DefaultTableCellRenderer with overiding getTableCellRendererComponent() and calling setBackground(Color c) from that return Component object .
At the first time data loaded into table, all is working well (each cell has their suitable color), but when I sort the table by clicking their header, the bacground color still at the fix cell (not sorted)
Any idea for this?
Thnks before.Thanx to Axel.
Yes, right, it's working in TableSorterDemo.java
that code coloring the cell depen on its value
but my app need to be colored only at specific column, so i need the value of column
i just try to modify at your code like this:
table.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
cell.setBackground(Color.white);
if(value instanceof Integer) {
if ((new Integer(5)).equals(value)) {
cell.setBackground(Color.yellow);
} else if((new Integer(3)).equals(value)) {
cell.setBackground(Color.green);
} else if((new Integer(20)).equals(value)) {
cell.setBackground(Color.red);
if(column == 0){ //not working, n it should not :D
cell.setBackground(Color.red);
return cell;
but, didn't work
so i set the CellRenderer using column approach in my app, like this:
DefaultTableCellRenderer leftCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
super.setHorizontalAlignment(SwingConstants.LEFT);
return cell;
DefaultTableCellRenderer centerCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
super.setHorizontalAlignment(SwingConstants.CENTER);
return cell;
DefaultTableCellRenderer coloredCellRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
super.setHorizontalAlignment(SwingConstants.CENTER);
if (value.equals(" ")) {
cell.setBackground(Color.GREEN);
} else {
cell.setBackground(Color.RED);
return cell;
myTable.getColumnModel().getColumn(1).setCellRenderer(leftCellRenderer);
myTable.getColumnModel().getColumn(0).setCellRenderer(centerCellRenderer);
myTable.getColumnModel().getColumn(2).setCellRenderer(centerCellRenderer);
myTable.getColumnModel().getColumn(3).setCellRenderer(centerCellRenderer);
myTable.getColumnModel().getColumn(4).setCellRenderer(coloredCellRenderer);And all works fine :-)
Thanks.
Maybe you are looking for
-
Open a SAPGUI transaction from a Java web application
Hi all, We are in the process of developing a Java based web application with SAP J2EE engine - but not SAP Enterprise Portal. One of the requirements we have is from one of the web screens there needs to be a button which launches SAPGUI and take
-
My headphones only work if I use the front port, however I want to talk and listen through my headphones and it's not letting me do this
-
Anyone seen this before? The VPN client was unable to setup IP filtering. A VPN connection will not be established. We have a Vendor trying to connect with Windows 7 and they are getting this error. I found this from the Cisco site but was wondering
-
Hi, We have recently upgraded the support packs in SAP HCM system upto level 45. I am trying to run a variant using SE16 > PA2001 > Get variant > execute. I am getting error " Variant ZABSENCE of program /1BCDWB/DBPA2001 is not the current version" I
-
Are Struts thread-safe. Also please let me know the disadvantages of Struts Thanks