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 - Selection Screen - How To Add Layout Option

Former Member
0 Kudos
2,103

On the selection screen of an ALV program, how can we add option for selecting the Layout & no. of hits to be shown box (Normally, can be accessed only after running after running the report).

1 ACCEPTED SOLUTION

Former Member
0 Kudos
751

Use following code :

PARAMETERS: pa_vari TYPE slis_vari.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
  PERFORM alv_variant_f4 CHANGING pa_vari.


FORM alv_variant_f4 CHANGING pa_vari.
  DATA: rs_variant LIKE disvariant.
  DATA nof4 TYPE c.

  CLEAR nof4.
  LOOP AT SCREEN.
    IF screen-name = 'PA_VARI'.
      IF screen-input = 0.
        nof4 = 'X'.
      ENDIF.
    ENDIF.
  ENDLOOP.

  rs_variant-report   = g_repid.
  rs_variant-username = sy-uname.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = rs_variant
      i_save     = 'A'
    IMPORTING
      es_variant = rs_variant
    EXCEPTIONS
      OTHERS     = 1.
  IF sy-subrc = 0 AND nof4 EQ space.
    pa_vari = rs_variant-variant.
  ENDIF.
ENDFORM.                               " ALV_VARIANT_F4

7 REPLIES 7

Former Member
0 Kudos
751

For selecting the layout, add following line to your program.

parameters: p_vari type slis_vari. use the function REUSE_ALV_VARIANT_F4 to get the list of variants for the report.

No of hits can be displayed using 'TOP-OF-PAGE" in the alv grid display.

Regards

Vinod

Former Member
0 Kudos
751

Use this function module.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

Regards

Prajwal.

Former Member
0 Kudos
752

Use following code :

PARAMETERS: pa_vari TYPE slis_vari.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
  PERFORM alv_variant_f4 CHANGING pa_vari.


FORM alv_variant_f4 CHANGING pa_vari.
  DATA: rs_variant LIKE disvariant.
  DATA nof4 TYPE c.

  CLEAR nof4.
  LOOP AT SCREEN.
    IF screen-name = 'PA_VARI'.
      IF screen-input = 0.
        nof4 = 'X'.
      ENDIF.
    ENDIF.
  ENDLOOP.

  rs_variant-report   = g_repid.
  rs_variant-username = sy-uname.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = rs_variant
      i_save     = 'A'
    IMPORTING
      es_variant = rs_variant
    EXCEPTIONS
      OTHERS     = 1.
  IF sy-subrc = 0 AND nof4 EQ space.
    pa_vari = rs_variant-variant.
  ENDIF.
ENDFORM.                               " ALV_VARIANT_F4

0 Kudos
751

Thank you for your prompt & indepth reply. Everything is fine, the PA_VARI input box has come up thats it. But no f4 help is available. pls help.

0 Kudos
751

You need to Create the Layouts once the output is displayed, Next Time when you execute the program, earlier created layouts will be available in the F4 help for this field.

0 Kudos
751

Create the custom layout after you execute the report, Then it will appear in the F4 list from the next time you execute the report.

Regards

Vinod

0 Kudos
751

Thank you very much .