0% found this document useful (0 votes)
150 views4 pages

ALV Top of Page Commentry Write

This document defines an ALV report to display sales document data from the VBAK table. It includes: 1) Defining data structures and internal tables to store the VBAK data and ALV field catalog. 2) Retrieving data from VBAK based on selection criteria and populating the internal table. 3) Building the ALV field catalog and layout. 4) Displaying the ALV grid with the VBAK data and field catalog.

Uploaded by

Ashish Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views4 pages

ALV Top of Page Commentry Write

This document defines an ALV report to display sales document data from the VBAK table. It includes: 1) Defining data structures and internal tables to store the VBAK data and ALV field catalog. 2) Retrieving data from VBAK based on selection criteria and populating the internal table. 3) Building the ALV field catalog and layout. 4) Displaying the ALV grid with the VBAK data and field catalog.

Uploaded by

Ashish Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

*&---------------------------------------------------------------------*

*& Report  YKK_COMMENTARY_WRITE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YKK_COMMENTARY_WRITE.

TABLES VBAK.
TYPE-POOLS SLIS.
* Data Declaration
TYPES: BEGIN OF T_VBAK,
      VBELN TYPE VBAK-VBELN,
      ERDAT TYPE VBAK-ERDAT,
      ERNAM TYPE VBAK-ERNAM,
      AUDAT TYPE VBAK-AUDAT,
      VBTYP TYPE VBAK-VBTYP,
      NETWR TYPE VBAK-NETWR,
      VKORG TYPE VBAK-VKORG,
      VKGRP TYPE VBAK-VKGRP,
      LINE_COLOR(4) TYPE C,
      END OF T_VBAK.

DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
      WA_VBAK TYPE T_VBAK.

* ALV Data Declaration
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
      GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
      GD_REPID TYPE SY-REPID.

SELECT-OPTIONS: VBELN FOR VBAK-VBELN NO-EXTENSION.

START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BLD_FLDCAT.
PERFORM BLD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.

* Build Field Catalog for ALV Report
FORM BLD_FLDCAT.

FLDCAT-FIELDNAME = 'VBELN'.
FLDCAT-SELTEXT_M = 'Sales Document'.
FLDCAT-COL_POS = 0.
*FLDCAT-EMPHASIZE = 'C411'.
FLDCAT-OUTPUTLEN = 20.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERDAT'.
FLDCAT-SELTEXT_L = 'Record Date created'.
FLDCAT-COL_POS = 1.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERNAM'.
FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'AUDAT'.
FLDCAT-SELTEXT_M = 'Document Date'.
FLDCAT-COL_POS = 3.
FLDCAT-EMPHASIZE = 'C110'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VBTYP'.
FLDCAT-SELTEXT_L = 'SD Document category'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'NETWR'.
FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.
FLDCAT-COL_POS = 5.
FLDCAT-OUTPUTLEN = 60.
FLDCAT-DO_SUM = 'X'.
FLDCAT-DATATYPE = 'CURR'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKORG'.
FLDCAT-SELTEXT_L = 'Sales Organization'.
FLDCAT-COL_POS = 6.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKGRP'.
FLDCAT-SELTEXT_M = 'Sales Group'.
FLDCAT-COL_POS = 7.
FLDCAT-EMPHASIZE = 'C801'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.

ENDFORM.

* Build Layout for ALV Grid Report

FORM BLD_LAYOUT.

GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.

ENDFORM.

* Display report using ALV grid

FORM DISPLAY_ALV_REPORT.

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_CALLBACK_PROGRAM                = GD_REPID
   IS_LAYOUT                         = GD_LAYOUT
  I_CALLBACK_TOP_OF_PAGE           = 'TOP_OF_PAGE'
   IT_FIELDCAT                       = FLDCAT[]
   I_SAVE                            = 'X'
  TABLES
    T_OUTTAB                          = IT_VBAK
 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.

* Retrieve data from VBAK table and populate itab IT_VBAK

FORM DATA_RETRIEVAL.

DATA LD_COLOR(1) TYPE C.
SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG
FROM VBAK
INTO TABLE IT_VBAK WHERE VBELN IN VBELN.

LOOP AT IT_VBAK INTO WA_VBAK.
LD_COLOR = LD_COLOR + 1.
IF LD_COLOR = 8.
  LD_COLOR = 1.
ENDIF.
CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.
MODIFY IT_VBAK FROM WA_VBAK.
ENDLOOP.

ENDFORM.

FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
      W_HEADER TYPE SLIS_LISTHEADER.

W_HEADER-TYP = 'H'.
W_HEADER-INFO = 'WELCOME HEADER LIST'.
APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'REPORT:'.
W_HEADER-INFO = SY-REPID.
APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'DATE:'.
CONCATENATE SY-DATUM+4(2) ' / ' SY-DATUM+6(2) ' / ' SY-DATUM(4) INTO W_HEADER-
INFO.
APPEND W_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY       = T_HEADER.ENDFORM.

You might also like