F ALV DO_SUM Program in SAP ABAP | CodeTheta

ALV DO_SUM Program in SAP ABAP

August 31, 2019

Code :
REPORT ZVP_ALV_DO_SUM.

TYPE-POOLSSLIS.

TYPESBEGIN OF EMP,
         ID   TYPE CHAR10,
         NAME TYPE CHAR10,
         SAL TYPE INT4,
       END OF EMP.

DATAIT_EMP    TYPE STANDARD TABLE OF EMP,
      WA_EMP    TYPE EMP,

      IT_FCAT   TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT   TYPE SLIS_FIELDCAT_ALV,
      WA_LAYOUT TYPE SLIS_LAYOUT_ALV.


WA_EMP-ID '1'.
WA_EMP-NAME 'SANJIT'.
WA_EMP-SAL '25000'.
APPEND WA_EMP TO IT_EMP.
CLEAR WA_EMP.

WA_EMP-ID '2'.
WA_EMP-NAME 'RAJU'.
WA_EMP-SAL '20000'.
APPEND WA_EMP TO IT_EMP.
CLEAR WA_EMP.

WA_EMP-ID '3'.
WA_EMP-NAME 'GANESH'.
WA_EMP-SAL '35000'.
APPEND WA_EMP TO IT_EMP.
CLEAR WA_EMP.

WA_EMP-ID '4'.
WA_EMP-NAME 'SUVANKAR'.
WA_EMP-SAL '23000'.
APPEND WA_EMP TO IT_EMP.
CLEAR WA_EMP.

WA_EMP-ID '5'.
WA_EMP-NAME 'KAJOL'.
WA_EMP-SAL '18000'.
APPEND WA_EMP TO IT_EMP.
CLEAR WA_EMP.


WA_FCAT-COL_POS '1'.
WA_FCAT-FIELDNAME 'ID'.
WA_FCAT-SELTEXT_M 'USER ID'.
APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-COL_POS '2'.
WA_FCAT-FIELDNAME 'NAME'.
WA_FCAT-SELTEXT_M 'CUSTOMER NAME'.
APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-COL_POS '3'.
WA_FCAT-FIELDNAME 'SAL'.
WA_FCAT-SELTEXT_M 'CUSTOMER SALARY'.
WA_FCAT-DO_SUM 'X'.
APPEND WA_FCAT TO IT_FCAT.

WA_LAYOUT-COLWIDTH_OPTIMIZE 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    IS_LAYOUT     WA_LAYOUT
    IT_FIELDCAT   IT_FCAT
  TABLES
    T_OUTTAB      IT_EMP.

Output :



IDE Used To Test This Code : SAP gui.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment