Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Regd: Calculation of TOTAL field in ALV report

Hi All,

We have a scenario that we are not getting the total value for numeric fields in ALV report.

Below i have given the code used for it.

G_KEY = 'X'.

G_NOKEY = SPACE.

G_SUM = 'X'.

G_NOSUM = SPACE.

PERFORM BUILD_FIELDCAT USING 'VBELN' G_KEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'BLDAT' G_NOKEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'VGBEL' G_KEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'POSNR' G_KEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'MATNR' G_KEY G_NOSUM..

PERFORM BUILD_FIELDCAT USING 'LFIMG' G_NOKEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'VRKME' G_NOKEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'NETPR' G_NOKEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'BRTWR' G_NOKEY G_NOSUM.

PERFORM BUILD_FIELDCAT USING 'VALUE_INR' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'B_DUTY' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'S_TOTAL1' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'CV_DUTY' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'C_CVD' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'S_TOTAL2' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'C_DUTY' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'S_TOTAL3' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'A_DUTY' G_NOKEY G_SUM.

PERFORM BUILD_FIELDCAT USING 'T_DUTY' G_NOKEY G_SUM.

PERFORM BUILD_LAYOUT.

PERFORM BUILD_DISPLAY.

&----


*& Form DISPLAY

&----


  • text

----


FORM BUILD_DISPLAY.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = TEXT-000

  • I_GRID_SETTINGS =

IS_LAYOUT = IG_LAYOUT

IT_FIELDCAT = IG_FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IG_INBOUND

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. "DISPLAY

&----


*& Form BUILD_FIELDCAT

&----


  • text

----


  • -->G_FIELDNAME text

  • -->L_KEY text

  • -->L_SUM text

----


FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME L_KEY TYPE C L_SUM TYPE C.

CLEAR WG_FIELDCAT_LN.

ADD 1 TO G_COL_POS.

WG_FIELDCAT_LN-REF_TABNAME = 'IG_INBOUND'.

WG_FIELDCAT_LN-FIELDNAME = L_FIELDNAME.

WG_FIELDCAT_LN-KEY = L_KEY.

WG_FIELDCAT_LN-DO_SUM = L_SUM.

WG_FIELDCAT_LN-COL_POS = G_COL_POS.

WG_FIELDCAT_LN-NO_OUT = SPACE.

WG_FIELDCAT_LN-QFIELDNAME = SPACE.

WG_FIELDCAT_LN-HOTSPOT = SPACE.

APPEND WG_FIELDCAT_LN TO IG_FIELDCAT.

ENDFORM. "BUILD_FIELDCAT

&----


*& Form BUILD_LAYOUT

&----


  • text

----


FORM BUILD_LAYOUT.

IG_LAYOUT-TOTALS_TEXT = 'Total Amount'.

*IG_LAYOUT-SUBTOTALS_TEXT = 'A'.

IG_LAYOUT-ZEBRA = 'X'.

ENDFORM.

Help and Sugesstions will be much appreciated.

Thanks & Regds.

Ramesh.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question