Posted: Fri May 09, 2008 6:56 pm Post subject: Subtotal в функции REUSE_ALV_LIST_DISPLAY
Подскажите что можно выводить в Subtotal строку кроме суммарного значения? Мне вот надо ещё - среднее, текст (зависит от того что в поле fieldcat). Не пойму: неужели это не предусмотрено?
Age: 165 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Sat May 10, 2008 5:22 pm Post subject:
Инна, в одном из старых постов я приводил текст события SUBTOTAL_TEXT для alv grid. В примере добавляется слово 'Итого' перед subtotal текстом.
Также смотрите пример SUBTOTAL_TEXT в программе BCALV_TEST_LIST_EVENTS
Используется два поля с подсуммами
Code:
CLASS lcl_ils DEFINITION DEFERRED.
DATA: FCODE LIKE SY-UCOMM,
FCODE2 LIKE SY-UCOMM,
SCODE LIKE SY-UCOMM.
DATA:
gc_alv TYPE scrfname VALUE 'CONTAINER',
gc_custom_alv TYPE REF TO cl_gui_custom_container,
grid_alv TYPE REF TO cl_gui_alv_grid.
DATA: gt_alv TYPE STANDARD TABLE OF ZMSD_GL WITH HEADER LINE,
gwa_alv TYPE ZMSD_GL,
field_catalog TYPE lvc_t_fcat WITH HEADER LINE,
gs_layout_alv TYPE lvc_s_layo,
gt_sort TYPE lvc_t_sort WITH HEADER LINE.
DATA: alv_event_receiver TYPE REF TO lcl_ils.
*&---------------------------------------------------------------------*
*& Class LCL_ILS
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_ils DEFINITION.
PUBLIC SECTION.
METHODS handle_subtotal_text for event subtotal_text of cl_gui_alv_grid
importing
es_subtottxt_info
ep_subtot_line
e_event_data.
ENDCLASS. "LCL_ILS
*&---------------------------------------------------------------------*
*& Class (Implementation) lcl_ils
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_ils IMPLEMENTATION.
* добавляет слово 'Итого' перед subtotal текстом
METHOD handle_subtotal_text.
DATA: LEN TYPE I,
POS TYPE I.
assign ep_subtot_line->* to <fs1>.
es_subtottxt_info = es_subtottxt_info.
assign e_event_data->m_data->* to <fs>.
LEN = STRLEN( <fs> ).
WHILE POS < LEN.
IF <fs>+POS(1) EQ ' '.
EXIT.
ENDIF.
POS = POS + 1.
ENDWHILE.
IF POS < LEN.
SHIFT <fs> BY POS PLACES.
CONCATENATE 'Итого '(103) <fs> INTO <fs>.
ENDIF.
ENDMETHOD.
SET PF-STATUS 'STATUS_0200'.
SET TITLEBAR 'TITLE_0200'.
PERFORM FILL_KORR_TABLE.
IF gc_custom_alv IS INITIAL.
CREATE OBJECT gc_custom_alv
EXPORTING
container_name = gc_alv
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
* add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
endif.
IF alv_event_receiver IS INITIAL.
CREATE OBJECT alv_event_receiver.
set handler alv_event_receiver->handle_subtotal_text for grid_alv.
SET HANDLER alv_event_receiver->on_dblclick FOR grid_alv.
ENDIF.
call method cl_gui_control=>set_focus exporting control = grid_alv.
ENDIF.
ENDMODULE. " STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.
SCODE = FCODE2.
CLEAR FCODE2.
CASE SCODE.
WHEN 'EXIT' OR 'CANC' OR 'BACK'.
call method gc_custom_alv->free.
free alv_event_receiver.
free grid_alv.
free gc_custom_alv.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
*& Form MASK_COLUMNS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_FIELDCAT text
*----------------------------------------------------------------------*
form MASK_COLUMNS
tables p_gt_fieldcat type lvc_t_fcat
p_GT_SORT type lvc_t_SORT.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.