BC.I.001L - ALV Include Object Oriented - v1.20

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

Installation Guide

SPDC Component Library

Component BC.I.001L – ALV Include Object Oriented Version 1.20


Description Create an ALV report using Object Oriented Methods

Obligatory Requirements
SAP Version R/3 4.7 – 6.0 Hot Package N/A
These other components are used by this one and must be installed before it.
Dependent
Components N/A

Version Change Log


Version Modified in Author Modification
Improve – New option in AddField for Edit fields
Improve – New Form to Update Internal Table from
Screen Changes
1.20 16.Oct.2007 Roberto Matias
Improve – New Options in SET_ALV_LAYOUT
Improve – Hide HTML Header when not Value is
Added.
Improve – New option in AddField for Checkboxes
1.10 19.Sep.2007 Carolina Grazia
fields
1.00 30.Jul.2007 Maicon Rosa Component Creation

1. General Description
This component feature is to provide performs to be used in your program and help the creation of an
ALV Report Object Oriented without direct interaction with method. They will help you to define the fields, sort,
layout and the Header for the report.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

2. Installation Procedure

2.1. Technical Configuration


Not Applicable

2.2. Programs / Includes / Functions

2.2.1 – Create Include < ZATS_BCI001L_ALVOO >

Title : [ATS Library] – BC.I.001L – ALV OO Include


Code: See View..Navigation Panels..Attachments.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

3. User Guide

3.1. Component Configuration


To use the Example in Attachments (BC.I.001L – Example.txt) you must:
- Create the program
- Create a blank screen with number 0100
- Create a PBO module STATUS_0100 and a PAI module USER_COMMAND_0100.
- Open the module STATUS_0100 and create the PF-STATUS with the basic function BACK.

3.2. Utilization
First Step: You need to insert the command INCLUDE ZATS_BCI001L_ALVOO in your program.

Next you need to create a New Blank Screen (e.g. 9000). All objects in this screen will be created
dynamically.

In the start-of-selection of your program you need to follow these steps.


1- Select your Data and create the Result Table to be displayed.
2- Setup the Layout of your Report using SET_ALV_LAYOUT.
3- Define the Save Mode using SET_SAVE_MODE, if you want to allow the user to save variants in
ALV.
4- Define the Header of Report using ADD_ALV_HEADER, so many times as the lines that you need
on your Header Window.
5- Setup the Length of columns in Report using SET_ALV_LEN ONLY IF you want to set a value
different of field size.
6- Define the Columns of your report using ADD_FIELDCAT so many times as the columns that you
need.
7- Call SET_ALV_SORT if you want to pre-define some orders in your report.

In the New Blank Screen PBO you need to create a module and follow these steps:
1- Create a module to setup the PF-STATUS.
2- In this module (or in other specific PBO module) insert a call to UPDATE_ALV_PBO_MODULE. This
perform will create the dynamically objects in the first time and manage the refresh in next PBO
executions.

After configured the report you can use some additional function to help the program.
1- Use the function SET_STABLE_ROW_COL to keep the position of ALV Report (displayed column
and row) fixed after an Event. If you don’t use this perform and an Event is executed the report show
the row 1 and column 1.
2- Use the function GET_CURR_CELL to get information about actual selected cell.
3- If you are using Editable Fields you must insert a call to UPDATE_ITABLE_EDITMODE in your
USER_COMMAND Module.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

To understand the parameters of each perform above, please check this list:

3.2.1. SET_ALV_LAYOUT
Setup the Layout of ALV.

FORM set_alv_layout USING ZEBRA type lvc_s_layo-zebra


TITLE type lvc_s_layo-grid_title
STYLE type lvc_s_layo-ctab_fname.

ZEBRA: ‘X’ to turn on and ‘ ‘ to turn off the change of colors for each line.
TITLE: Title of Report ALV. This is not the Header of Screen.
STYLE: When you have a field in your table that will define the color characteristics of cells in
each line.

3.2.2. SET_EVENTS
Define the Save Mode, field I_SAVE in function REUSE_ALV_GRID_DISPLAY.
The Default Value for this parameter if this perform is not used is ‘A’.

FORM set_save_mode USING SAVE_MODE type char1.

SAVE_MODE:
' ' = Display variants cannot be saved
Defined display variants (such as delivered display variants) can be selected for presentation
regardless of this indicator. However, changes cannot be saved.

'X' = Standard save mode


Display variants can be saved as standard display variants. Saving display variants as user-
specific is not possible.

'U' = User-specific save mode


Display variants can only be saved as user-specific.

'A' = Standard and user-specific save mode


Display variants can be saved both as user-specific and as standard variants. Users make their
choice on the dialog box for saving the display variant.

3.2.3. ADD_ALV_HEADER
Include a new line in Header of Screen. This Header is displayed in a specific container that could
be resized by user.

FORM add_alv_header USING TYPE TYPE slis_listheader-typ


KEY TYPE slis_listheader-key
INFO TYPE slis_entry.

TYPE: ‘H’ to Header, ‘S’ to Selection and ‘A’ to Action.


KEY: Value of Left Text
INFO: Value of Right Text.

The values are displayed according the TYPE defined:


