Вы находитесь на странице: 1из 20

Abstract:

What if you could reformat a standard ABAP list as easily as a Microsoft Excel
spreadsheet? Many R/3 users are not aware that the report development using ABAP List
Viewer(ALV), which comes standard with R/3(since version 4.5X), lets you come very
close to doing just that. Unlike a standard ABAP list, ALV provides the end-user the
flexibility to individually customize the data output. Many traditional developers are
under the impression that ALV is a complicated and difficult tool to understand and use
until they started using. It really saves lot of time and system resources. This document is
intended for the users who want to quickly convert ABAP lists to ALV format. A
template was provided as a part of this paper which can be used to considerably reduce
the amount of time to less than 30 minutes to convert each ABAP list to ALV format.
However there are some restrictions that are outlined in this paper. Using this template,
you can also run ALV reports in the background unlike the standard examples provided
by SAP with the only exception that you will not have all ALV features like sorting are
available from spool.

About the author


Kasi Murthy is a senior ABAP consultant working with Tata Consultancy Services
(TCS), India. Kasi has over 8 years of SAP R/3 experience specializing in ABAP
development. Kasi has spent last 5 years managing SAP R/3 offshore onsite
development projects successfully. He can be reached at kasi.murthy@tcs.com
for any clarifications about this white paper.
What does ALV do for you?
ALV Grid Control is SAP’s graphical list-viewing tool and is similar in look and feel to
Microsoft Excel. ALV’s broad functionality lets you emphasize, hide, and reformat list
items; add graphic elements; and generally make any ABAP list display a more powerful
communications tool. ALV functionality lets users:
 Apply typical list functions like summing, sorting and filtering without
extra programming effort.
 Add response to user action by clicking on display line
 Define and save custom output settings both at user level and global level.
 Export list to other applications like excel.
 Create totals and sub-totals without additional programming effort.
 Create and share output templates.

SAP provides a set of ALV function modules that can be used to output a report. This set
of ALV functions is used to enhance the readability and functionality of any report
output. Cases arise in sap when the output of a report contains columns extending more
than 255 characters in length. In such cases, this set of ALV functions can help choose
selected columns and arrange the different columns from a report output and also save
different variants for report display. This is a very efficient tool for dynamically sorting
and arranging the columns from a report output. The report output can contain up to 90
columns in the display with the wide array of display options. The standard system
provides functions that allow the user to sort, filter, and sum data in tables. Depending on
the application, the ALV Grid Control includes additional application-specific functions
and hides functions available in the standard system.

The SAP List Viewer (ALV) standardizes the use of lists in the SAP System.

The commonly used ALV functions used for this purpose are;

1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT

How you call this function in your report?


After completion of all the data fetching from the database and append this data into an
Internal Table. Say I_ITAB.

Then use following function module.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'PROGRAM NAME'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA

Restrictions of using ALV:


Not all existing lists can be replaced by ALV components. Only Single-line and
multiple-line lists should be replaced by ALV. Hierarchical-sequential lists could be
replaced by ALV lists but recommended to check if it can be presented in multiple linear
lists which will follow one below the other or are distributed onto several screens.

So, keep in mind the above constraints and check whether you list type can be built by
ALV.

TIPS:
 For a description of some examples about ALV components, look at transaction
LIBS and reuse library transaction SE83.
 For practical examples of the ALV Grid Control, see development class SLIS.
 The SAP program BALVBT01 provides an example of displaying multiple ALV
LIST reports on one page
 Single-line and multiple-line lists can be replaced by ALV.

Note: Matrices could not be replaced by ALV. Hierarchical-sequential lists could be


replaced by ALV lists. But check first whether you can present your data by a linear list
type. Below you can find guidelines for implementing hierarchical-sequential lists. But
keep in mind that there is an alternative solution to this presentation problem: You may
also split the list into several simple lists, one for each group, which will follow one
below the other or are distributed onto several screens (a tab strip come in handy).
Template Program:
Below given template program can be used to convert existing lists to ALV format.
ONLY PORTIONS OF THE CODE HIGHLIGHTED IN BLUE need to be replaced with
your requirements. Please see my comments in BLUE in the logic. Copy the program into
ABAP editor and change as per your requirement. This program is a sample program
which will display invoice line item details when you provide billing document numbers.

REPORT ZSROP200
NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID zi.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
TABLES:
vbrp.

*--------------------------------
* Global Types
*--------------------------------
TYPE-POOLS: slis.

*--------------------------------
* Global Internal Tables
*--------------------------------
DATA:
i_fieldcat_alv TYPE slis_t_fieldcat_alv,
i_events TYPE slis_t_event,
i_event_exit TYPE slis_t_event_exit,
i_list_comments TYPE slis_t_listheader,
i_excluding TYPE slis_t_extab.

* Display data
* This is the internal table which will be passed on to ALV function module to display
data. Replace this with your internal table.
DATA: BEGIN OF i_data OCCURS 0,
vbeln LIKE vbrp-vbeln, "Billing document
posnr LIKE vbrp-posnr,
matnr LIKE vbrp-matnr,
fkimg LIKE vbrp-fkimg,
meins LIKE vbrp-meins,
matkl LIKE vbrp-matkl,
arktx LIKE vbrp-arktx,
werks LIKE vbrp-werks,
vstel LIKE vbrp-vstel,
lgort LIKE vbrp-lgort,
mvgr2 LIKE vbrp-mvgr2,
vbelv LIKE vbrp-vbelv,
vgbel LIKE vbrp-vgbel,
aubel LIKE vbrp-aubel,
kondm LIKE vbrp-kondm,
ktgrm LIKE vbrp-ktgrm,
vkgrp LIKE vbrp-vkgrp,
vkbur LIKE vbrp-vkbur,
kzwi1 LIKE vbrp-kzwi1,
kvgr2 LIKE vbrp-kvgr2,
kvgr3 LIKE vbrp-kvgr3,
kvgr4 LIKE vbrp-kvgr4,
prsdt LIKE vbrp-prsdt,
fbuda LIKE vbrp-fbuda,
txjcd LIKE vbrp-txjcd,
oid_extbol LIKE vbrp-oid_extbol,
oic_mot LIKE vbrp-oic_mot,
oic_truckn LIKE vbrp-oic_truckn,
oic_ptrip LIKE vbrp-oic_ptrip,
oignrule LIKE vbrp-oignrule,

END OF i_data.

*Internal table for data selection specific to this program.


DATA: BEGIN OF ivbrp OCCURS 0.
INCLUDE STRUCTURE vbrp.
DATA: END OF ivbrp.

*--------------------------------
* Global Variables
*--------------------------------
DATA:
w_variant LIKE disvariant,
wx_variant LIKE disvariant,
w_variant_save(1) TYPE c,
w_exit(1) TYPE c,
w_repid LIKE sy-repid,
w_user_specific(1) TYPE c,
w_callback_ucomm TYPE slis_formname,
w_print TYPE slis_print_alv,
w_layout TYPE slis_layout_alv,
w_html_top_of_page TYPE slis_formname,
w_fieldcat_alv LIKE LINE OF i_fieldcat_alv,
w_excluding LIKE LINE OF i_excluding,
w_events LIKE LINE OF i_events,
w_event_exit LIKE LINE OF i_event_exit,
w_list_comments LIKE LINE OF i_list_comments.

DATA: erdat(10) TYPE c.


DATA: time(8) TYPE c.
DATA: counter TYPE i.

*--------------------------------
* Global Constants
*--------------------------------
*constants:

*--------------------------------
* Selection Screen – replace selection screen in BLUE per your requirement
*--------------------------------
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-f01.

SELECT-OPTIONS: s_vbeln FOR vbrp-vbeln.

SELECTION-SCREEN END OF BLOCK selection.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK selection1 WITH FRAME TITLE text-f02.

SELECTION-SCREEN END OF BLOCK selection1.

SELECTION-SCREEN BEGIN OF BLOCK blk_params WITH FRAME TITLE text-


f03.
PARAMETERS:
p_vari LIKE disvariant-variant.
SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT (31) text-pe1


FOR FIELD p_grid .

PARAMETERS p_grid RADIOBUTTON GROUP rb01 DEFAULT 'X'.

SELECTION-SCREEN POSITION 40.


SELECTION-SCREEN COMMENT (17) text-pe2
FOR FIELD p_html .

PARAMETERS p_html AS CHECKBOX DEFAULT 'X'.


SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.
PARAMETERS:
p_list RADIOBUTTON GROUP rb01.
SELECTION-SCREEN END OF BLOCK blk_params.

*--------------------------------
* Initialization
*--------------------------------
INITIALIZATION.
PERFORM init_variant.
PERFORM variant_default USING p_vari.

*--------------------------------
* At Selection Screen PBO
*--------------------------------
AT SELECTION-SCREEN OUTPUT.

*----------------------------------
* At Selection Screen Value Request
*----------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM variant_f4 USING p_vari.

*--------------------------------
* At Selection Screen
*--------------------------------
AT SELECTION-SCREEN.
PERFORM variant_fill.

*--------------------------------
* Start of Selection
*--------------------------------
START-OF-SELECTION.

PERFORM get_data.

END-OF-SELECTION.
PERFORM fieldcat_build.
PERFORM event_build.
PERFORM event_exit_build.
PERFORM exclude_build.
PERFORM print_build.
PERFORM layout_build.
PERFORM display_data.

*--------------------------------
* Top of Page
*--------------------------------
TOP-OF-PAGE.

*--------------------------------
* Top of Page During Line Sel
*--------------------------------
TOP-OF-PAGE DURING LINE-SELECTION.

*--------------------------------
* At User Command
*--------------------------------
*AT USER-COMMAND.

*--------------------------------
* At Line Selection
*--------------------------------
*AT LINE-SELECTION.
*--------------------------------
* Macros
*--------------------------------
DEFINE skip_1.
write: /001 sy-vline,
at sy-linsz sy-vline.
END-OF-DEFINITION.

*----------------------------------------------------------------------
* Forms
*----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Form variant_f4
*&---------------------------------------------------------------------*
FORM variant_f4 USING p_variant.

CALL FUNCTION 'LVC_VARIANT_F4'


EXPORTING
is_variant = w_variant
i_save = w_variant_save
IMPORTING
e_exit = w_exit
es_variant = wx_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.

IF sy-subrc <> 0.
MESSAGE i000(zz) WITH text-g01.
ENDIF.

IF w_exit IS INITIAL.
w_variant-variant = wx_variant-variant.
p_variant = wx_variant-variant.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form init_variant
*&---------------------------------------------------------------------*
FORM init_variant.

CLEAR: w_variant.
w_repid = sy-repid.
w_variant-report = w_repid.
w_variant-username = sy-uname.
w_variant_save = 'A'. "All types

ENDFORM.
*&---------------------------------------------------------------------*
*& Form variant_default
*&---------------------------------------------------------------------*
FORM variant_default USING p_variant.

wx_variant = w_variant.

IF NOT p_variant IS INITIAL.


wx_variant-variant = p_variant.
ENDIF.

CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'


EXPORTING
i_save = w_variant_save
CHANGING
cs_variant = wx_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.

CASE sy-subrc.
WHEN 0.
p_variant = wx_variant-variant.
WHEN 2.
CLEAR: p_variant.
ENDCASE.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form variant_fill
*&---------------------------------------------------------------------*
FORM variant_fill.

CLEAR: w_variant.

IF p_vari IS INITIAL.
w_variant-variant = 'STANDARD'.
w_variant-report = w_repid.
ELSE.

w_variant-variant = p_vari.
w_variant-report = w_repid.

CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'


EXPORTING
i_save = w_variant_save
CHANGING
cs_variant = w_variant
EXCEPTIONS
OTHERS = 01.
IF sy-subrc NE 0.
MESSAGE e124(zi) WITH text-g02.
ENDIF.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form fieldcat_build
*&---------------------------------------------------------------------*
FORM fieldcat_build.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
i_program_name = w_repid
* i_structure_name = 'TRDIR'
i_internal_tabname = 'I_DATA'
i_inclname = w_repid
CHANGING
ct_fieldcat = i_fieldcat_alv.

* Modify displayed fields


* You can hide fields, change heading description, put hotspots etc in this step.
LOOP AT i_fieldcat_alv INTO w_fieldcat_alv.
CASE w_fieldcat_alv-fieldname.
WHEN 'VBELN'.
w_fieldcat_alv-hotspot = 'X'.

WHEN 'OIC_TRUCKN'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'OIC_PTRIP'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'OIGNRULE'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'MVGR2'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'VSTEL'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'KVGR2'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'VBELV'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'KVGR3'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'KVGR4'.
w_fieldcat_alv-no_out = 'X'.

WHEN 'KZWI1'.
w_fieldcat_alv-seltext_l = 'Gross Value'.
w_fieldcat_alv-no_out = 'X'.
WHEN 'OID_EXTBOL'.
w_fieldcat_alv-seltext_l = 'Gross Value'.
w_fieldcat_alv-no_out = 'X'.

WHEN OTHERS.
ENDCASE.

MODIFY i_fieldcat_alv FROM w_fieldcat_alv.


ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
FORM display_data.

w_callback_ucomm = 'CALLBACK_UCOMM'.

CASE 'X'.
WHEN p_grid.
IF p_html = 'X'.
w_html_top_of_page = 'HTML_TOP_OF_PAGE'.
ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
* i_background_id = 'SIWB_WALLPAPER'
i_background_id = 'SIWB_WALLPAPER'
i_callback_program = w_repid
i_callback_html_top_of_page = w_html_top_of_page
* i_structure_name = 'TRDIR'
i_default = 'X'
i_save = 'A'
is_variant = w_variant
is_layout = w_layout
i_callback_user_command = w_callback_ucomm
it_fieldcat = i_fieldcat_alv
it_events = i_events
it_event_exit = i_event_exit
it_excluding = i_excluding
is_print = w_print
* i_screen_start_column =1
* i_screen_start_line =1
* i_screen_end_column = 70
* i_screen_end_line = 30
TABLES
t_outtab = i_data.

WHEN p_list.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_callback_program = w_repid
i_default = 'X'
i_save = 'A'
is_variant = w_variant
is_layout = w_layout
i_callback_user_command = w_callback_ucomm
it_fieldcat = i_fieldcat_alv
it_events = i_events
it_event_exit = i_event_exit
is_print = w_print
TABLES
t_outtab = i_data.
ENDCASE.

ENDFORM.
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
FORM callback_ucomm USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

CASE r_ucomm.
WHEN '&IC1'.
*Interactive list. Replace with your Tcode and parameter id
SET PARAMETER ID 'VF' FIELD rs_selfield-value.
CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

WHEN OTHERS.
ENDCASE.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'


EXPORTING
text = text-pg1.

*Replace below logic with your report logic


REFRESH ivbrp.

REFRESH i_data.
CLEAR counter.

SELECT vbeln posnr fkimg meins prsdt fbuda netwr vbelv vgbel aubel
matnr arktx matkl werks lgort kondm mvgr2 vstel ktgrm vkgrp vkbur kvgr2
kvgr3 kvgr4 kzwi1 txjcd oid_extbol oic_truckn oic_ptrip oignrule FROM
vbrp INTO

CORRESPONDING FIELDS OF TABLE ivbrp

WHERE vbeln IN s_vbeln.

