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

ABAP LIST VIEWER

SHOBANA.C

SAMPLE ALV OUTPUT

2/21/2013

ABAP LIST VIEWER


To present the main technical functionalities of ALV.

2/21/2013

Function Modules used Parameter required to be passed Events to be passed Formatting Output as per need Simple Reports Hierarchical Reports
3

Function group : SALV


REUSE_ALV_COMMENTARY_WRITE comment block output REUSE_ALV_EVENTS_GET events for a list type List body

Returns table of possible

REUSE_ALV_EVENTS_TRANSFER
REUSE_ALV_EVENT_NAMES_GET Returns table of constant names of possible events for a list type

REUSE_ALV_FIELDCATALOG_MERGE Create field catalog from dictionary structure or internal table


REUSE_ALV_HIERSEQ_LIST_DISPLAY Hierarchical 2/21/2013 sequential list output
4

REUSE_ALV_LIST_DISPLAY list (single line or several lines)

Output a simple

REUSE_ALV_LIST_LAYOUT_INFO_GET Read current ALV list information REUSE_ALV_LIST_LAYOUT_INFO_SET Set current ALV list information

REUSE_ALV_VARIANT_DEFAULT_GET Read default display variant (description only, w/o field catalog)
REUSE_ALV_VARIANT_F4 selection dialog box Display variant

2/21/2013

Function group:SLVC_FULLSCREEN
REUSE_ALV_GRID_COMMENTARY_SET REUSE_ALV_GRID_DISPLAY Output of a simple list (single-line) REUSE_ALV_GRID_DISPLAY_LVC REUSE_ALV_GRID_LAYOUT_INFO_GET Read current ALV list information REUSE_ALV_GRID_LAYOUT_INFO_SET Set current ALV list information
2/21/2013 6

Function REUSE_ALV_LIST_DISPLAY

This module outputs an internal table with any structure as a formatted one-line or multiple-line list. PRINCIPLE:
Pass an internal table with the set of output information Pass a structure with general list layout details Pass a field catalogue as an internal table The field catalogue describes the fields to be output in the list.
7

2/21/2013

Exporting Parameters
1
2 3

I_INTERFACE_CHECK
I_BYPASSING_BUFFER I_BUFFER_ACTIVE

= ' '
= = ' '

4
5 6

I_CALLBACK_PROGRAM
I_CALLBACK_PF_STATUS_SET I_CALLBACK_USER_COMMAND

= ' '
= ' ' = ' '

7
8 9
2/21/2013

I_STRUCTURE_NAME
IS_LAYOUT IT_FIELDCAT

=
= =
8

10
11 12

IT_EXCLUDING
IT_SPECIAL_GROUPS IT_SORT

=
= =

13
14 15 16 17 18 19 20

IT_FILTER
IS_SEL_HIDE I_DEFAULT I_SAVE IS_VARIANT IT_EVENTS IT_EVENT_EXIT IS_PRINT

=
= = 'X' = ' ' = = = =
9

2/21/2013

21 22 23 24 25

IS_REPREP_ID I_SCREEN_START_COLUMN I_SCREEN_START_LINE I_SCREEN_END_COLUMN I_SCREEN_END_LINE

= = 0 = 0 = 0 = 0

2/21/2013

10

Import & Table parameters


IMPORTING E_EXIT_CAUSED_BY_CALLER ES_EXIT_CAUSED_BY_USER TABLES T_OUTTAB EXCEPTIONS PROGRAM_ERROR OTHERS
2/21/2013

= = =

= 1 = 2
11

Though the ALV function module needs 25-30 parameters to be passed, a simple report with ALV just requires these:
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_CALLBACK_PROGRAM TABLES T_OUTTAB EXCEPTIONS PROGRAM_ERROR OTHERS
2/21/2013

= ' '

= 1 = 2.
12

PARAMETERS TO BE PASSED TO THE STANDARD ALV FUNCTION MODULE

2/21/2013

13

I_CALLBACK_PROGRAM
Program which calls the function module and contains the exit routines. It must be a Report, Function group, Module pool or Form routine pool (not an Include).
Note: Never pass SY-REPID directly in the interface. If the desired program name is in SYREPID, it must be assigned to an intermediate variable which is then passed to the interface.
2/21/2013 14

IT_FIELCAT - Field catalog with field descriptions

The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the following function module REUSE_ALV_FIELDCATALOG_MERGE

2/21/2013

15

A field catalog need not be built-up and passed explicitly only under the following conditions: The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
All fields in this structure are to be output

The structure name is passed to ALV in the parameter I_STRUCTURE_NAME.


2/21/2013 16

Parameters to be passed

Positioning
row_pos (row position) value set: 0, 1 - 3 col_pos (column position) value set: 0, 1 60

Identification
fieldname (field name) tabname (internal output table)

2/21/2013

17

Data Dictionary reference


ref_fieldname (reference field name) ref_tabname (reference table/structure field name)

Link to currency unit


cfieldname (currency unit field name) ctabname (internal currency unit field output table)

Link to measurement unit


