10-08-2007 10:24 AM
hi,
can anybody help me to display totals text in alv grid.
please give some same code.
thanks in advance.
I had used ,
data: st_layout like slis_layout_alv.
st_layout-totals_text = 'Total in Lakhs'.
but it is not working..
is there any other way
10-08-2007 10:28 AM
hi,
Please refer this program/.....
&----
*
*& Report Z_REPT_ALV_EX1 *
*& *
&----
*& *
*& *
&----
report ZALV_GEN line-count 36(5)
line-size 225
no standard page heading.
************************************************************************
Report name: Puchase Order Report for ALV practice *
Program ID : Z_REPT_ALV_EX1_TG *
Author : ADCDEV ( T G Santosh ) *
Date : Sep 09, 2004 *
************************************************************************
*..Type Definitions for ALV Report
type-pools slis.
************************************************************************
Tables Declaration
************************************************************************
tables : lfa1,
lfb1,
lfm1.
************************************************************************
Data Declaration
************************************************************************
data : v_lifnr like lfa1-lifnr,
v_bukrs like lfb1-bukrs,
v_ekorg like lfm1-ekorg,
v_ktokk like lfa1-ktokk,
v_repid like sy-repid.
************************************************************************
Internal Tables
************************************************************************
data : begin of it_details occurs 0,
lifnr like lfa1-lifnr,
bukrs like lfb1-bukrs,
ekorg like lfm1-ekorg,
ktokk like lfa1-ktokk,
name1 like lfa1-name1,
stras like lfa1-stras,
ragio like lfa1-regio,
pfach like lfa1-pfach,
pstl2 like lfa1-pstl2,
pstlz like lfa1-pstlz,
telf1 like lfa1-telf1,
end of it_details.
data: it_fieldcatalog type slis_t_fieldcat_alv,
it_fieldcatalog1 type slis_t_fieldcat_alv,
wa_fieldcatalog type slis_fieldcat_alv,
wa_layout type slis_layout_alv,
it_events type slis_t_event,
wa_events type slis_alv_event,
it_sort type slis_t_sortinfo_alv,
wa_sort type slis_sortinfo_alv occurs 0 with header line.
************************************************************************
Initialization
************************************************************************
v_repid = sy-repid.
************************************************************************
Selecton Screen
************************************************************************
selection-screen begin of block blk1 with frame title text-001.
select-options : s_lifnr for lfa1-lifnr,
s_bukrs for lfb1-bukrs,
s_ekorg for lfm1-ekorg,
s_ktokk for lfa1-ktokk.
selection-screen end of block blk1.
selection-screen begin of block blk2 with frame title text-002.
parameter : block radiobutton group g1,
grid radiobutton group g1.
selection-screen end of block blk2.
************************************************************************
At Selecton Screen
************************************************************************
select single lifnr
from lfa1
into v_lifnr
where lifnr in s_lifnr.
if sy-subrc <> 0.
message i101(zsantosh) with 'v_lifnr' .
write : 'not a valid number', v_lifnr.
else.
select single bukrs
from lfb1
into v_bukrs
where bukrs in s_bukrs.
if sy-subrc <> 0.
message i101(zsantosh) with 'Company Code'.
else.
select single ekorg
from lfm1
into v_ekorg
where ekorg in s_ekorg.
if sy-subrc <> 0.
message i101(zsantosh) with 'Purchasing Organisation'.
else.
select single ktokk
from lfa1
into v_ktokk
where ktokk in s_ktokk.
if sy-subrc <> 0.
message i101(zsantosh) with 'Vendor Group'.
endif.
endif.
endif.
endif.
************************************************************************
Start of Selection
************************************************************************
start-of-selection.
select a1~lifnr
b1~bukrs
m1~ekorg
a1~ktokk
a1~name1
a1~stras
a1~regio
a1~pfach
a1~pstl2
a1~pstlz
a1~telf1
into table it_details
from lfa1 as a1
join lfb1 as b1 on a1lifnr = b1lifnr
join lfm1 as m1 on a1lifnr = m1lifnr
where a1~lifnr in s_lifnr and
b1~bukrs in s_bukrs and
m1~ekorg in s_ekorg and
a1~ktokk in s_ktokk.
clear wa_sort.
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'BUKRS'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-spos = 3.
wa_sort-fieldname = 'EKORG'.
wa_sort-tabname = 'IT_DETAILS'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
************************************************************************
End of selection
************************************************************************
end-of-selection.
perform fill_fieldcat.
loop at it_fieldcatalog into wa_fieldcatalog.
if wa_fieldcatalog-fieldname = 'RAGIO'.
wa_fieldcatalog-intlen = 2.
wa_fieldcatalog-ref_fieldname = ''.
wa_fieldcatalog-ref_tabname = ''.
wa_fieldcatalog-ddic_outputlen = 2.
endif.
wa_fieldcatalog-ref_fieldname = ''.
wa_fieldcatalog-ref_tabname = ''.
modify it_fieldcatalog from wa_fieldcatalog.
endloop.
perform fill_layout.
if block = 'X'.
perform list_block_display.
elseif grid = 'X'.
perform list_grid_display.
endif.
&----
*& Form FILL_FIELDCAT
&----
text
----
--> p1 text
<-- p2 text
----
form fill_fieldcat .
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_DETAILS'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = it_fieldcatalog
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.
endform. " FILL_FIELDCAT
&----
*& Form FILL_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
form fill_layout .
wa_layout-zebra = 'X'.
wa_layout-totals_text = 'TOTAL'.
wa_layout-colwidth_optimize = 'X'.
endform. " FILL_LAYOUT
&----
*& Form list_block_display
&----
text
----
--> p1 text
<-- p2 text
----
form list_block_display .
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = wa_layout
it_fieldcat = it_fieldcatalog
i_tabname = 'IT_DETAILS'
it_events = it_events
it_sort = it_sort
I_TEXT = ' '
tables
t_outtab = it_details
exceptions
program_error = 1
maximum_of_appends_reached = 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.
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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. " list_block_display
&----
*& Form LIST_GRID_DISPLAY
&----
text
----
--> p1 text
<-- p2 text
----
form list_grid_display .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'IT_DETAILS'
I_BACKGROUND_ID = ' '
i_grid_title = 'DETAILS IN GRID DISPLAY'
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_details
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. " LIST_GRID_DISPLAY
Regards
vasu
10-08-2007 10:33 AM
tables:ekko.
type-pools : slis.
*&----
*
Internal table for ALV
*----
*
data : it_fieldcat type slis_t_fieldcat_alv, "Field catalog
wa_fieldcat type slis_fieldcat_alv, "WA for Field catalog
it_event type slis_t_event, "events
wa_event type slis_alv_event, "WA for events
it_comment type slis_t_listheader, "Header details
wa_comment type slis_listheader, "WA for header details
wa_layout type slis_layout_alv, "Layout
it_sort type slis_t_sortinfo_alv, "Sort table
wa_sort type slis_sortinfo_alv, "WA for sort table
it_keyinfo type slis_keyinfo_alv. "Pass key value
data : v_repid like sy-repid.
v_repid = sy-repid.
data : v_date like sy-datum.
color management.
data : it_color type table of lvc_s_scol. "Color management.
*&----
*
Internal table declearation
*----
*
data:begin of it_ekko occurs 0,
ebeln like ekko-ebeln,
bukrs like ekko-bukrs,
aedat like ekko-aedat,
end of it_ekko.
data : begin of it_ekpo occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
netwr like ekpo-menge,
chk(1) type c,
end of it_ekpo.
data : begin of it_ekbe occurs 0,
ebeln like ekbe-ebeln,
ebelp like ekbe-ebelp,
belnr like ekbe-belnr,
menge like ekbe-menge,
matnr like ekbe-matnr,
end of it_ekbe.
data : begin of it_final occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
netwr like ekpo-netwr,
line_color(4) type c, "Used to store row color attributes
end of it_final.
selection-screen begin of block blk with frame title text-001.
select-options:s_ebeln for ekko-ebeln.
selection-screen end of block blk.
start-of-selection.
perform get_details.
perform get_alv.
*&----
*
*& Form GET_DETAILS
*&----
*
Get the details
*----
*
form get_details .
data: ld_color(1) type c.
select ebeln
bukrs
aedat
from ekko
into table it_ekko
where ebeln in s_ebeln.
if sy-subrc = 0.
sort it_ekko by ebeln.
else.
message e000 with 'DATA NOT FOUND'.
endif.
if not it_ekko[] is initial.
select ebeln
ebelp
matnr
menge
meins
netpr
netwr
chk
from ekpo
into table it_ekpo
for all entries in it_ekko
where ebeln = it_ekko-ebeln.
if sy-subrc = 0.
sort it_ekpo by ebeln.
endif.
endif.
loop at it_ekpo.
it_final-ebeln = it_ekpo-ebeln.
it_final-ebelp = it_ekpo-ebelp.
it_final-matnr = it_ekpo-matnr.
it_final-menge = it_ekpo-menge.
it_final-meins = it_ekpo-meins.
it_final-netpr = it_ekpo-netpr.
it_final-netwr = it_ekpo-netwr.
on change of it_final-ebeln.
ld_color = 7.
concatenate 'C' ld_color '10' into it_final-line_color.
endon.
append it_final.
clear it_final.
endloop.
endform. " GET_DETAILS
*&----
*
*& Form GET_ALV
*&----
*
text
*----
*
form get_alv .
perform generate_fieldcat.
perform generate_layout.
perform generate_events.
perform generate_sort.
perform alv_grid_display.
endform. " GET_ALV
*&----
*
*& Form GENERATE_FIELDCAT
*&----
*
Field catalog
*----
*
form generate_fieldcat .
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'PO Number'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Item Number'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-edit = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Material Number'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'PO Quantity'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Order unit'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Net price'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Net order value'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
endform. " GENERATE_FIELDCAT
*&----
*& Form GENERATE_EVENTS
*&----
Generate Events
*----
form generate_events .
call function 'REUSE_ALV_EVENTS_GET'
importing
et_events = it_event
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.
if not it_event[] is initial.
read table it_event into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc = 0.
wa_event-form = 'TOP_OF_PAGE'.
modify it_event from wa_event index sy-tabix.
endif.
read table it_event into wa_event with key name = 'USER_COMMAND'.
if sy-subrc = 0.
wa_event-form = 'IT_USER_COMMAND'.
modify it_event from wa_event index sy-tabix.
endif.
endif.
endform. " GENERATE_EVENTS
*&----
*& Form TOP_OF_PAGE
*&----
TOP_OF_PAGE
*----
form top_of_page.
data : v_concate(50) type c.
data : v_space(10) type c.
concatenate 'VIKRANTH' 'rajesh' into v_concate.
wa_comment-typ = 'S'.
wa_comment-key = 'USER :'.
wa_comment-info = v_concate.
append wa_comment to it_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'DATE:'.
wa_comment-info = sy-datum.
append wa_comment to it_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'TIME:'.
wa_comment-info = sy-timlo.
append wa_comment to it_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_comment.
clear it_comment.
endform. "TOP_OF_PAGE
*&----
*
*& Form ALV_GRID_DISPLAY
*&----
*
Grid display
*----
*
form alv_grid_display .
perform grid_display.
endform. " ALV_GRID_DISPLAY
*&----
*
*& Form GENERATE_LAYOUT
*&----
*
LAYOUT
*----
*
form generate_layout .
wa_layout-colwidth_optimize = 'X'. "OPTIMIZING FIELD WIDTH
wa_layout-zebra = 'X'. "PUTTING ZEBRA COLORS
wa_layout-totals_text = 'Total'.
wa_layout-subtotals_text = 'SUB TOTAL'.
wa_layout-info_fieldname = 'LINE_COLOR'.
endform. " GENERATE_LAYOUT
*&----
*
*& Form GENERATE_SORT
&----
SORT
----
form generate_sort .
wa_sort-fieldname = 'EBELN'.
wa_sort-spos = '1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
append wa_sort to it_sort.
endform. " GENERATE_SORT
&----
*& Form GRID_DISPLAY
&----
GRID DISPLAY
----
form grid_display .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = I_STRUCTURE_NAME
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
it_events = it_event
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = 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 = IR_SALV_LIST_ADAPTER
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = it_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'IT_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = 'Purchase Order Details'
I_GRID_SETTINGS = I_GRID_SETTINGS
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
it_events = it_event
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
IT_HYPERLINK = IT_HYPERLINK
IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab = it_final
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endform. " GRID_DISPLAY
10-08-2007 10:38 AM
hi selvi,
go through this code this will be helpfull to u. If u did'nt understood how to insert this code into your prog, then just farword your program. I will do it.
wa_fcat-fieldname = 'TOTAL'. " Reading the field name
wa_fcat-tabname = 'G_T_ITAB'. " Internal table name
wa_fcat-col_pos = '4'. " Indicates the position of the column
wa_fcat-seltext_m = 'TOTAL IN LAKHS'. " To display the text.
APPEND wa_fcat TO it_fcat.
<b>please reward points if helpfull.</b>
with regards,
radhika kolluru.