Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV

Former Member
0 Kudos
296

Plz tell me the use of the following function modules..What is variant relate to this function modules.Can anyone give a simple example of this function modules.

reuse_alv_variant_default_get

reuse_alv_variant_existence

reuse_alv_variant_f4

1 ACCEPTED SOLUTION

Former Member
0 Kudos
165

Hi mahesh,

Check the below code.

&----


*& Form variant_init

&----


  • Initialize variant

----


FORM variant_init .

  • Set Options: save variants userspecific or general

g_save = 'A'.

g_report = sy-repid.

g_var-report = g_report.

  • Get default variant

g_variant = g_var.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = g_save

CHANGING

cs_variant = g_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = g_variant-variant.

ENDIF.

ENDFORM. " variant_init

&----


*& Form f4_for_variant

&----


  • F4 help for variant

----


FORM f4_for_variant .

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = g_var

i_save = g_save

IMPORTING

e_exit = g_exit

es_variant = g_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF g_exit = space.

p_vari = g_variant-variant.

ENDIF.

ENDIF.

ENDFORM. " f4_for_variant

&----


*& Form pai_of_selection_screen

&----


  • Check existence of Variant

----


FORM pai_of_selection_screen .

IF NOT p_vari IS INITIAL.

MOVE g_var TO g_variant.

MOVE p_vari TO g_variant-variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

i_save = g_save

CHANGING

cs_variant = g_variant.

g_var = g_variant.

ELSE.

PERFORM variant_init.

ENDIF.

ENDFORM. " pai_of_selection_screen

5 REPLIES 5

Former Member
0 Kudos
165

1. REUSE_ALV_VARIANT_DEFAULT_GET

Read default display variant (description only, w/o field catalog)

Provides the default variant for the list specified in the structure parameter CS_VARIANT of a program

2. REUSE_ALV_VARIANT_F4

Display variant selection dialog box

Possible entries help, if the variant is defined explicitly as an input field on a screen. The selection must be specified by at least partially filling the parameter structure IS_VARIANT.

3. REUSE_ALV_VARIANT_EXISTENCE

Checks whether a display variant exists

This function module checks the existence in the database of a display variant passed in the interface.

4. REUSE_ALV_EVENTS_GET

Returns table of possible events for a list type

This table can be passed to the ALV display module with the form name.

5. REUSE_ALV_COMMENTARY_WRITE

List body comment block output

List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.

This module outputs formatted simple header information at TOP-OF-PAGE.

Example

List <-- Type 'H'

Currency DEM Controlling area currency <-- Type 'S'

Material FGS_TEST Test material <-- Type 'S'

Action info <-- Type 'A'

-


Column headers

-


-


List

-


6. REUSE_ALV_FIELDCATALOG_MERGE

Create field catalog from dictionary structure or internal table

Supports the creation of the field catalog for the ALV function modules based either on a structure or table defined in the ABAP Data Dictionary, or a program-internal table.

The program-internal table must either be in a TOP Include or its Include must be specified explicitly in the interface.

The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:

Performance is affected since the code of the table definition must always be read and interpreted at runtime.

Dictionary references are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.

If the field catalog contains more than 90 fields, the first 90 fields are output in the list by default whereas the remaining fields are only available in the field selection.

If the field catalog is passed with values, they are merged with the 'automatically' found information.

7. REUSE_ALV_LIST_DISPLAY

Output a simple list (single line or several lines)

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 catalog as an internal table

The field catalog describes the fields to be output in the list.

All actions on the list refer directly to the internal output table, e.g. sorting the list also sorts the passed internal output table (passed by reference).

An important consideration for the use of the tools and certain generic functions (totals, subtotals) is the expected amount of data to be displayed.

The application must take this consideration into account.

8. REUSE_ALV_GRID_DISPLAY

Output of a simple list (single-line)

The function module outputs an internal table with whatever structure in the form of a formatted single- oder multi-line list.

Process:

Passing an internal table with the set of information to be output

Passing a structure with general layout specifications for list layout

Passing a field catalog in the form of an internal table

The field catalog describes the fields to be output in the list.

All interactions performed on the list refer directly to the internal output table. Sorting the list, for example, also involves a resorting of the internal output table passed (since it was passed by reference).

An important factor determining the usability of the tool or of various generic functions (totals, subtotals) is the expected amount of data to be displayed.

The application is responsible for critically testing this aspect and consider

9. REUSE_ALV_POPUP_TO_SELECT

List in dialog box to choose one or more entries (or display only)

Module for displaying or selecting table entries in internal tables in a popup (single or multiple selection is possible).

Principle:

pass an internal table with the superset of information to be output

pass list layout detail flags

pass a field catalog in the form of an internal table

The field catalog describes the fields to be output in the list.

Further information

The module uses the function module 'REUSE_ALV_LIST_DISPLAY' internally. The documentation of this module contains further information about the field catalog.

Reward if usefull

Edited by: Sravan Prakash.V on Jan 18, 2008 11:23 AM

Former Member
0 Kudos
166

Hi mahesh,

Check the below code.

&----


*& Form variant_init

&----


  • Initialize variant

----


FORM variant_init .

  • Set Options: save variants userspecific or general

g_save = 'A'.

g_report = sy-repid.

g_var-report = g_report.

  • Get default variant

g_variant = g_var.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = g_save

CHANGING

cs_variant = g_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = g_variant-variant.

ENDIF.

ENDFORM. " variant_init

&----


*& Form f4_for_variant

&----


  • F4 help for variant

----


FORM f4_for_variant .

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = g_var

i_save = g_save

IMPORTING

e_exit = g_exit

es_variant = g_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

IF g_exit = space.

p_vari = g_variant-variant.

ENDIF.

ENDIF.

ENDFORM. " f4_for_variant

&----


*& Form pai_of_selection_screen

&----


  • Check existence of Variant

----


FORM pai_of_selection_screen .

IF NOT p_vari IS INITIAL.

MOVE g_var TO g_variant.

MOVE p_vari TO g_variant-variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

i_save = g_save

CHANGING

cs_variant = g_variant.

g_var = g_variant.

ELSE.

PERFORM variant_init.

ENDIF.

ENDFORM. " pai_of_selection_screen

Former Member
0 Kudos
165

Hi,

by the name

reuse_alv_variant_default_get

getsa all the default variants for the report

reuse_alv_variant_existence

checks the exiastence of variant for the report

reuse_alv_variant_f4

displays possible variants for the report

regards

Former Member
0 Kudos
165

Create a new input parameter p_disvar like disvariant-variant.

In selection screen output set the default variant using

REUSE_ALV_VARIANT_DEFAULT_GET

Provide value request help using REUSE_ALV_VARIANT_F4

Set the display variant before calling ALV display using

REUSE_ALV_VARIANT_SELECT

Now the user can select the ALV variant on the selection screen. They can create new variants and save it. Next time they use the report, the can select the variant before executing the report, or in the report variant for background execution.

REUSE_ALV_VARIANT_EXISTENCE Checks whether a display variant exists

REUSE_ALV_VARIANT_F4 Display variant selection dialog box or To display all existing variants

Reward points if useful.

Former Member
0 Kudos
165

thanks