qfieldname (measurement unit field name) qtabname (internal measurement unit field output table)

2/21/2013

18

Column output options


outputlen (column width) key (key column) key_sel (hideable key column) no_out (field in field list) emphasize (highlight columns in color) value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on) hotspot (column as hotspot)

fix_column (fix column)


do_sum (sum over column)
2/21/2013

no_sum (sums forbidden)

19

Column output options (contd.)


input (column ready for input) icon

symbol Texts
just (justification) value set: SPACE, 'R', 'L', 'C' lzero (leading zeros) no_sign (no +/- sign ) no_zero (suppress zeros) edit_mask (field formatting) value set: SPACE, template

2/21/2013

20

Texts
The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. seltext_l (long field label) seltext_m (medium field label)

seltext_s (short field label)


reptext_ddic (header)

The specified text is not necessarily output in the list, an optimum among all texts is sought ddictxt (specify text) value set: SPACE, 'L', 'M', 'S'
2/21/2013 21

Parameters for program fields without Data Dictionary reference


datatype (data type ) value set: SPACE, Data Dictionary data type

ddic_outputlen (external output length) value set: 0 (initial), n


intlen (internal output length)value set: 0 (initial), n

rollname (data element) value set: SPACE, Data Dictionary data element name

2/21/2013

22

Priority rule:
Entries in the field catalog have priority over differing entries in the Data Dictionary.The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary

1 Fieldname

2 Outputlen

3 Datatype
5 seltext_m

4 seltext_s
6 seltext_l

If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes.
2/21/2013 23

Defaults : The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :

fieldname
ref_tabname ALV gets the remaining information from the Data Dictionary. If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog. REF_FIELDNAME need only be specified when the name of the internal table field differs from the name of the referred Data Dictionary field.

Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary. 2/21/2013 24

I_STRUCTURE_NAME

If the internal output table is defined via an ABAP/4 Dictionary structure (INCLUDE STRUCTURE struct or LIKE struct), the field catalog can be built-up automatically by passing the structure name.

2/21/2013

25

IS_LAYOUT -List layout specifications


The parameters are described under the following headers:

2/21/2013

Display options Totals Interaction Detail screen Display variants (only for hierarchical lists) Color Other
26

Display options

colwidth_optimize no_colhead zebra no_vline no_min_linesize max_linesize

2/21/2013

27

Exceptions

lights_fieldname value set: SPACE, internal


output table field name

lights_tabname value set: SPACE, internal


output table name

lights_rollname value set: SPACE, data


element name

lights_condense value set: SPACE, 'X'


2/21/2013 28

Totals
no_sumchoice value set: SPACE, 'X' no_totalline value set: SPACE, 'X' no_subchoice value set: SPACE, 'X' no_subtotals value set: SPACE, 'X' totals_only value set: SPACE, 'X' totals_text value set: SPACE, string(max.60) subtotals_text value set: SPACE, string(max.60) numc_sum value set: SPACE, 'X'
29

2/21/2013

Interaction

box_fieldname value set: SPACE, internal output table field name box_tabname value set: SPACE, internal output table name no_input value set: SPACE, 'X' expand_fieldname value set: SPACE, internal header table field name f2code value set: SPACE, function code
2/21/2013 30

Interaction (cont)

confirmation_prompt value set: SPACE, 'X' key_hotspot value set: SPACE, 'X' no_keyfix value set: SPACE, 'X' get_selinfos value set: SPACE, 'X'

2/21/2013

31

Detail screen

detail_popup value set: SPACE, 'X' detail_initial_lines value set: SPACE, 'X' detail_titlebar value set: SPACE, string(max.30)

2/21/2013

32

Display variants & color


header_text value set: SPACE, CHAR(20) item_text value set: SPACE, CHAR(20) item_default value set: SPACE, 'X' info_fieldname value set: SPACE, internal output table field name coltab_fieldname value set: SPACE, internal output table field name

2/21/2013

33

IT_SORT
The caller specifies the sorting and/or subtotalling of the basic list in the internal table IT_SORT. This internal table has the following fields
Spos Sort sequence Fieldname Internal output table field name Tabname Name of the internal output table Up 'X' = sort in ascending order Down 'X' = sort in descending order Subtot 'X' = subtotal at group value change group '* ' = new page at group value change 'UL' = underline at group value change

2/21/2013

34

IT_EVENTS This table tells ALV which events are processed by the caller by CALLBACK. The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET. You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.
2/21/2013 35

The table structure contains the fields:


IT_EVENTS-NAME-Name of the Callback event.
Action : USER_COMMAND

PF_STATUS_SET
ITEM_DATA_EXPAND List processing events :
TOP_OF_LIST

END_OF_LIST
END_OF_PAGE TOP_OF_PAGE TOP_OF_COVERPAGE

END_OF_COVERPAGE

IT_EVENTS-FORM - Name of the form routine which should be called in the calling program at the event.
2/21/2013 36

