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

ALV

Former Member
0 Likes
631

HI All,

Plz tell me what is the use of REUSE_ALV_VARIANT_DEFAULT_GET function module in ALV. And please tell me one simple example with using this function.

Thanks.

Pradip Pawar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
592

REUSE_ALV_VARIANT_DEFAULT_GET:

Purpose: Provides the default variant for the list specified in the structure

parameter CS_VARIANT of a program.

Function Call:

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = 'A'

CHANGING

CS_VARIANT = I_VARIANT

Parameters

I_SAVE :

Description :

Controls the storage mode

Prerequisite:

The IS_VARIANT parameter has the appropriate value.

Value range

' ' = display variants cannot be saved

Defined display variants (e.g. delivered display variants) can be

selected for presentation independently of this flag.

Changes cannot be saved.

'X' = standard save

Display variants can be saved as standard display variants.

User-specific saving is not possible.

'U' = only user-specific saving

The user can only save display variants user-specifically

'A' = standard and user-specific saving

The user can save a display variant user-specifically and

as standard display variant. The user chooses in the display variant

save popup.

CS_VARIANT:

Internal table containing the program name (and the default variant---optional )

*******************************************

Sample code :

CONSTANTS: c_yes(1) TYPE c VALUE 'X'.

...

DATA: e_variant TYPE disvariant.

...

PARAMETERS: p_vari LIKE disvariant-variant.

...

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

CLEAR e_variant.

e_variant-report = sy-cprog.

e_variant-username = sy-uname.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = c_yes

CHANGING

cs_variant = e_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = e_variant-variant.

ENDIF.

PERFORM f4_for_variant.

...

FORM f4_for_variant.

*

DATA: l_exit(1) TYPE c.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = e_variant

i_tabname_header = 'T_LISTADO'

  • i_tabname_item = ' '

  • IT_DEFAULT_FIELDCAT =

i_save = 'A'

IMPORTING

e_exit = l_exit

es_variant = e_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 l_exit = space.

p_vari = e_variant-variant.

ENDIF.

ENDIF.

*

ENDFORM. " f4_for_variant

This allows you to enter a display variant BEFORE running your ALV report. Then, your call to the ALV should look a little bit like this:

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

...

is_variant = e_variant

...

Regards

Vasu

4 REPLIES 4
Read only

Former Member
0 Likes
593

REUSE_ALV_VARIANT_DEFAULT_GET:

Purpose: Provides the default variant for the list specified in the structure

parameter CS_VARIANT of a program.

Function Call:

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = 'A'

CHANGING

CS_VARIANT = I_VARIANT

Parameters

I_SAVE :

Description :

Controls the storage mode

Prerequisite:

The IS_VARIANT parameter has the appropriate value.

Value range

' ' = display variants cannot be saved

Defined display variants (e.g. delivered display variants) can be

selected for presentation independently of this flag.

Changes cannot be saved.

'X' = standard save

Display variants can be saved as standard display variants.

User-specific saving is not possible.

'U' = only user-specific saving

The user can only save display variants user-specifically

'A' = standard and user-specific saving

The user can save a display variant user-specifically and

as standard display variant. The user chooses in the display variant

save popup.

CS_VARIANT:

Internal table containing the program name (and the default variant---optional )

*******************************************

Sample code :

CONSTANTS: c_yes(1) TYPE c VALUE 'X'.

...

DATA: e_variant TYPE disvariant.

...

PARAMETERS: p_vari LIKE disvariant-variant.

...

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

CLEAR e_variant.

e_variant-report = sy-cprog.

e_variant-username = sy-uname.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = c_yes

CHANGING

cs_variant = e_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_vari = e_variant-variant.

ENDIF.

PERFORM f4_for_variant.

...

FORM f4_for_variant.

*

DATA: l_exit(1) TYPE c.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = e_variant

i_tabname_header = 'T_LISTADO'

  • i_tabname_item = ' '

  • IT_DEFAULT_FIELDCAT =

i_save = 'A'

IMPORTING

e_exit = l_exit

es_variant = e_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 l_exit = space.

p_vari = e_variant-variant.

ENDIF.

ENDIF.

*

ENDFORM. " f4_for_variant

This allows you to enter a display variant BEFORE running your ALV report. Then, your call to the ALV should look a little bit like this:

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

...

is_variant = e_variant

...

Regards

Vasu

Read only

Former Member
0 Likes
592

When we are creting variant functinality for ALV reports and if user not selected any variant to get output this FM will call the default variant and report will be get disply with this variant

check for more details BCALV_GRID_09

Rewards if useful.....................

Minal

Read only

0 Likes
592

Hi Menal ,

Plz tell me what is the exactuse REUSE_ALV_VARIANT_DEFAULT_GET

In ALV. I do not understand its use. Actually I did this in my report by SDN help. I unable to execute it but not understand why we do this. Just I understand is that if I press F4 button it is showing whole output from database. And I saw one sample program by using this FM. In this FM the fieldcatalog is filled before the selection of data......how is it.

Willl you plz explain it in more detail........

Thanks .

Pradip Pawar

Message was edited by:

PRADIP PAWAR

Read only

Former Member
0 Likes
592

Hi pradip,

That function mod provides the default variant for the list specified in the structure parameter CS_VARIANT of a program.

Eg:

DATA: LV_VIEWNAME LIKE DD02L-TABNAME.

LV_INDX_KEY = 'K'.

LV_INDX_KEY+1 = 'V'.

IMPORT LV_TRVOG LV_ANZGR LT_SELTAB LV_TXT_PARVW LV_MATNR

FROM MEMORY ID LV_INDX_KEY.

IF ( NOT LV_TRVOG IS INITIAL ).

MOVE LV_TRVOG TO TRVOG.

MOVE LV_ANZGR TO ANZGR.

SELECT SINGLE * FROM T180V

WHERE RNAME = SY-REPID

AND TRVOG = TRVOG

AND ANZGR = ANZGR.

ASSIGN SPACE TO <FELD1>.

CHAR = 'POSTAB-'.

IF NOT T180V-VSORT IS INITIAL.

CHAR+7(10) = T180V-VSORT.

ELSE.

CHAR+7(10) = 'VBELN'.

ENDIF.

ASSIGN (CHAR) TO <FELD1>.

CASE T180V-SORTA.

WHEN 'A'.

SORT POSTAB BY <FELD1> ASCENDING VBELN DESCENDING

POSNR ASCENDING.

WHEN 'D'.

SORT POSTAB BY <FELD1> DESCENDING VBELN DESCENDING

POSNR ASCENDING.

ENDCASE.

CLEAR CHAR.

ENDIF.

PERFORM REUSE_ALV_VARIANT_FILL USING SY-REPID

TRVOG

SPACE

SY-UNAME

GS_SD_ALV-VARIANT.

LV_VIEWNAME = VIEWNAME.

PERFORM REUSE_ALV_FIELDCATALOG_MERGE USING GS_SD_ALV-FIELDCAT[]

LV_VIEWNAME

SPACE

SPACE.

PERFORM REUSE_ALV_VARIANT_DEFAULT USING GS_SD_ALV.