LOOP AT ivbrp.
MOVE: ivbrp-vbeln TO i_data-vbeln,
ivbrp-posnr TO i_data-posnr,
ivbrp-fkimg TO i_data-fkimg,
ivbrp-meins TO i_data-meins,
ivbrp-prsdt TO i_data-prsdt,
ivbrp-fbuda TO i_data-fbuda,
ivbrp-mvgr2 TO i_data-mvgr2,
ivbrp-vbelv TO i_data-vbelv,
ivbrp-vgbel TO i_data-vgbel,
ivbrp-aubel TO i_data-aubel,
ivbrp-matnr TO i_data-matnr,
ivbrp-arktx TO i_data-arktx,
ivbrp-matkl TO i_data-matkl,
ivbrp-mvgr2 TO i_data-mvgr2,
ivbrp-werks TO i_data-werks,
ivbrp-lgort TO i_data-lgort,
ivbrp-vstel TO i_data-vstel,
ivbrp-kondm TO i_data-kondm,
ivbrp-ktgrm TO i_data-ktgrm,
ivbrp-vkgrp TO i_data-vkgrp,
ivbrp-kzwi1 TO i_data-kzwi1,
ivbrp-kvgr2 TO i_data-kvgr2,
ivbrp-kvgr3 TO i_data-kvgr3,
ivbrp-kvgr4 TO i_data-kvgr4,
ivbrp-txjcd TO i_data-txjcd,
ivbrp-oid_extbol TO i_data-oid_extbol,
ivbrp-oignrule TO i_data-oignrule,
ivbrp-oic_ptrip TO i_data-oic_ptrip,
ivbrp-oic_truckn TO i_data-oic_truckn.

APPEND i_data.
counter = sy-tabix.
ENDLOOP.

ENDFORM.
*---------------------------------------------------------------------*
* FORM ALV_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM alv_top_of_page.

CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-key = ''.
w_list_comments-info = 'Material Valuation'. “Replace desc
APPEND w_list_comments TO i_list_comments.

w_list_comments-typ = 'A'. "H=Header, S=Selection, A=Action


w_list_comments-key = ''.
w_list_comments-info = sy-datum.
APPEND w_list_comments TO i_list_comments.

w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action


w_list_comments-key = ''.
w_list_comments-info = 'Begin of list'.
APPEND w_list_comments TO i_list_comments.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form event_build
*&---------------------------------------------------------------------*
FORM event_build.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'


EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.

READ TABLE i_events


WITH KEY name = slis_ev_top_of_page
INTO w_events.
IF sy-subrc = 0.
MOVE 'ALV_TOP_OF_PAGE' TO w_events-form.
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.

READ TABLE i_events


WITH KEY name = slis_ev_end_of_list
INTO w_events.
IF sy-subrc = 0.
MOVE 'ALV_END_OF_LIST' TO w_events-form.
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.

READ TABLE i_events


WITH KEY name = slis_ev_end_of_page
INTO w_events.
IF sy-subrc = 0.
MOVE 'ALV_END_OF_PAGE' TO w_events-form.
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.

ENDFORM.
*---------------------------------------------------------------------*
* FORM alv_end_of_list *
*---------------------------------------------------------------------*
FORM alv_end_of_list.

CLEAR: i_list_comments[].

w_list_comments-typ = 'A'. "H = Header, S = Selection, A = Action


w_list_comments-key = ''.
w_list_comments-info = 'End of list'.
APPEND w_list_comments TO i_list_comments.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'


EXPORTING
it_list_commentary = i_list_comments
i_logo = 'ZMYOBJECTKEY'
i_end_of_list_grid = 'X'.

ENDFORM.
*---------------------------------------------------------------------*
* FORM alv_end_of_page *
*---------------------------------------------------------------------*
FORM alv_end_of_page.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form print_build
*&---------------------------------------------------------------------*
FORM print_build.

w_print-no_print_listinfos = 'X'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
FORM layout_build.

w_layout-zebra = 'X'.
w_layout-no_vline = 'X'.
w_layout-colwidth_optimize = 'X'.
w_layout-detail_popup = 'X'.
w_layout-detail_initial_lines = 'X'.
w_layout-detail_titlebar = 'Detail Title Bar'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form event_exit_build
*&---------------------------------------------------------------------*
FORM event_exit_build.

CLEAR: i_event_exit[].

* Pick
w_event_exit-ucomm = '&ETA'.
w_event_exit-before = ' '.
w_event_exit-after = 'X'.
APPEND w_event_exit TO i_event_exit.