‘H’ – Header, is displayed at the top of window in bold letters, only parameter INFO is used. It
must be used for the Title of Report.
‘S’ – Selection, is displayed in next lines after Header, parameter KEY is displayed in bold and
INFO in normal text. It must be used to display categorized information as selection parameters
and they values
‘A’ – Action, is displayed in last lines of header, only parameter INFO is displayed. It must be
used to inform some action that user needs execute after report shown.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

3.2.4. SET_ALV_LEN
This is a simple way to define width of all columns in report.

FORM add_alv_header USING COLSIZE TYPE string.

COLSIZE: A string separated by semi-colon ( ; ) with the width of each columns in the same
sequence of columns of report. If you want that the width of columns respects the field size keep
its value blank, as the third column in example below.

e.g. perform add_alv_header using ’10;30;;100;20;’

3.2.5. ADD_FIELDCAT
Include a new column in report. It must be called using the sequence of columns that you want in
the report. During this perform the values defined in SET_ALV_LEN will be used and an internal table
declared in the include will be fulfilled with all FIELDCAT characteristics.

FORM add_fieldcat USING FIELD TYPE lvc_s_fcat-fieldname


TYPE TYPE lvc_s_fcat-ref_field
SIZE TYPE lvc_s_fcat-intlen
ALIGN TYPE lvc_s_fcat-just
SHOW TYPE c
TITLE TYPE lvc_s_fcat-coltext.

FIELD: Name of field in internal table. If this field was not found on RESULT_TABLE (See
UPDATE_ALV_PBO_MODULE) no column will be displayed.
TYPE: Type of field defined above. It is important because ALV will execute conversion and
summarization using this field. Common values are CHAR, NUMC, DATS and QUAN.
If you want to use a reference to a Database Field you must start the parameter with a ‘!’. E.g. ‘!
KNA1-KUNNR’.
SIZE: Internal Size of field. This is the max number of chars that will be displayed for this field.
ALIGN: Alignment of field in column. It can be ‘L’ – Left, ‘C’ – Center, ‘R’ – Right.
SHOW: Define how the column will be displayed. It can be one of the pre-defined constants:
C_SHOW - Display the Column.
C_HIDE - Insert the column in report but doesn’t display it.
C_NOZERO - Display the Column, but hide left-zeros of field.
C_FIXED - Display the Column and keep it fixed during scroll. It must be used on the
left columns.
C_ICON - Display the Column as an icon.
C_SUM - Display the Column and set it to be summarized.
C_AVG - Display the Column and set it to show the average.
TITLE: The text to be displayed in header of Column.

3.2.6. SET_ALV_SORT
This will define the pre-defined sort of report.

FORM set_alv_sort USING POS TYPE lvc_s_sort-spos


FIELD TYPE lvc_s_sort-fieldname
UP TYPE lvc_s_sort-up
SUBTOT TYPE lvc_s_sort-subtot.

POS: Indicates the position of field in the Order of Sort. This is not the Column Position in report.
FIELD: Setup which field must be sorted.
UP: ‘X’ for Ascending and ‘ ‘ for Descending.
SUBTOT: ‘X’ indicates that this field will create a sub-total line in report.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.
Installation Guide

3.2.7. UPDATE_ALV_PBO_MODULE
This form must be inserted in a PBO module in the New Blank Screen created.
It will create the dynamic object in the first execution and will update the report with changes
during the execution.

FORM update_alv_pbo_module USING RESULT_TABLE TYPE ANY TABLE


NUMBER TYPE i
REPID TYPE sy-repid
DYNNR TYPE sy-dynnr
HDSIZE TYPE i
VARIANT TYPE disvariant-variant.

RESULT_TABLE: The internal table with the values that must be displayed in report with the
columns defined with ADD_FIELDCAT.
NUMBER: Identifies which ALV we are using. You can use at max 2 ALV in the same program.
REPID: Variable type sy-repid with the name of your program.
DYNNR: Number of New Blank Screen created. These parameters are used combined to create
the dynamically containers.
HDSIZE: The height of Header of Report. It is necessary when a couple of lines are defined in
ADD_ALV_HEADER and you want that user could see all of them on start.
VARIANT: When you want that the report start displaying according a specific AVL Variant.

3.2.8. SET_STABLE_ROW_COL
This form will keep the scroll position of report after an Event, like a button pressed.
If you don’t use it the report, after screen refresh (PBO Event) will return to display first row and
first column,

FORM set_stable_row_col USING ROW TYPE char1


COL TYPE char1.

ROW: ‘X’ to keep the row fixed after an event.


COL: ‘X’ to keep the column fixed after an event.

3.2.9. GET_CURR_CELL
This form returns the actual position of cursor.

FORM get_curr_cell USING ROW TYPE sy-tabix


COL TYPE string.

ROW: Returns the line selected. This is the index (sy-tabix) of RESULT_TABLE passed to report.
COL: Return the name of field select. This is the name of field used in ADD_FIELDCAT.

3.2.10. UPDATE_ITABLE_EDITMODE
This form update internal table assigned with ALV with information updated in screen by user in
Edit Mode Fields.

FORM update_itable_editmode.

© 2007 Accenture – All Rights Reserved.


This component, containing its documentation and code, is proprietary of Accenture and its use and distribution is restrict.

You might also like