Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Layout

Hi,

I have an ALV. In this ALV I allow save layout.

The problem is when I try load a layout. When I clik in the matchcode, It doesn´t show any layout to load. (Several layouts exist).

What happens ???

Thanks

Tags:
replied

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

PARAMETERS P_LAYOUT TYPE DISVARIANT-VARIANT.

SELECTION-SCREEN END OF BLOCK B3.

INITIALIZATION.

*--Initialize

  • Initialize to default layout if one exist.

WA_VARIANT-REPORT = SY-REPID.

WA_VARIANT-USERNAME = SY-UNAME.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

I_SAVE = C_ALL

CHANGING

CS_VARIANT = WA_VARIANT

EXCEPTIONS

WRONG_INPUT = 1

NOT_FOUND = 2

PROGRAM_ERROR = 3

OTHERS = 4.

IF SY-SUBRC = 0.

P_LAYOUT = WA_VARIANT-VARIANT.

ENDIF.

*-- On value request for varaint

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LAYOUT.

DATA: TL_DYNPFIELDS TYPE TABLE OF DYNPREAD,

WL_EXIT TYPE C,

WAL_VARIANT LIKE WA_VARIANT,

WAL_DYNPFIELDS TYPE DYNPREAD.

  • Get values from the selection screen to determine layout set

WAL_DYNPFIELDS-FIELDNAME = 'P_LAYOUT'.

APPEND WAL_DYNPFIELDS TO TL_DYNPFIELDS.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = SY-CPROG

DYNUMB = '1000'

TRANSLATE_TO_UPPER = C_CHECK

TABLES

DYNPFIELDS = TL_DYNPFIELDS.

  • Get the variant (we have only 1 entry)

READ TABLE TL_DYNPFIELDS INTO WAL_DYNPFIELDS INDEX 1.

IF SY-SUBRC EQ 0.

WA_VARIANT-VARIANT = WAL_DYNPFIELDS-FIELDVALUE.

ENDIF.

WA_VARIANT-REPORT = SY-REPID.

WA_VARIANT-USERNAME = SY-UNAME.

  • Invoke function to provide drop down entries

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = WA_VARIANT

I_SAVE = C_ALL

IMPORTING

E_EXIT = WL_EXIT

ES_VARIANT = WAL_VARIANT

EXCEPTIONS

NOT_FOUND = 1

PROGRAM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC IS INITIAL.

IF WL_EXIT IS INITIAL.

P_LAYOUT = WAL_VARIANT-VARIANT.

WA_VARIANT = WAL_VARIANT.

ENDIF.

ELSE.

MESSAGE I208(00) WITH 'No layouts found'(022).

ENDIF.

FREE: TL_DYNPFIELDS.

http://sap.ittoolbox.com/code/archives.asp?a=s&d=3619

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question