2009 Mar 09 5:00 AM
Hi,
Im displaying an ALV using reuse_alv_grid_display. Im populating the events table and calling appropriate routines. However the events are called only for specific events like 'TOP_OF_PAGE' or END_OF_PAGE. The events are not getting triggered for SUBTOTALS_TEXT & BEFORE_LINE_OUTPUT.
Can any one point out the reason ?
BYe
2009 Mar 09 5:17 AM
Hi,
iam able to display the subtotal text using alv events,
here is the code,
W_EVENT-NAME = 'SUBTOTAL_TEXT'.
W_EVENT-FORM = 'SUBTOT_TEXT'.
APPEND W_EVENT TO T_EVENT.
FORM SUBTOT_TEXT CHANGING
P_TOTAL TYPE ANY
T_TEXT TYPE SLIS_SUBTOT_TEXT.
T_TEXT-CRITERIA = 'VBELN'. -
> "give the field on which you are doing sub-totals.
T_TEXT-DISPLAY_TEXT_FOR_SUBTOTAL = 'Subtotal' .
ENDFORM. "SUBTOT_TEXT
Regards,
R K.
2009 Mar 09 5:17 AM
Hi,
iam able to display the subtotal text using alv events,
here is the code,
W_EVENT-NAME = 'SUBTOTAL_TEXT'.
W_EVENT-FORM = 'SUBTOT_TEXT'.
APPEND W_EVENT TO T_EVENT.
FORM SUBTOT_TEXT CHANGING
P_TOTAL TYPE ANY
T_TEXT TYPE SLIS_SUBTOT_TEXT.
T_TEXT-CRITERIA = 'VBELN'. -
> "give the field on which you are doing sub-totals.
T_TEXT-DISPLAY_TEXT_FOR_SUBTOTAL = 'Subtotal' .
ENDFORM. "SUBTOT_TEXT
Regards,
R K.
2009 Mar 09 5:25 AM
Hi,
Thanks for your prompt reply. I tried your code but it is not working ! One more thing i even tried to have subtotals text using , following code,
t_slis_layout_alv-subtotals_text = 'SUB'.
t_slis_layout_alv-totals_text = 'GRand Total'.
and passed this variable to is_layout parameter. However the ALV is ignoring this text also. The first column is wide enuf to show the texts.
The subtotals are also done on first column. Is it the reason ?
2009 Mar 09 5:36 AM
Hi,
The above code is working fine for me,
however,
did u filled your sort table
i.e.
W_SORT-FIELDNAME = 'VBELN'.
W_SORT-SUBTOT = 'X'.
append w_sort to t_sort.
after that, code as previous and pass that event table , sort table to your reuse_alv__grid_display fm.
Regards,
R K.
2009 Mar 09 5:45 AM
hi,
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'. "---> based on 'LIFNR' u r calculating subtotals
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'D'. "-----> this is the field of ur internal table for displaying
"SUB TOTAL as text.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
" pass wa_sort to the function module.
wa_event-name = 'SUBTOTAL_TEXT'.
wa_event-form = 'SUBTOTAL'.
APPEND wa_event TO it_event.
pass it_event to the function module
*&---------------------------------------------------------------------*
*& Form subtotal
*&---------------------------------------------------------------------*
FORM subtotal USING i_listhead STRUCTURE wa_ekpo i_subtotal TYPE slis_subtot_text.
READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
IF sy-subrc = 0.
IF i_subtotal-criteria = 'D'.
i_subtotal-display_text_for_subtotal = 'Sub total'.
ENDIF.
ENDIF.
ENDFORM. "subtotal
Thanks & Regards
2009 Mar 09 6:03 AM
Thanks guys for your valuable time.
The subtotals are displayed fine. However the subtotals_text event is not getting triggered. Ive also populate the events table. Events liokf TOP_OF_PAGE are getting triggered however the routine for subtotals is not getting triggered ?
Any clues friends ?
2009 Mar 09 6:32 AM
hi,
make sure that you define a dummy field in your internal table to display subtotal text.
TYPES: BEGIN OF ty_ekpo,
lifnr TYPE ekko-lifnr, "vendor number
ebeln TYPE ekko-ebeln, "purchase document number
ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document
matnr TYPE ekpo-matnr, "Material Number
bukrs TYPE ekpo-bukrs, "Company Code
werks TYPE ekpo-werks, "Plant
lgort TYPE ekpo-lgort, "Storage Location
menge TYPE ekpo-menge, "Purchase Order Quantity
netpr TYPE ekpo-netpr,
d, "Dummy field to fire the Subtotal text event
END OF ty_ekpo.
Define the field catalog
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-ref_tabname = 'EKKO'.
wa_fcat-emphasize = 'C110'.
wa_fcat-tabname = 'IT_EKPO'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'EBELN'.
wa_fcat-ref_tabname = 'EKKO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C210'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'EBELP'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C310'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C410'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BUKRS'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C510'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C610'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'LGORT'.
wa_fcat-ref_tabname ='EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C710'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 8.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-emphasize = 'C310'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 9.
wa_fcat-fieldname = 'NETPR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-do_sum = 'X'.
wa_fcat-emphasize = 'C210'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
" Define field catalog for the field 'D' as well
wa_fcat-col_pos = 10.
wa_fcat-fieldname = 'D'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-ref_fieldname = 'NETPR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-no_out = 'X'.
APPEND wa_fcat TO it_fcat.
" pass this it_fcat to the function modlule
If the problem still persists , then why dont you copy-paste your code here...?so that it will
be helpful to solve your issue
Thanks & Regards
2009 Mar 09 7:15 AM
Thanks 'Always Learner' ...... Your suggestion worked like a charm ! I dont know why the event was not triggering otherwise (w/o inclusion of dummy field ). Thanks a lot !
2009 Mar 09 7:19 AM
Hi,
One more question. BEFORE_LINE_OUTPUT is also not triggering . Is there also a workaround for triggering it ?
Bye
2009 Mar 09 7:26 AM
Hi,
No workaround for BEFORE_LINE_OUTPUT. If you write the following it should trigger this event:
wa_events-name = 'BEFORE_LINE_OUTPUT'.
wa_events-form = 'SUB_BEFORE_LINE_OUTPUT1'.
append wa_events to i_events.
form sub_before_line_output1 using l_v_line type slis_lineinfo."#EC CALLED
do processing.
endform.
2009 Mar 09 7:28 AM
thanks guys for your replies.....im closing this thread (and offcourse rewarding pnts)
2009 Mar 09 5:22 AM
Hi Mac,
u need to code this in a FORM...ENDFORM and call this PERFORM for SUBTOTALS TEXT before calling the REUSEALV_GRID...FM ..like
&----
*& Form TOTtext_init
&----
TEXT OF TOTAL AND SUBTOTAL
----
-->P_S_TXT text
----
FORM tottext_init USING p_s_txt TYPE slis_layout_alv.
DATA colo1 TYPE slis_specialcol_alv.
colo1-fieldname = 'BILLAMT'.
colo1-color-col = '4'.
colo1-color-int = '1'.
APPEND colo1 TO colo.
it_col-col = 'C21'.
APPEND it_col.
p_s_txt-totals_text = 'Total'.
p_s_txt-subtotals_text = 'Subtotal'.
p_s_txt-info_fieldname = 'BILLAMT'.
ENDFORM. " TOTtext_init
And call this PERFORM 'TOTtext_init' befor the REUSE_ALV....FM...
Keerthi.
2009 Mar 09 7:39 AM