Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Reports

Former Member
0 Likes
435

Hi

Iam doing subtotals for each customer month wise.

But in place of subtotal, I want to display average of that subtotal.

how can I get it?

Is there any option to get it automatically?

Thanks in advance

Hi

Iam doing subtotals for each customer month wise.

But in place of subtotal, I want to display average of that subtotal.

how can I get it?

Is there any option to get it automatically?

Thanks in advance

3 REPLIES 3
Read only

Former Member
0 Likes
409

Hi,

If you are using the OO concept . and field catalog type "LVC_S_FCAT" there is one field called "H_FTYPE" for which you can specify the type of function you want to perform like (sum, avg, max, min, ...) ...

Please assign the points if it helps.

Regards,

Gaurang

Read only

0 Likes
409

Hi

Iam not using OO ALV But Iam using Simple ALV

Is there option for avg or not?

plz tell me

Thanks & Regards

venkat

Read only

p291102
Active Contributor
0 Likes
409

Hi,

I am sending the sample report for the subtotal for alv report. Kindly go through it.

&----


*& Report YMS_SUBHEADINGALV2 *

*& *

&----


*& *

*& *

&----


REPORT YMS_SUBHEADINGALV2.

TYPE-POOLS : SLIS.

TYPES : BEGIN OF YVBRK_LIST,

VBELN LIKE VBRK-VBELN,

FKART LIKE VBRK-FKART,

BELNR LIKE VBRK-BELNR,

END OF YVBRK_LIST.

TYPES : BEGIN OF YVBRP_LIST,

VBELN LIKE VBRP-VBELN,

POSNR LIKE VBRP-POSNR,

NETWR LIKE VBRP-NETWR,

END OF YVBRP_LIST.

DATA: I_VBRK TYPE STANDARD TABLE OF YVBRK_LIST

INITIAL SIZE 0 WITH HEADER LINE.

DATA: I_VBRP TYPE STANDARD TABLE OF YVBRP_LIST

INITIAL SIZE 0 WITH HEADER LINE.

DATA: KEY_INFO TYPE SLIS_KEYINFO_ALV,

REPORT_ID LIKE SY-REPID,

TABLE_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

GT_EVENTS TYPE SLIS_T_EVENT,

GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

G_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

G_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST'.

INITIALIZATION.

REPORT_ID = SY-REPID.

KEY_INFO-HEADER01 = 'VBELN'.

KEY_INFO-ITEM01 = 'VBELN'.

KEY_INFO-HEADER02 = SPACE.

KEY_INFO-ITEM02 = 'NETWR'.

GS_LAYOUT-GROUP_CHANGE_EDIT = 'X'.

GT_SORT-FIELDNAME = 'VBELN'.

GT_SORT-TABNAME = '1'.

GT_SORT-SPOS = 1.

GT_SORT-UP = 'X'.

GT_SORT-SUBTOT = 'X'.

GT_SORT-GROUP = '*'.

APPEND GT_SORT.

GT_SORT-FIELDNAME = 'POSNR'.

GT_SORT-TABNAME = '2'.

GT_SORT-SPOS = 2.

GT_SORT-UP = 'X'.

GT_SORT-SUBTOT = 'X'.

GT_SORT-GROUP = ''.

APPEND GT_SORT.

TABLE_FIELDCAT-FIELDNAME = 'VBELN'.

TABLE_FIELDCAT-seltext_m = 'Sales Document'.

TABLE_FIELDCAT-TABNAME = '1'.

TABLE_FIELDCAT-COL_POS = '1'.

TABLE_FIELDCAT-OUTPUTLEN = 17.

TABLE_FIELDCAT-DO_SUM = ' '.

APPEND TABLE_FIELDCAT.

TABLE_FIELDCAT-FIELDNAME = 'POSNR'.

TABLE_FIELDCAT-seltext_m = 'Sales Document Item'.

TABLE_FIELDCAT-TABNAME = '2'.

TABLE_FIELDCAT-COL_POS = '1'.

TABLE_FIELDCAT-OUTPUTLEN = 14.

TABLE_FIELDCAT-DO_SUM = ' '.

APPEND TABLE_FIELDCAT.

TABLE_FIELDCAT-FIELDNAME = 'NETWR'.

TABLE_FIELDCAT-seltext_m = 'Net value'.

TABLE_FIELDCAT-TABNAME = '2'.

TABLE_FIELDCAT-COL_POS = '2'.

TABLE_FIELDCAT-OUTPUTLEN = 15.

TABLE_FIELDCAT-DO_SUM = 'X'.

APPEND TABLE_FIELDCAT.

PERFORM EVENTTAB_BUILD USING GT_EVENTS[].

START-OF-SELECTION.

SELECT VBELN

FKART

BELNR

INTO CORRESPONDING FIELDS OF TABLE I_VBRK

FROM VBRK

WHERE VBELN > '0090000121' AND VBELN < '0090000135'.

SELECT VBELN

POSNR

NETWR

INTO CORRESPONDING FIELDS OF TABLE I_VBRP

FROM VBRP

FOR ALL ENTRIES IN I_VBRK

WHERE VBELN = I_VBRK-VBELN.

PERFORM WRITE_REPORT.

*&----


*& Form EVENTTAB_BUILD

*&----


  • text

*----


  • -->RT_EVENTS text

*----


FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.

"Registration of events to happen during list display

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = RT_EVENTS.

READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO RT_EVENTS.

ENDIF.

ENDFORM. "EVENTTAB_BUILD

*&----


*& Form TOP_OF_PAGE

*&----


  • text

*----


FORM TOP_OF_PAGE.

DATA: LS_LINE TYPE SLIS_LISTHEADER.

  • Header Data

REFRESH GT_LIST_TOP_OF_PAGE.

CLEAR LS_LINE.

  • LS_LINE-TYP = 'H'.

  • LS_LINE-INFO = 'Hierarchical Lists'.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM. "TOP_OF_PAGE

*&----


*& Form write_report

*&----


  • text

*----


FORM WRITE_REPORT.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPORT_ID

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = TABLE_FIELDCAT[]

IT_SORT = GT_SORT[]

IT_EVENTS = GT_EVENTS[]

I_TABNAME_HEADER = '1'

I_TABNAME_ITEM = '2'

I_STRUCTURE_NAME_HEADER = 'YVBRK_LIST'

I_STRUCTURE_NAME_ITEM = 'YVBRP_LIST'

IS_KEYINFO = KEY_INFO

TABLES

T_OUTTAB_HEADER = I_VBRK

T_OUTTAB_ITEM = I_VBRP.

ENDFORM. "write_report

Thanks,

Shankar