Application Development and Automation 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: 
Read only

Regarding ALV variant...

Former Member
0 Likes
1,985

Hi...

How to use variants in ALV?

Please tell me step by step,how to implent variants in ALV?

Regards

Sandeep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,210

hi sandeep,

Variants are used to save the data and retrieve the same when required. This is an option used in ALV.

SAP provides standard interfaces for initializing and retrieving the display variant information. This includes three function modules and four subroutines.

1. REUSE_ALV_VARIANT_DEFAULT_GET.

This FM is used to get the default variant for the report if it has been set.

EXPORTING

I_SAVE : Controls the storage mode. Allowed values are :

‘A‘ : Standard and user specific variants

‘U’ : User specific variants

‘X’ : Standard Variants

CHANGING

CS_VARIANT : Gets the default variant in a structure like DISVARIANT.

2. REUSE_ALV_VARIANT_F4

This FM is used to get the possible values of the variants on the selection screen.

EXPORTING

IS_VARIANT : Structure of this parameter is like DISVARIANT. Pass the program name through this.

I_SAVE : Controls type of variant to be displayed in value help. Allowed values are

‘A‘ Standard and user specific variants

‘U’ User specific variants

‘X’ Standard Variants

IMPORTING

E_EXIT : If this parameter is blank then user has selected some variant.

ES_VARIANT :

Selected variant is populated in this work area. It’s of structure like DISVARIANT.

3.REUSE_ALV_VARIANT_EXISTENCE

This FM is used to check existence of a

display variant.

EXPORTING

I_SAVE : Type of variant. Allowed values are

‘A‘ Standard and user specific variants

‘U’ User specific variants

‘X’ Standard Variants

CHANGING

CS_VARIANT : Pass on variant details. The structure of this field is like DISVARIANT.

 DATA AREAS TO BE DECLARED FOR VARIANTS :

Data, which will be, used by the standard function modules in ALV for variants. A sample data deceleration is as mentioned below.

DATA: WS_X_VARIANT LIKE DISVARIANT,

WS_VARIANT LIKE DISVARIANT,

WS_SAVE TYPE C,

WS_EXIT TYPE C,

WS_REPID LIKE SY-REPID.

REUSE_ALV_VARIANT_DEFAULT_GET

____________________________________________________

Text

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

Functionality

Provides the default variant for the list specified in the structure

parameter CS_VARIANT of a program.

REUSE_ALV_VARIANT_F4

____________________________________________________

Text

Display variant selection dialog box

Functionality

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.

REUSE_ALV_VARIANT_EXISTENCE

____________________________________________________

Text

Checks whether a display variant exists

CS_VARIENTS holds the information about varients like:

ABAP Program Name

Mgt. ID for repeated calls from the same program

Logical group name

User name for user-specific storage

Layout

Description for layout

Dependent variant entry vector

Functionality

This function module checks the existence in the database of a display

variant passed in the interface.

check this example in the below link

http://www.sap-img.com/abap/use-simple-alv-functions-to-make-reporting-easy.htm

**if useful don't forget to reward with points...**

Hi...

How to use variants in ALV?

Please tell me step by step,how to implent variants in ALV?

Regards

Sandeep.

3 REPLIES 3
Read only

Former Member
0 Likes
1,211

hi sandeep,

Variants are used to save the data and retrieve the same when required. This is an option used in ALV.

SAP provides standard interfaces for initializing and retrieving the display variant information. This includes three function modules and four subroutines.

1. REUSE_ALV_VARIANT_DEFAULT_GET.

This FM is used to get the default variant for the report if it has been set.

EXPORTING

I_SAVE : Controls the storage mode. Allowed values are :

‘A‘ : Standard and user specific variants

‘U’ : User specific variants

‘X’ : Standard Variants

CHANGING

CS_VARIANT : Gets the default variant in a structure like DISVARIANT.

2. REUSE_ALV_VARIANT_F4

This FM is used to get the possible values of the variants on the selection screen.

EXPORTING

IS_VARIANT : Structure of this parameter is like DISVARIANT. Pass the program name through this.

I_SAVE : Controls type of variant to be displayed in value help. Allowed values are

‘A‘ Standard and user specific variants

‘U’ User specific variants

‘X’ Standard Variants

IMPORTING

E_EXIT : If this parameter is blank then user has selected some variant.

ES_VARIANT :

Selected variant is populated in this work area. It’s of structure like DISVARIANT.

3.REUSE_ALV_VARIANT_EXISTENCE

This FM is used to check existence of a

display variant.

EXPORTING

I_SAVE : Type of variant. Allowed values are

‘A‘ Standard and user specific variants

‘U’ User specific variants

‘X’ Standard Variants

CHANGING

CS_VARIANT : Pass on variant details. The structure of this field is like DISVARIANT.

 DATA AREAS TO BE DECLARED FOR VARIANTS :

Data, which will be, used by the standard function modules in ALV for variants. A sample data deceleration is as mentioned below.

DATA: WS_X_VARIANT LIKE DISVARIANT,

WS_VARIANT LIKE DISVARIANT,

WS_SAVE TYPE C,

WS_EXIT TYPE C,

WS_REPID LIKE SY-REPID.

REUSE_ALV_VARIANT_DEFAULT_GET

____________________________________________________

Text

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

Functionality

Provides the default variant for the list specified in the structure

parameter CS_VARIANT of a program.

REUSE_ALV_VARIANT_F4

____________________________________________________

Text

Display variant selection dialog box

Functionality

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.

REUSE_ALV_VARIANT_EXISTENCE

____________________________________________________

Text

Checks whether a display variant exists

CS_VARIENTS holds the information about varients like:

ABAP Program Name

Mgt. ID for repeated calls from the same program

Logical group name

User name for user-specific storage

Layout

Description for layout

Dependent variant entry vector

Functionality

This function module checks the existence in the database of a display

variant passed in the interface.

check this example in the below link

http://www.sap-img.com/abap/use-simple-alv-functions-to-make-reporting-easy.htm

**if useful don't forget to reward with points...**

Read only

Former Member
0 Likes
1,210

Check this thread.

Read only

Former Member
0 Likes
1,210

hi,

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.

reward points if helpful,

shylaja