ENDFORM.
*---------------------------------------------------------------------*
* FORM HTML_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM html_top_of_page USING r_top TYPE REF TO cl_dd_document.

DATA:
text TYPE sdydo_text_element,
s_table TYPE REF TO cl_dd_table_element,
col_key TYPE REF TO cl_dd_area,
col_info TYPE REF TO cl_dd_area,
a_logo TYPE REF TO cl_dd_area.
* Split TOP-Document
CALL METHOD r_top->vertical_split
EXPORTING split_area = r_top
split_width = '99%'
IMPORTING right_area = a_logo.

* Fill TOP-Document
CALL METHOD r_top->add_text
EXPORTING text = 'Invoice Analysis: Line Item Details'
sap_style = 'HEADING'.

CALL METHOD r_top->new_line.


CALL METHOD r_top->new_line.
CALL METHOD r_top->add_table
EXPORTING no_of_columns = 2
with_heading = ' '
border = '1'
IMPORTING table = s_table.

CALL METHOD s_table->add_column IMPORTING column = col_key.


CALL METHOD s_table->add_column IMPORTING column = col_info.

text = 'Report Executed by'.


CALL METHOD col_key->add_text
EXPORTING text = text
sap_emphasis = 'Strong'.

CALL METHOD col_info->add_gap EXPORTING width = 6.

text = sy-uname. .
CALL METHOD col_info->add_text
EXPORTING text = text
sap_style = 'Key'.

**************************************************************
CALL METHOD s_table->new_row.

text = 'Report Executed on'.


CALL METHOD col_key->add_text
EXPORTING text = text
sap_emphasis = 'Strong'.

CALL METHOD col_info->add_gap EXPORTING width = 7.


DATA: year(4) TYPE c.
DATA: month(2) TYPE c.
DATA: date(2) TYPE c.

year = sy-datlo(4).
month = sy-datlo+4(2).
date = sy-datlo+6(2).

CONCATENATE month'/' date'/' year INTO erdat.

text = erdat.
CALL METHOD col_info->add_text EXPORTING text = text.
***************************************************************

CALL METHOD s_table->new_row.

text = 'Time' .
CALL METHOD col_key->add_text
EXPORTING text = text
sap_emphasis = 'Strong'.

CALL METHOD col_info->add_gap EXPORTING width = 6.


DATA: hour(2) TYPE c.
DATA: min(2) TYPE c.
DATA: sec(2) TYPE c.

hour = sy-timlo(2).
min = sy-timlo+2(2).
sec = sy-timlo+4(2).

CONCATENATE hour':' min ':' sec INTO time.

text = time .
CALL METHOD col_info->add_text
EXPORTING text = text
sap_style = 'Success'.
*************************************************************
CALL METHOD s_table->new_row.

text = 'No. of Records' .


CALL METHOD col_key->add_text
EXPORTING text = text
sap_emphasis = 'Strong'.

CALL METHOD col_info->add_gap EXPORTING width = 6.


text = counter.
CALL METHOD col_info->add_text EXPORTING text = text.
**************************************************************

CALL METHOD s_table->new_row.

CALL METHOD r_top->new_line.


text = 'Local date and time are shown above'.
CALL METHOD r_top->add_text
EXPORTING text = text
sap_emphasis = 'EMPHASIS'.
**************************************************************

CALL METHOD s_table->new_row.

CALL METHOD r_top->new_line.


text = 'Double-Click on the material number for material details'.
CALL METHOD r_top->add_text
EXPORTING text = text
sap_emphasis = 'EMPHASIS'.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form exclude_build
*&---------------------------------------------------------------------*
FORM exclude_build.

w_excluding = '&GRAPH'. "Graphic


APPEND w_excluding TO i_excluding.

ENDFORM. " exclude_build

Conclusion…
With the inclusion of ALV in version 4.5X and later, SAP has added a powerful and
extremely useful tool that is easy to learn and use. It helps you turn data into information
so you can be more effective. It lets you create information faster, on the fly, and without
tying up your organization’s IT resources.

Вам также может понравиться