Displaying Total Text in an ALV Grid
Hi Experts,
Please suggest me how to display the Total text in the alv grid using CL_SALV_FACTORY method.
Example Output:
Field1 Field2 Field3
a b 100
b c 100
Total 200
Regards,
Sunil Kumar
Hi Avinash,
It will not work since am using cl_salv_factory method. whatever links you have sent are using reuse_alv_grid_display or set_first_table_display.
Regards,
Sunil Kumar
Similar Messages
-
Problem in displaying total text in total line
Hi...I am facing problem in displaying total text in first column of total line. Width of first column is sufficient to display text "TOTAL". But somehow its not getting displayed....Please Help...?
code is as follows:
ls_layout TYPE slis_layout_alv .
ls_layout-totals_text = 'TOTAL'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-no_vline = 'X'.
ls_layout-no_hline = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gv_repid " Report ID
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = ls_layout
it_fieldcat = gt_fieldcat " Field Catlog
TABLES
t_outtab = gt_cost_output " Output Tablehi me to i have the same problem
FORM create_layout .
data: text(20) TYPE c.
it_layout-window_titlebar = text.
it_layout-colwidth_optimize = 'X'.
it_layout-totals_text = text-013."'Totals'(013).
it_layout-cell_merge = 'X'.
it_layout-zebra = 'X'.
ENDFORM.
but no output total in alv
also i had another broplem i had unit i wanna show it in total line and calc value in header -
Hi, coding to display popup window after first alv grid display
hi
can anybody please send coding to display popup window after first alv grid display i.e. first the prog shows grid display and from grid display the user select the field and on the basis of field value i need to show pop up window in the first secondary window and then third popup window.
thanx
rockyHi rocky,
here is the sample code .hope this helps you.
TYPE-POOLS : SLIS.
DATA : GT_OUTTAB TYPE VBAK OCCURS 0,
GS_PRIVATE TYPE SLIS_DATA_CALLER_EXIT,
GS_SELFIELD TYPE SLIS_SELFIELD.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA : ITAB TYPE TABLE OF SLIS_SELFIELD,
WA_ITAB LIKE LINE OF ITAB.
START-OF-SELECTION.
PERFORM POPULATE_GT_OUTTAB.
PERFORM GET_POPUP.
PERFORM POPULATE_ITAB.
PERFORM FIELDCAT.
PERFORM DISPLAY_DETAILS.
*& Form FIELDCAT
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
LOOP AT ITAB INTO WA_ITAB.
WA_FIELDCAT-FIELDNAME = 'TABINDEX'.
WA_FIELDCAT-TABNAME = 'WA_ITAB'.
WA_FIELDCAT-COL_POS = 1.
WA_FIELDCAT-SELTEXT_L = 'TABLE INDEX'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'SEL_TAB_FIELD'.
WA_FIELDCAT-TABNAME = 'WA_ITAB'.
WA_FIELDCAT-COL_POS = 2.
WA_FIELDCAT-OUTPUTLEN = 20.
WA_FIELDCAT-SELTEXT_L = 'FIELD NAME'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'VALUE'.
WA_FIELDCAT-TABNAME = 'WA_ITAB'.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-SELTEXT_L = 'FIELD VALUE'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
ENDLOOP.
ENDFORM. " FIELDCAT
*& Form POPULATE_GT_OUTTAB
text
--> p1 text
<-- p2 text
FORM POPULATE_GT_OUTTAB .
SELECT * FROM VBAK
UP TO 10 ROWS
INTO TABLE GT_OUTTAB.
ENDFORM. " POPULATE_GT_OUTTAB
*& Form GET_POPUP
text
--> p1 text
<-- p2 text
FORM GET_POPUP .
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'SALES ORDER'
I_SELECTION = 'X'
I_ALLOW_NO_SELECTION =
I_ZEBRA = 'X'
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_CHECKBOX_FIELDNAME =
I_LINEMARK_FIELDNAME =
I_SCROLL_TO_SEL_LINE = 'X'
I_TABNAME = 'SALES ORDER'
I_STRUCTURE_NAME = 'VBAK'
IT_FIELDCAT =
IT_EXCLUDING =
I_CALLBACK_PROGRAM =
I_CALLBACK_USER_COMMAND =
IS_PRIVATE = GS_PRIVATE
IMPORTING
ES_SELFIELD = GS_SELFIELD
E_EXIT = G_EXIT
TABLES
T_OUTTAB = GT_OUTTAB
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. " GET_POPUP
*& Form POPULATE_ITAB
text
--> p1 text
<-- p2 text
FORM POPULATE_ITAB .
WA_ITAB-TABNAME = GS_SELFIELD-TABNAME.
WA_ITAB-TABINDEX = GS_SELFIELD-TABINDEX.
WA_ITAB-SEL_TAB_FIELD = GS_SELFIELD-SEL_TAB_FIELD.
WA_ITAB-VALUE = GS_SELFIELD-VALUE.
APPEND WA_ITAB TO ITAB.
ENDFORM. " POPULATE_ITAB
*& Form DISPLAY_DETAILS
text
--> p1 text
<-- p2 text
FORM DISPLAY_DETAILS .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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_DETAILS
award points if helpful.
regards,
deepthi reddy -
Text above an ALV-Grid print-out
It is possible to set a Text above an ALV-Grid print-out?
hii
yes you can print header in ALV & it will come in print out.use following code
DATA: i_listheader TYPE slis_t_listheader WITH HEADER LINE,
w_date like sy-datum.
move:
'H' TO i_listheader-typ,
TO i_listheader-info.
* text-021 TO i_listheader-info.
APPEND i_listheader.
WRITE sy-datum TO w_date.
move:
'S' TO i_listheader-typ,
'Execution date' TO i_listheader-key,
w_date TO i_listheader-info.
APPEND i_listheader.
MOVE:
'S' TO i_listheader-typ,
'Execution user' TO i_listheader-key,
sy-uname TO i_listheader-info.
APPEND i_listheader.
Move:
'Discription' to i_listheader-key,
'Tolling Production Variance' to i_listheader-info.
APPEND i_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_listheader[].
<REMOVED BY MODERATOR>
thx
twinkal
Edited by: twinkal patel on Jun 12, 2008 2:51 PM
Edited by: Alvaro Tejada Galindo on Jun 12, 2008 1:33 PM -
How to display an image in an alv grid in each corresponding row?
Hi,
please tell me how to display an image in an alv grid in each corresponding row, like;;
tony 23 newyork <image>
Mkitharyan 63 washington <image>
NOT BY HOTSPOTS/URL.you can put image in each cell you want:
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
lo_INTERFACECONTROLLER = wd_this->wd_cpifc_alv( ).
DATA lo_value TYPE ref to cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model( ).
data col type ref to CL_SALV_WD_COLUMN.
col = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'IMAGE' ).
data image type ref to cl_salv_wd_uie_image.
CREATE OBJECT image.
image->SET_SOURCE_FIELDNAME( 'IMAGE' ).
COL->SET_CELL_EDITOR( image ). -
Problem displaying 'Total' text in ALV grid
My ALV works and displays correct output. However, I am struggling to display the text 'Total' on position in the last row of the grid. The total is for the salary. My code is below..
I have looked on numerous sites and forums for assistance.
*& Report ZALV
REPORT ZALV.
TABLES: ZCONTACT.
TYPE-POOLS: slis. "slis contains all of the ALV data types.
DATA: "fieldcatALOG TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
alv_prog_name LIKE sy-repid,
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_save TYPE c VALUE 'X',
it_fieldcat TYPE slis_t_fieldcat_alv,"declares field catalog table of line type alv
wa_fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
it_list_top_of_page TYPE slis_t_listheader,
izontact TYPE TABLE OF zcontact,
h1(10) TYPE c VALUE 'Toatall',
"i_logo TYPE OT.
gt_events TYPE slis_t_event,
gd_prntparams TYPE slis_print_alv,
text(40) type c,
wa_layout TYPE slis_layout_alv.
**Selection Screen details
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: variant like disvariant-variant.
SELECTION-SCREEN END OF BLOCK B1.
**Getting default variant
INITIALIZATION.
gx_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
VARIANT = GX_VARIANT-VARIANT.
ENDIF.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM DISPLAY_ALV_REPORT.
"PERFORM build_alv_header
FORM BUILD_FIELDCATALOG.
*Build field catalog
wa_fieldcat-fieldname = 'ID'.
wa_fieldcat-seltext_m = 'ID'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LASTNAME'.
wa_fieldcat-seltext_m = 'LASTNAME'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'FIRSTNAME'.
wa_fieldcat-seltext_m = 'FIRSTNAME'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'DOB'.
wa_fieldcat-seltext_m = 'DOB'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'TEL'.
wa_fieldcat-seltext_m = 'Tel'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ADDRESS'.
wa_fieldcat-seltext_m = 'ADDRESS'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'OCCUPATION'.
wa_fieldcat-seltext_m = 'OCCUPATION'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WEIGHT'.
wa_fieldcat-seltext_m = 'WEIGHT'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-seltext_m = 'AGE'.
wa_fieldcat-do_sum = 'X'. "Display column total
APPEND wa_fieldcat TO it_fieldcat.
"CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'SALARY'.
wa_fieldcat-seltext_m = 'SALARY'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-cfieldname = 'CURRENCYKEY'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'CURRENCY'.
wa_fieldcat-seltext_s = 'CURRENCY'.
APPEND wa_fieldcat TO it_fieldcat.
"CLEAR wa_fieldcat.
ENDFORM. "BUILDING THE FIELD CATALOG
**FORM layout.
*wa_layout-colwidth_optimize = 'X'.
*wa_layout-totals_text ='TOTAL'.
*wa_layout-zebra = 'X'.
*ENDFORM.
"ls_layout-cell_merge = 'X'.
FORM DISPLAY_ALV_REPORT.
alv_prog_name = sy-repid.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat[]
i_callback_program = alv_prog_name
is_layout = wa_layout
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ZCONTACT'
i_save = 'X'
it_events = gt_events
is_print = gd_prntparams
is_variant = g_variant
"is_layout = ls_layout
TABLES
t_outtab = it_zcontact
EXCEPTIONS
program_error = 1
OTHERS = 2.
WRITE: H1 UNDER 'SALARY'.
ENDFORM.
**Fetch data from the database
FORM DATA_RETRIEVAL.
SELECT * FROM zcontact INTO TABLE it_zcontact.
ENDFORM.
FORM top_of_page.
*ALV Header declarations
DATA: it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
t_line like wa_listheader-info,
ld_lines TYPE I,
ld_linesc(10) TYPE C.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Contact Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-repid.
wa_listheader-key = 'Program Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-uname.
wa_listheader-key = 'User Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Run Date :'.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
INTO wa_listheader-info
SEPARATED BY '/'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Time :'.
CONCATENATE sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2)
INTO wa_listheader-info
SEPARATED BY ':'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader[]
i_logo = 'KLOGO'.
ENDFORM. "top_of_pageI did this but still i cant display the total text..I have reposted my code. please assist. Im only missing that total label
*& Report ZALV
REPORT ZALV.
TABLES: ZCONTACT.
TYPE-POOLS: slis. "slis contains all of the ALV data types.
TYPES: BEGIN OF t_zcontact,
text(40) TYPE c, "storing the total text
mandt TYPE mandt,
id TYPE zcontactid,
lastname type zcontactlname,
firstname TYPE zcontactfname,
dob TYPE zdateofbirth,
tel TYPE ztel,
address TYPE zaddress,
occupation TYPE zoccup,
weight type zweight,
age TYPE zage,
salary TYPE zsalary,
ecurrency TYPE curcy,
END OF t_zcontact.
TYPES: BEGIN OF wa_zcontact,
mandt TYPE mandt,
id TYPE zcontactid,
lastname type zcontactlname,
firstname TYPE zcontactfname,
dob TYPE zdateofbirth,
tel TYPE ztel,
address TYPE zaddress,
occupation TYPE zoccup,
weight type zweight,
age TYPE zage,
salary TYPE zsalary,
ecurrency TYPE curcy,
END OF wa_zcontact.
TYPES:
i_zcontact TYPE STANDARD TABLE OF t_zcontact." INITIAL SIZE 0.
DATA: itt_zcontact TYPE STANDARD TABLE OF wa_zcontact INITIAL SIZE 0,
wat_zcontact TYPE wa_zcontact.
DATA: "it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
gd_repid LIKE sy-repid,
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_save TYPE c VALUE 'X',
fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,"declares field catalog table of line type alv
gd_tab_group type slis_t_sp_group_alv,
gd_prntparams TYPE slis_print_alv,
fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
it_list_top_of_page TYPE slis_t_listheader,
i_zcontact TYPE TABLE OF zcontact,
"h1(10) TYPE c VALUE 'Toatall',
"i_logo TYPE OT.
gt_events TYPE slis_t_event,
gd_layout TYPE slis_layout_alv."work area for the alv layout
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort LIKE LINE OF it_sortcat.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM DISPLAY_ALV_REPORT.
PERFORM BUILD_LAYOUT.
perform build_sortcat.
PERFORM sub_add_text.
"PERFORM build_events.
PERFORM top-of-page.
"PERFORM build_alv_header.
END-OF-SELECTION.
*DATA: gd_layout TYPE slis_layout_alv.
* gd_layout-totals_text = 'TOTAL'.
**Selection Screen details
*SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS: variant like disvariant-variant.
*SELECTION-SCREEN END OF BLOCK B1.
***Getting default variant
*INITIALIZATION.
*gx_variant-report = sy-repid.
*CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
*EXPORTING
* I_SAVE = G_SAVE
* CHANGING
* CS_VARIANT = GX_VARIANT
* EXCEPTIONS
* NOT_FOUND = 2.
*IF SY-SUBRC = 0.
* VARIANT = GX_VARIANT-VARIANT.
* ENDIF.
FORM BUILD_FIELDCATALOG.
*Build field catalog
fieldcatalog-fieldname = 'ID'.
fieldcatalog-seltext_m = 'ID'.
fieldcatalog-col_pos = 2.
fieldcatalog-outputlen = 10.
fieldcatalog-datatype = 'CHAR'.
"fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LASTNAME'.
fieldcatalog-seltext_m = 'LASTNAME'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'FIRSTNAME'.
fieldcatalog-seltext_m = 'FIRSTNAME'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'DOB'.
fieldcatalog-seltext_m = 'DOB'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TEL'.
fieldcatalog-seltext_m = 'Tel'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ADDRESS'.
fieldcatalog-seltext_m = 'ADDRESS'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'OCCUPATION'.
fieldcatalog-seltext_m = 'OCCUPATION'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'WEIGHT'.
fieldcatalog-seltext_m = 'WEIGHT'.
"fieldcatalog-do_sum = 'X'.
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AGE'.
fieldcatalog-seltext_m = 'AGE'.
"fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'SALARY'.
fieldcatalog-seltext_m = 'SALARY'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype ='CURR'.
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
"fieldcatalog-fieldname = 'ECURRENCY'.
"fieldcatalog-seltext_s = 'ECURRENCY'.
"APPEND fieldcatalog TO fieldcatalog.
"CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TEXT'.
fieldcatalog-col_pos = 0.
"fieldcatalog-seltext_m = 'TEXT'.
fieldcatalog-tech = 'X'.
fieldcatalog-no_out = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
ENDFORM.
*& Form build_sortcat
* Build Sort catalog
FORM build_sortcat .
"wa_sort-spos = 1.
wa_sort-fieldname = 'TEXT'.
"wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
wa_sort-up = 'X'.
APPEND wa_sort TO it_sortcat.
CLEAR wa_sort.
ENDFORM. " build_sortcat
FORM BUILD_LAYOUT.
*gd_layout-no_input = 'X'.
*gd_layout-colwidth_optimize = 'X'.
*gd_layout-totals_text = 'Totals'(201).
*"gd_LAYOUT-coltab_fieldname = 'SALARY'.
gd_layout-no_totalline = 'X'.
ENDFORM.
*IF sy-subrc = 0.
* LOOP AT fieldcatalog INTO fieldcat.
* IF fieldcat-fieldname = 'WEIGHT' OR
* fieldcat-fieldname = 'AGE'.
** Summation for WEIGHT & AGE
* fieldcat-do_sum = 'X'.
* MODIFY fieldcatalog FROM fieldcat TRANSPORTING do_sum.
* ENDIF.
* IF fieldcat-fieldname = 'TEXT'.
** Hide this field so that it can display it's content i.e.
** Total text in Subtotal level
* fieldcat-tech = 'X'.
* fieldcat-no_out = 'X'.
* MODIFY fieldcatalog FROM fieldcat TRANSPORTING tech no_out.
* ENDIF.
* CLEAR fieldcat.
* ENDLOOP.
* ENDIF.
*ENDFORM. "BUILDING THE FIELD CATALOG
*form build_events.
* data: ls_event type slis_alv_event.
* call function 'REUSE_ALV_EVENTS_GET'
* exporting
* i_list_type = 0
* importing
* et_events = gt_events[].
* read table gt_events with key name = slis_ev_top_of_page
* into ls_event.
* if sy-subrc = 0.
* move 'TOP-OF-PAGE' to ls_event-form.
* append ls_event to gt_events.
* endif.
* read table gt_events with key name = slis_ev_end_of_list
* into ls_event.
* if sy-subrc = 0.
* move 'END_OF_LIST' to ls_event-form.
* append ls_event to gt_events.
* endif.
*endform. " BUILD_EVENTS
"ls_layout-cell_merge = 'X'.
FORM DISPLAY_ALV_REPORT.
gd_repid = sy-repid.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_callback_program = gd_repid
is_layout = gd_layout
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ZCONTACT'
i_save = 'X'
it_events = gt_events
is_print = gd_prntparams
is_variant = g_variant
"is_layout = ls_layout
TABLES
t_outtab = itt_zcontact
EXCEPTIONS
program_error = 1
OTHERS = 2.
"WRITE: 'TOTAL' UNDER 'ID'.
ENDFORM.
**Fetch data from the database
FORM DATA_RETRIEVAL.
"DATA: ld_subtot(1) type c.
SELECT * FROM zcontact INTO TABLE itt_zcontact UP TO 10 ROWS.
ENDFORM.
FORM sub_add_text.
*Populate field with text value
DATA:
wt_zcontact TYPE t_zcontact,
last TYPE zcontact-ID,
l_text(40) type c,
num type n.
loop at itt_zcontact into wat_zcontact.
* Populate final table
wt_zcontact-TEXT = 'Total salary: '.
"ld_subtot = ld_subtot + 1.
"wat_zcontact-text = ld_subtot.
modify itt_zcontact FROM wat_zcontact.
clear wat_zcontact.
"APPEND wat_zcontact TO itt_zcontact.
endloop.
ENDFORM.
FORM top-of-page.
*ALV Header declarations
DATA: it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
t_line like wa_listheader-info,
ld_lines TYPE I,
ld_linesc(10) TYPE C.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Contact Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-repid.
wa_listheader-key = 'Program Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-uname.
wa_listheader-key = 'User Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Run Date :'.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
INTO wa_listheader-info
SEPARATED BY '/'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Time :'.
CONCATENATE sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2)
INTO wa_listheader-info
SEPARATED BY ':'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader[]
i_logo = 'KLOGO'.
ENDFORM. "top_of_page -
Total problem in Exporting ALV GRID to Excel
Hi all,
I have manipulated the Total of ALV Grid by using GET_SUBTOTALS and REFRESH method of CL_GUI_ALV_GRID. The ALV Output is also correct. When i export to Excel,only the Original total is displaying not the calculated one. How to download the exact output which is displaying in the ALV Grid to Excel.
Please help me out to solve this.
Thanks,
RameshDEAR,
AS U WANT UPLOAD WITH THE SUB TOTAL YOU TRY THIS.
FIRST to get subtotal in ALV output you select at least one column of total and then press ctrl + F6 . u will see the sub total .
and now how to download it so press ctrl + shift + F9 .
now screen appears and select second option ie spreadsheet and press enter
now a screen appear in wich u have to give file name.
so double click on search button of file name . click on desktop give ur file name as u want suppose zreport u have given.
and save type = excel file.
now save it and then generate it your output bytes will be transmitted .
now u can see in your desktop in your file name . ur output with subtotal.
regards
navin -
hiiiiiiiiiiii
i write one alv grid program
i wnat total at last of output for the field *DMBTR*
plz see the code and give me solution
type-pools: slis.
tables: BSID, KNA1.
data : begin of it_BSID occurs 0,
BUKRS TYPE BSID-BUKRS, "COMPANY CODE
KUNNR TYPE BSID-KUNNR, "Customer no
NAME1 TYPE KNA1-NAME1, "Customer name
XBLNR TYPE BSID-XBLNR, "REFERANCE
BLART TYPE BSID-BLART, "Document Type
BUDAT TYPE BSID-BUDAT, "Posting Date in the Document
SHKZG TYPE BSID-SHKZG, "Debit/Credit Indicator
BELNR TYPE BSID-BELNR, "Accounting Doc no
DMBTR TYPE BSID-DMBTR, "Amount in Local Currency
SGTXT TYPE BSID-SGTXT, "Item text
end of it_BSID.
data : begin of itab occurs 0,
BUKRS TYPE BSID-BUKRS, "COMPANY CODE
KUNNR TYPE BSID-KUNNR, "Customer no
NAME1 TYPE KNA1-NAME1, "Customer name
XBLNR TYPE BSID-XBLNR, "REFERANCE
BLART TYPE BSID-BLART, "Document Type
BUDAT TYPE BSID-BUDAT, "Posting Date in the Document
SHKZG TYPE BSID-SHKZG, "Debit/Credit Indicator
BELNR TYPE BSID-BELNR, "Accounting Doc no
DMBTR TYPE BSID-DMBTR, "Amount in Local Currency
SGTXT TYPE BSID-SGTXT, "Item text
end of itab.
*********ALV Declaration************************************************
data: it_fieldcatalog type slis_t_fieldcat_alv with header line,
wa_fieldcatalog like line of it_fieldcatalog,
wa_layout type slis_layout_alv,
it_rec type table of itab,
it_rec1 type table of itab,
wa_rec like line of itab,
wa_itab like line of itab.
data : it_sort type slis_t_sortinfo_alv,
wa_sort type slis_sortinfo_alv.
*********ALV Declaration************************************************
selection-screen : begin of block b with frame title text-100.
select-options:
COMPANY for BSID-BUKRS ,
CUSTOMER for BSID-KUNNR,
DATE FOR BSID-BUDAT.
selection-screen end of block b .
start-of-selection.
select BUKRS KUNNR XBLNR BLART BUDAT
SHKZG BELNR DMBTR SGTXT
from BSID into corresponding fields of table it_BSID
where
BUKRS IN COMPANY AND
KUNNR IN CUSTOMER AND
BUDAT IN DATE .
sort it_BSID by BUDAT KUNNR.
end-of-selection.
loop at it_BSID.
IF it_BSID-SHKZG EQ 'H'.
MULTIPLY it_BSID-DMBTR BY -1.
ENDIF.
move: IT_BSID-BUKRS TO ITAB-BUKRS, "COMPANY CODE
IT_BSID-KUNNR TO ITAB-KUNNR, "Customer no
IT_BSID-XBLNR TO ITAB-XBLNR, "REFERANCE
IT_BSID-BLART TO ITAB-BLART, "Document Type
IT_BSID-BUDAT TO ITAB-BUDAT, "Posting Date in the Document
IT_BSID-SHKZG TO ITAB-SHKZG, "Debit/Credit Indicator
IT_BSID-BELNR TO ITAB-BELNR, "Accounting Doc no
IT_BSID-DMBTR TO ITAB-DMBTR, "Amount in Local Currency
IT_BSID-SGTXT TO ITAB-SGTXT. "Item text
select single NAME1 from KNA1 into (itab-NAME1) where KUNNR = itab-KUNNR.
APPEND ITAB.
endloop.
loop at itab .
at end of itab-dmbtr.
sum.
endat.
endloop.
if not itab[] is initial.
perform populate_field_catalog.
perform fill_layout.
perform display_alv.
else.
write: ' NO DATA'.
endif.
*& Form populate_field_catalog
* text
form populate_field_catalog .
wa_fieldcatalog-fieldname = 'BUKRS'.
wa_fieldcatalog-seltext_m = 'COMPANY'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'KUNNR'.
wa_fieldcatalog-seltext_m = 'CUSTOMER CODE.'.
wa_fieldcatalog-no_zero = 'X'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NAME1'.
wa_fieldcatalog-seltext_m = 'NAME'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BLART'.
wa_fieldcatalog-seltext_m = 'DOC. TYPE '.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BUDAT'.
wa_fieldcatalog-seltext_m = 'POSTING DATE'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'BELNR'.
wa_fieldcatalog-seltext_m = 'DOCUMENT NO.'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'DMBTR'.
wa_fieldcatalog-seltext_m = 'AMOUNT'.
wa_fieldcatalog-DO_SUM = 'X'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'SGTXT'.
wa_fieldcatalog-seltext_m = 'TEXT'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'XBLNR'.
wa_fieldcatalog-seltext_m = 'REFERANCE'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog.
endform. " populate_field_catalog
*& Form fill_layout
* text
* --> p1 text
* <-- p2 text
form fill_layout .
wa_layout-no_input = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-zebra = 'X'.
endform. " fill_layout
*& Form display_alv
* text
* --> p1 text
* <-- p2 text
form display_alv .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
is_layout = wa_layout
it_fieldcat = it_fieldcatalog[]
i_default = 'X'
i_save = 'A'
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_alv
Edited by: pranay panchbhai on Mar 15, 2010 3:18 PMHi
Give this code for field DMBTR in fielcatalog.
wa_fieldcatalog-FIELDNAME = 'DMBTR'.
wa_fieldcatalog-INTTYPE = 'C'.
wa_fieldcatalogT-DO_SUM = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
It will work definitely.
If you still have doubts then revert back.
Thanks & Regards
Khushboo -
Total/Subtotal Icon in ALV GRID
Hi;
i have an ALV GRID that is already sorted and data is shown ordered in the grid:
Sort Documento
wa_sort-spos = '1' .
wa_sort-fieldname = 'MBLNR'.
wa_sort-tabname = 'ITAB'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
But, i need to subtotal by a column and i do this:
gt_fieldcat-seltext_l = 'Cant_entregada'.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-ref_tabname = 'itab'.
gt_fieldcat-outputlen = 14.
gt_fieldcat-do_sum = 'X'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
Menge is data type Integer because the Key User doesn´t want decimal places.
And ,
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_sort = i_sort
i_default = 'X'
i_save = 'A'
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
So data in the grid is ordered by Document number, but the total/subtotal button is not displayed.
i've been lookin other posts about the same, but i don´t see any difference with my code.
Any help.
David Fúnez
Tegucigalpa, Hondurasi found the answer..jus added this line : gt_fieldcat-datatype = 'INT4'.
gt_fieldcat-seltext_l = 'Cant_entregada'.
gt_fieldcat-fieldname = 'MENGE'.
gt_fieldcat-ref_tabname = 'itab'.
gt_fieldcat-outputlen = 14.
gt_fieldcat-do_sum = 'X'.
gt_fieldcat-datatype = 'INT4'.
APPEND gt_fieldcat. CLEAR gt_fieldcat.
Now buttons are displayed... -
Hello Experts,
I have an ALV Grid where the last column is displayed as push buttons. When i click on a pushbutton, a text editor is opened up using ABAP OO. Now, I enter the text and SAve it. A standard text is created against the selected row in ALV Grid. Then I come back to the alv grid and click on another button of some different row. Again the text editor opens up with the previous text. I nter the new text and click on save. However, this time the standard text is not created. I have am making the container and text editor free as i click on 'back'. Still the data is not getting refreshed.
Please, let me know where m i going wrong.
Regards,
SonalHi Sonal,
I have faced similar issue with respect to module pool with container on the screen.
Try using the following on back action....
call method wf_init_edit->delete_text. (wf_init_edit -> editor reference - type ref to cl_gui_textedit )
Also we can free the container using
call method wf_init_cont->free. (wf_init_cont -> container reference - type ref to cl_gui_custom_container )
Hope it helps.
Regards,
Byju -
Color the sub-total row in an alv-grid
Hi all.
I work on SAP 4.7 WAS6.20 and output a table with the cl_gui_alv_grid. I´m able to color special rows (or columns) in the alv grid. But I want to color individually the sub-total lines (like the lines before) and don´t want the yellow color for all of the sub-total lines.
Do you know how to color the sub-total-lines?
Thanks a lot.
MichaelHi,
U can color an individula row see the link below
Color a line
The steps for coloring a line i the grid is much the same as making a traffic light.
* To color a line the structure of the table must include a Char 4 field for color properties
TYPES: BEGIN OF st_sflight.
INCLUDE STRUCTURE zsflight.
* Field for line color
types: line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
* Loop trough the table to set the color properties of each line. The color properties field is
* Char 4 and the characters is set as follows:
* Char 1 = C = This is a color property
* Char 2 = 6 = Color code (1 - 7)
* Char 3 = Intensified on/of = 1 = on
* Char 4 = Inverse display = 0 = of
LOOP AT gi_sflight INTO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
g_wa_sflight-line_color = 'C610'.
ENDIF.
MODIFY gi_sflight FROM g_wa_sflight.
ENDLOOP.
* Name of the color field
gs_layout-info_fname = 'LINE_COLOR'.
* Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gi_sflight
see the link
http://www.sapgenie.com/abap/controls/alvgrid.htm -
Sub Total Text in an ALV using FACTORY Method
Hi Gurus,
My requirement is simple, but I couldn't find any answers under SDN or any other forums. Some of you may ask me to check for the SCN posts, but I almost checked everything.
My requirement is - When I get the Sub-total in my ALV, it should print a text other than the field which has got sub-total value.
My ALV Schema:
Field1 | Field2 | Field 3 |
____ |______ |______ |
| | |
| | |
Tot. Qty | 1000.00|
I have sorted and added the subtotal = 'X' for the field which I need the Subtotal. Added Aggregations to Field3. But where and how to the field 'Tot. Qty', so that it should appear at the Sub-Total Level.
Please guide me if I've missed any of the forums. Again my requirement is to print the Field Name.
Regards,
-Wahid Hussain Syed.Hi,
You can view this thread for example Display constant text in intermediate results column of SALV as it says that this is a limitation in SALV that "The output of totals and subtotals is handled solely by ALV. You can neither pass the results to your application nor manipulate them in any way.". But you can see a work around done for this problem, to be frank that I have not done that and I am only providing this link for your reference. -
Hi Experts,
I need to get the subtotal text in the ALV, for which i need to handle the event sub_total text
I see that it is not gettting trigerred.
thanksHi,
Use the subtotal_text event of the ALV.
Refer to this link for examples..
[ALV Display Subtotal Text Using OO |https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/displaysubtotaltextinALV+grid] -
To display a popup message alongwith ALV grid
Hi Experts,
I have a requirement where I need to display data using ALV Grid. Also, in case there are any errors encountered during the data extraction I need to inform the user about it by using either a popup message or a status message stating that he needs to check the error log. To display the error log I have provided a push button which will take the user to another screen where he can see all the errors encountered.
Can anyone please let me know as to how to accomplish the task of displaying a status message alongwith a ALV grid display?
Looking forward to your reply.
-Warm regards,
Prajakta K.use exception handling and pop up.........
try following in grid..
*--Exception handling
ENDIF .
ENDIF .
WHEN 'EU' .
READ TABLE gt_list INDEX ls_selected_row-row_id .
IF sy-subrc = 0 .
CALL FUNCTION 'ZPOPUP_CONV_CURR_AND_DISPLAY'
EXPORTING monun = 'EU'
quant = gt_list-paymentsum.
ENDIF .
ENDCASE .
ENDFORM . -
Display the material details in alv grid based on material(in mara)
hi,
display the material details when get input of material from user in mara table using alv-grid display.
give some examples.
Thanks of advance.Hi
For your help i am just giving you few hints.
1. Create a selection screen.
2. Select matnr from mara into an internal table.
3. use fm Reuse_Alv_grid_display to display your entries from the internal table
Please read about all of this step by step in the forum.
Maybe you are looking for
-
White space not preserved with XSL Mapping
Hello Is there a problem with preserving white space when using a XSL mapping? My schema has the following included: <xs:element name="FileVersion" minOccurs="1" maxOccurs="1"> <xs:simpleType> <xs:restr
-
Blend Overlay is not working in Safari over site's background image
My message is concerning the website (below) called suspendedinsound.com. The blend mode, Overlay, is not working on several of my movie clips in the Safari browser. The Flash swf and html is published with a transparent background. I put a bg image
-
Win 8.1 64 bit and javascript problems.
I have purchased some internet shop software and it works fine on Chrome and Firefox. On IE11 if I input a user name and password on pressing return it just clears out the username. Also if I click on add an item to the basket the basket screen opens
-
Installing Lightroom in a new computer
I will soon be selling my old iMac computer and purchasing a new iMac. Will there be a problem with reinstaling the Lightroom software on the new computer? Is there a limit to the number of computers that one license can use for installation?
-
Cannot Sync iPhone Video back to iPhone
Alright, so I took some video on my iPhone 3GS. As part of my normal archiving process, I have all photos and videos from the iPhone automatically imported into a specific album ("iPhone Album") in Adobe Photoshop Elements 7 upon connecting my iPhone