I_CALLBACK_USER_COMMAND
EXIT routine for command handling
Passing an EXIT routine tells ALV that the application wants to react to certain function codes itself. These are general function codes which ALV does not recognize (not ALV standard functions) and which were defined and set by an application status. FORM user_command USING r_ucomm LIKE syucomm rs_selfield TYPE slis_selfield. The parameter R_UCOMM contains the function code called.
2/21/2013 37

IT_EVENT_EXIT

Table for passing ALV standard function codes, to return control to the user before and/or after execution with the callback event USER_COMMAND. The table fields are as follows:
ucomm before after
2/21/2013 38

I_CALLBACK_PF_STATUS_ST
Passing an EXIT routine tells the ALV that the caller wants to set his or her own user status. In this case, the default ALV status is not set. The form routine interface must be defined as follows:
FORM set_pf_status USING rt_extab TYPE slis_t_extab

The table RT_EXTAB contains those function codes that are hidden on the standard interface.
2/21/2013 39

The structure RS_SELFIELD contains information: tabname : internal output table name tabindex : internal output table index fieldname: field name of cursor position sel_tab_field: cell name of cursor position (internal ALV table name field endsum : cursor is on the final total row sumindex : if >0, the cursor is on a subtotal row value : field value on the list refresh : (exporting) list is to be refreshed col_stable:(exporting) keep column positions in refresh row_stable:(exporting) keep row positions in refresh exit :(exporting) leave list (and ALV) before_action: jump before performing standard action 2/21/2013 after_action : jump after performing standard action,

40

IT_FILTER

Filter criteria for first list output Filter criteria which result, e.g. from explicitly loading an initial display variant, can be passed to list output in this parameter. This table should never be builtup 'manually'.
2/21/2013 41

I_DEFAULT

Initial variant logic active/inactive. Prerequisite: The parameter IS_VARIANT has the appropriate value Value Range SPACE = no initial variant can be defined 'X' = initial variant can be defined Default SPACE
2/21/2013 42

I_SAVE - variants can be saved

Value Range
' ' = display variants cannot be saved 'X' = standard save 'U' = only user-specific saving 'A' = standard and user-specific saving

2/21/2013

43

IS_VARIANT

This structure is only relevant if display variants are to be saved and/or read The access path must be specified in the fields
REPORT (required field), HANDLE (optional) unique user-assigned CHAR(4) field LOG_GROUP (optional)
2/21/2013 44

I_INTERFACE_CHECK
To avoid overloading list output with interface consistency checks, they are only made in an extra call mode. If this parameter is 'X', the consistency of the interface is checked when the function module is called, and an error log is output. This parameter should only be set for development test purposes (e.g. in debugging). The interface check can also be made on the results list by entering the function code &SOS.
2/21/2013 45

IS_PRINT
Print information Print control parameter

2/21/2013

PRINT NO_PRINT_SELINFOS NO_COVERPAGE NO_NEW_PAGE RESERVE_LINES END_OF_PAGE NO_PRINT_LISTINFOS NO_CHANGE_PRINT_PARAMS


46

SCREEN_SETTINGS

Coordinates for list in dialog box


Only to be used if the list is output in a popup. IT_SCREEN_START_COLUMN
x coordinate of the top left-hand corner of the popup.

IT_SCREEN_END_COLUMN
x coordinate of the bottom right-hand corner of the popup.

2/21/2013

47

SCREEN_SETTINGS (contd.)

Coordinates for list in dialog box


Only used if the list is output in a popup. IT_SCREEN_START_LINE
y coordinate of the top left-hand corner of the popup.

IT_SCREEN_END_LINE
y coordinate of the bottom right-hand corner of the popup.

2/21/2013

48

E_EXIT_CAUSED_BY_CALLER

Delete list in CALLBACK_USER_COMMAND


Parameter which states whether the caller left the list (SELFIELD-EXIT = 'X') in CALLBACK USER_COMMAND

2/21/2013

49

ES_EXIT_CAUSED_BY_USER
How the user left the list
If one of the ALV standard function codes for 'Back', 'Cancel' or 'Exit' occurs, the current list is discarded and the ALV function module ends. In this case the exporting structure ES_EXIT_CAUSED_BY_USER contains one of the following flags: ES_EXIT_CAUSED_BY_USER-BACK = 'X 'Back' occurred ES_EXIT_CAUSED_BY_USER-CANCEL = 'X' 'Cancel' occurred ES_EXIT_CAUSED_BY_USER-EXIT = 'X' 'Exit' occurred The function which occured determines the further navigation in the application. 2/21/2013 50

T_OUTTAB

Table with data to be displayed


This table can contain more fields than are relevant for the list output (display fields and field list). Only the fields named in field catalog and the layout structure are used for the list output. Other internal table fields are ignored. If the internal table is defined in the calling program without a header, no F1 help is possible in the list.
2/21/2013 51

REUSE_ALV_LIST_DISPLAY EXCEPTIONS Program errors


Exception type
If the exception is not handled by the calling program, the following applies: (X) an error message is sent. ( ) a termination message is sent. ( ) a runtime error occurs.

2/21/2013

52

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