11-27-2014 3:46 PM
Hi all,
There is an issue with subtotal average display in the ALV output with standard program.
Consider there is two columns in the output display as follows.
Column A in % Column B in %
======== ==========
1 1
2 2
3 3
4 4
======= ========
10 2.5
For both the column it should display average as 2.5. But in column A, it is displaying the total sum of the row instead of average.
Fieldcatalog value has been set as ls_fieldcat-do_sum = 'C' for both the columns and the data type for the column A and B is P.
Need help to solve this issue.
Thank You.
11-27-2014 4:06 PM
Hi RK,
Check your structure, and your assign in t_fieldcat, many times a simple bad reference change this value. Try only show this columns and execute.
I hope help.
11-28-2014 2:40 PM
Hello Francisco Rodríguez Loera,
Thanks for your reply.
I did tried to show only this two columns in the output, The output was the same.
Column A shows sum and Column B shows the average value.
And also examined the fieldcat properties of both column. It is same.
But I find the fieldcat column sequence is changed when compared with fieldcat column position to the ALV list output.
In fieldcat, the column position COL_POS = 1 for field A and COL_POS = 2 for field B
But in the ALV list output, it is displayed as field B as first field and field A as second field.
will this sequence impact the ALV list output ?
Thanks,
RK.
11-28-2014 5:58 PM
Hi RK,
Are you have another field at the first?
Sounds like your program structure, doesnt match with your output.
Ex.
Structure:
A
B
C
And your output, only try show two fields.
A--No show (POS = 1) AVG
B--Show (POS=2) AVG
C--Show (POS=3) Not defined.
I hope help.
Regards.
12-02-2014 9:31 AM
Hi Francisco Rodríguez Loera,
I did examine the output internal table and the fieldcat internal table. It has same sequence of fields that has been passed to the FM REUSE_ALV_GRID_DISPLAY.
Regards,
RK
11-28-2014 5:23 PM
hi rk,
It is working fine. Have a look at below source.
*&---------------------------------------------------------------------*
*& Report ZR_ALV_SUM_TOTAL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZR_ALV_SUM_TOTAL.
TYPE-POOLS slis.
TYPES:
BEGIN OF ty,
A TYPE p DECIMALS 2,
B TYPE p DECIMALS 2,
END OF ty.
DATA: wa type TY,
itab TYPE STANDARD TABLE OF ty.
START-OF-SELECTION.
PERFORM sub_alv_display.
*&---------------------------------------------------------------------*
*& Form sub_alv_display
*&---------------------------------------------------------------------*
* Display alv
*----------------------------------------------------------------------*
FORM sub_alv_display.
DATA:
li_fieldcat TYPE slis_t_fieldcat_alv,
lw_layout TYPE slis_layout_alv,
li_sort TYPE slis_t_sortinfo_alv,
lw_sort TYPE slis_sortinfo_alv.
PERFORM sub_get_data.
PERFORM sub_form_fieldcat CHANGING li_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = lw_layout
it_fieldcat = li_fieldcat "can sum total
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. "sub_alv_display
*&---------------------------------------------------------------------*
*& Form sub_get_data
*&---------------------------------------------------------------------*
* Select data
*----------------------------------------------------------------------*
FORM sub_get_data.
wa-a = 1.
wa-b = 1.
append wa to itab.
wa-a = 2.
wa-b = 2.
append wa to itab.
wa-a = 3.
wa-b = 3.
append wa to itab.
wa-a = 4.
wa-b = 4.
append wa to itab.
ENDFORM. "sub_get_data
*&---------------------------------------------------------------------*
*& Form sub_form_fieldcat
*&---------------------------------------------------------------------*
* Define fieldcategory
*----------------------------------------------------------------------*
* -->PI_FIELDCAT text
*----------------------------------------------------------------------*
FORM sub_form_fieldcat CHANGING pi_fieldcat TYPE slis_t_fieldcat_alv.
DATA:
lw_fieldcat TYPE slis_fieldcat_alv.
lw_fieldcat-fieldname = 'A'.
lw_fieldcat-seltext_l = 'A'.
lw_fieldcat-do_sum = 'C'.
APPEND lw_fieldcat TO pi_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = 'B'.
lw_fieldcat-seltext_l = 'B'.
lw_fieldcat-do_sum = 'C'.
APPEND lw_fieldcat TO pi_fieldcat.
CLEAR lw_fieldcat.
ENDFORM. "sub_form_fieldcat
12-02-2014 9:28 AM
Hello Abdul,
Thanks for your reply. It is happening in standard program delivered by SAP.
I did gone through the basic checks as you explained. Despite having the fieldcat checks that is by you. It is showing the error.
Thanks,
RK.