2008 Apr 17 6:32 AM
hi gurus
i have an alv display report of TAT for a month..
insp lot | Work center plant |....| TAT | ....
Above are some of my fields.
Now at the end of each work center , I have t display the TAT average in a row as a sub-total.
also at the end of the report for this month, i should display the total avg tat.
I started with this code.
*MOD
DATA: l_i_sort TYPE slis_t_sortinfo_alv,
l_wa_sort TYPE slis_sortinfo_alv.
CONSTANTS: l_c_int_1 TYPE int1 VALUE 1,
l_c_int_2 TYPE int1 VALUE 2,
l_c_arbpl TYPE slis_fieldname VALUE 'ARBPL'.
l_wa_sort-spos = l_c_int_1.
l_wa_sort-fieldname = l_c_arbpl.
l_wa_sort-up = c_x.
l_wa_sort-subtot = l_c_int_2.
APPEND l_wa_sort TO l_i_sort.
*MODplz do the required modifications in my code for acheiving my result.
Thanks in advance..
chaitanya
2008 Apr 17 6:39 AM
Hi,
Wherever you r filling the fieldcatalogue... just put the following logic if you have not.
wa_fieldcat-do_sum = 'X'.
Thanks.
Swati.
hi gurus
i have an alv display report of TAT for a month..
insp lot | Work center plant |....| TAT | ....
Above are some of my fields.
Now at the end of each work center , I have t display the TAT average in a row as a sub-total.
also at the end of the report for this month, i should display the total avg tat.
I started with this code.
*MOD
DATA: l_i_sort TYPE slis_t_sortinfo_alv,
l_wa_sort TYPE slis_sortinfo_alv.
CONSTANTS: l_c_int_1 TYPE int1 VALUE 1,
l_c_int_2 TYPE int1 VALUE 2,
l_c_arbpl TYPE slis_fieldname VALUE 'ARBPL'.
l_wa_sort-spos = l_c_int_1.
l_wa_sort-fieldname = l_c_arbpl.
l_wa_sort-up = c_x.
l_wa_sort-subtot = l_c_int_2.
APPEND l_wa_sort TO l_i_sort.
*MODplz do the required modifications in my code for acheiving my result.
Thanks in advance..
chaitanya
2008 Apr 17 6:36 AM
Hi Chaitanya ,
try this
*MOD
DATA: l_i_sort TYPE slis_t_sortinfo_alv,
l_wa_sort TYPE slis_sortinfo_alv.
CONSTANTS: l_c_int_1 TYPE int1 VALUE 1,
l_c_int_2 TYPE int1 VALUE 2,
l_c_arbpl TYPE slis_fieldname VALUE 'ARBPL'.
l_wa_sort-spos = l_c_int_1.
l_wa_sort-fieldname = l_c_arbpl.
l_wa_sort-up = c_x.
l_wa_sort-subtot =c_x. <----
changed to c_x
APPEND l_wa_sort TO l_i_sort.
*MOD
2008 Apr 17 6:38 AM
Then how would the calculation of TAT being taken with my code.
2008 Apr 17 6:41 AM
Hi chaitanya,
you had mentioned the fieldname as ARBPL , work center
l_wa_sort-fieldname = l_c_arbpl.
So after every change in that field the subtotals will be calculated for the amount fields
so no need to mention TAT field
2008 Apr 17 6:39 AM
Hi,
Wherever you r filling the fieldcatalogue... just put the following logic if you have not.
wa_fieldcat-do_sum = 'X'.
Thanks.
Swati.
2008 Apr 17 6:40 AM
Hi,
Try this
data: i_layout type slis_layout_alv.
I_LAYOUT-totals_text = 'SUM TEXT'.
And pass the structure i_layout to the FM you are using.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = ws_program
is_layout = i_layout
Hope this helps you.
Also Go through the sample code for subtotal..
REPORT z_demo_alv_sort.
TYPES :
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
waerk TYPE vbak-waerk, " Document currency
END OF ty_vbak.
DATA:
vbak TYPE vbak,
gt_vbak TYPE TABLE OF ty_vbak.
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
----
INITIALIZATION.
v_1 = 'Maximum of records to read'.
----
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
----
Form f_read_data
----
FORM f_read_data.
SELECT vkorg kunnr vbeln netwr waerk
UP TO p_max ROWS
INTO TABLE gt_vbak
FROM vbak
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
----
Form f_display_data
----
FORM f_display_data.
TYPE-POOLS: slis. " ALV Global types
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA
END OF PROGRAM Z_DEMO_ALV_SORT **********************
Regards,
Raj.
2008 Apr 17 6:44 AM
Hello Chaitanya,
In the fieldcatalog of the work center plant , give sort = 'X'.
In the fieldcatalog of the TAT field , give the sub_tot = 'X'.
If u do the subtotal in the ALV, then it automatically display the total field at the end of the field.
Hope it is helpful.
Reward Points.
2008 Apr 17 6:49 AM
Hi,
and one more thing is , have you passed the table l_i_sort to FM REUSE_ALV_GRID_DISPLAY
it_sort = l_i_sort
2008 Apr 17 6:57 AM
2008 Apr 17 7:56 AM
HI,
I have got the sub totals.
But now i should give my text for that sub-total work center wise
and for the final report.
for ex: Sub- total for work center = ____
avg TAT for the month is = _____
how to go about this :
2008 Apr 17 6:58 AM
Hi Chaitanya,
Do u want to display TAT average for each Work Center or TAT subtotal for one Work Center ? If you build SORT table and pass through function module, it displays total TAT for that Work Center not Average value of TAT.
If u want only subtotal then build SORT Table and pass that.
If you want to have subtotal text as well .Check this link.
[http://www.saptechnical.com/Tutorials/ALV/Subtotals/text.htm|http://www.saptechnical.com/Tutorials/ALV/Subtotals/text.htm]
Regards,
Venkat.O
w_sort-fieldname = 'ARBPL'.
w_sort-tabname = 'ITAB'. "Which is displayed through function module REUSE*
w_sort-up = 'X'. "Ascending order
w_sort-subtot = 'X'. "Subtotal
APPEND w_sort TO i_sort.
CLEAR w_sort.
2008 Apr 17 8:00 AM
I want to display the avg TAT., i.e.. Total TAT for workcenter/ no of entries for work center
Wat can i do.
2008 Jul 09 6:42 AM