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

Layout variants

Former Member
0 Likes
454

Hi All,

How to create a layout variant which will display the list of all variants created by user? also layout parameter will show the default layout? I am creating field catalogue manually, will this affect the layout variant ?How to get F4 functionality for Layout variant?

Minal

2 REPLIES 2
Read only

Former Member
0 Likes
385

Hi Minal,

Refer to the code below

PARAMETERS: alv_def LIKE disvariant-variant.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR alv_def.

PERFORM layout.

FORM layout .

g_save = 'A'.

CLEAR g_variant.

g_variant-report = sy-repid.

gx_variant = g_variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = g_save

CHANGING

cs_variant = gx_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

alv_def = gx_variant-variant.

ENDIF.

  • Get values from the selection screen to determine layout set

wal_dynpfields-fieldname = 'ALV_DEF'.

APPEND wal_dynpfields TO tl_dynpfields.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-cprog

dynumb = '1000'

  • TRANSLATE_TO_UPPER = ' '

  • REQUEST = ' '

  • PERFORM_CONVERSION_EXITS = ' '

  • PERFORM_INPUT_CONVERSION = ' '

  • DETERMINE_LOOP_INDEX = ' '

TABLES

dynpfields = tl_dynpfields

  • EXCEPTIONS

  • INVALID_ABAPWORKAREA = 1

  • INVALID_DYNPROFIELD = 2

  • INVALID_DYNPRONAME = 3

  • INVALID_DYNPRONUMMER = 4

  • INVALID_REQUEST = 5

  • NO_FIELDDESCRIPTION = 6

  • INVALID_PARAMETER = 7

  • UNDEFIND_ERROR = 8

  • DOUBLE_CONVERSION = 9

  • STEPL_NOT_FOUND = 10

  • OTHERS = 11

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE tl_dynpfields INTO wal_dynpfields INDEX 1.

IF sy-subrc EQ 0.

g_variant-variant = wal_dynpfields-fieldvalue.

ENDIF.

g_variant-report = sy-repid.

g_variant-username = sy-uname.

**-- Display all existing variants

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = g_variant

i_save = g_save

IMPORTING

e_exit = g_exit

es_variant = gx_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.

alv_def = gx_variant-variant.

g_variant = gx_variant.

ELSE.

MESSAGE 'No layouts found' TYPE 'I'.

ENDIF.

ENDIF.

ENDFORM. " layout

Reward points if helpful.

Regards,

Pankaj Sharma

Read only

0 Likes
385

Hi Pankaj Sharma ,

Thanks for reply.

I try to applied your code but it is giving

Exception condition "INVALID_DYNPROFIELD" raised.

At.

Trigger Location of Runtime Error

Program SAPLSHL2

Include LSHL2U22

Row 249

Module type (FUNCTION)

Module Name DYNP_VALUES_READ

Please guide me regarding the same.

Regards ,

Minal