Wednesday, December 22, 2010
We set DO_SUM = 'X' in the fieldcatalog for the Quantity field in the internal table.

REPORT ZTEST.
DATA:
      BEGIN OF IT_MARD OCCURS 0,
        MATNR TYPE MARD-MATNR,
        WERKS TYPE MARD-WERKS,
        LGORT TYPE MARD-LGORT,
        LABST TYPE MARD-LABST,
      END OF IT_MARD.
TYPE-POOLS:SLIS.
DATA:IT_FIELD TYPE SLIS_T_FIELDCAT_ALV.
DATA:WA_FIELD LIKE LINE OF IT_FIELD.
DEFINE FIELDCAT.
  WA_FIELD-FIELDNAME = &1 .
  WA_FIELD-TABNAME   = &2 .
  WA_FIELD-SELTEXT_M = &3 .
  WA_FIELD-DO_SUM    = &4 .
  APPEND WA_FIELD TO IT_FIELD.
  CLEAR  WA_FIELD.
END-OF-DEFINITION.

START-OF-SELECTION.
  SELECT * 
    FROM MARD 
     INTO CORRESPONDING FIELDS OF TABLE IT_MARD 
     UP TO 100 ROWS.
  "DO_SUM
  FIELDCAT:
        'MATNR' 'IT_MARD' 'MARD-MATNR' '',
        'WERKS' 'IT_MARD' 'MARD-WERKS' '',
        'LGORT' 'IT_MARD' 'MARD-LGORT' '',
        'LABST' 'IT_MARD' 'MARD-LABST' 'X'.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
      IT_FIELDCAT        = IT_FIELD
    TABLES
      T_OUTTAB           = IT_MARD.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.