Skip to Content
0
Former Member
Dec 21, 2006 at 05:31 PM

alv report with totals text

17 Views

Hi all,

This is my code .I want to display totals and subtotals with text , even though i define layout and populating text . But its not not working for me. Can any one resolve this issue?

REPORT ZTEST_E .

TABLES:ekpo.

TYPE-POOLS:slis.

DATA:BEGIN OF t_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln,

netwr LIKE ekpo-netwr,

brtwr LIKE ekpo-brtwr,

END OF t_ekpo.

DATA:fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

fieldcat1 type slis_t_sortinfo_alv WITH HEADER LINE,

g_repid LIKE sy-repid,

layout TYPE slis_layout_alv .

SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.

SELECT-OPTIONS:s_ebeln FOR ekpo-ebeln.

SELECTION-SCREEN END OF BLOCK BL1.

START-OF-SELECTION.

PERFORM populate_header.

PERFORM populate_text.

PERFORM populate_output.

END-OF-SELECTION.

FORM populate_header.

fieldcat-fieldname = 'EBELN'.

fieldcat-seltext_m = 'Po Number'.

fieldcat-tabname = t_ekpo.

fieldcat-col_pos = 0.

fieldcat-outputlen = 20.

fieldcat-key = 'x'.

fieldcat-emphasize = 'x'.

APPEND fieldcat to fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'NETWR'.

fieldcat-seltext_m = 'Net CURRENCY'.

fieldcat-tabname = t_ekpo.

fieldcat-col_pos = 0.

fieldcat-outputlen = 20.

fieldcat-key = 'x'.

fieldcat-emphasize = 'x'.

fieldcat-do_sum = 'x'.

APPEND fieldcat to fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'BRTWR'.

fieldcat-seltext_m = 'Gross CURRENCY'.

fieldcat-tabname = t_ekpo.

fieldcat-col_pos = 0.

fieldcat-outputlen = 20.

fieldcat-key = 'x'.

fieldcat-do_sum = 'x'.

fieldcat-emphasize = 'x'.

APPEND fieldcat to fieldcat.

CLEAR fieldcat.

fieldcat1-fieldname = 'NETWR'.

fieldcat1-up = 'x'.

fieldcat1-subtot = 'x'.

APPEND fieldcat1 to fieldcat1.

CLEAR fieldcat1.

ENDFORM.

FORM populate_text.

layout-zebra = 'X'.

layout-subtotals_text = 'Sub Totals:'.

layout-colwidth_optimize = 'X'.

layout-zebra = 'X'.

layout-totals_text = 'Totals:'.

layout-colwidth_optimize = 'X'.

ENDFORM.

*

FORM populate_output.

SELECT * FROM ekpo INTO CORRESPONDING FIELDS OF TABLE t_ekpo

WHERE ebeln IN s_ebeln.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = g_repid

I_CALLBACK_USER_COMMAND = ' '

IT_FIELDCAT = fieldcat[]

IT_SORT = fieldcat1[]

IS_LAYOUT = layout

TABLES

T_OUTTAB = t_ekpo

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.