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

selection parameter empty

Former Member
0 Likes
2,160

Hi,

I have the following situation:

I have in the report a selection parameter for layout. It is totally empty.

On my ALV output there is BUTTON select buuton. I can select here

some layouts wihich I have saved privously.

But why is the selection parameter empty ?

Regards

ertas

SELECTION-SCREEN SKIP.
PARAMETERS: pa_lv TYPE disvariant-variant.

wa_variant-report = sy-cprog.
  IF NOT pa_lv IS INITIAL.
    wa_variant-variant = pa_lv.
    save = 'A'.
  ENDIF.

CALL METHOD gr_alv->set_table_for_first_display
       EXPORTING
         i_structure_name              = 'ZITAB
         is_variant                    = wa_variant
         i_save                        = save
         i_default                     =  'X'
         is_layout                     = wa_layout
      CHANGING
        it_outtab                     =  it_li
        it_fieldcatalog               =  it_fcat

       EXCEPTIONS

         OTHERS                        = 4

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,620

Hi,

You have to populate the parameter value in the selection screen when executing the report. If you want to provide F4 help with the saved layouts add the below code in the report. when executing the report, if you click on F4 for that parameter you will be able to see the variant you have saved. You can choose that variant and run your ALV.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_LV.

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.

PA_LV = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

Thanks and Regards,

Lakshmi.

8 REPLIES 8
Read only

Former Member
0 Likes
1,620

default the selection parameter or assign some value in

initialization...

Read only

Former Member
0 Likes
1,621

Hi,

You have to populate the parameter value in the selection screen when executing the report. If you want to provide F4 help with the saved layouts add the below code in the report. when executing the report, if you click on F4 for that parameter you will be able to see the variant you have saved. You can choose that variant and run your ALV.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_LV.

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.

PA_LV = GX_VARIANT-VARIANT.

ENDIF.

ENDIF.

Thanks and Regards,

Lakshmi.

Read only

Former Member
0 Likes
1,620

Hi,

Please refer the code below:


PARAMETERS: sp_vari LIKE disvariant-variant.        "Dispaly Variant

* Data for ALV variant
DATA  gv_repname          LIKE sy-repid.
DATA  gv_x_variant        LIKE disvariant.
DATA  gv_exit(1)          TYPE c.
DATA  gv_save(1)          TYPE c.
DATA  gv_variant          LIKE disvariant.

INITIALIZATION.

  PERFORM f_initialize_variant.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR sp_vari.
  PERFORM f_f4_for_variant.

AT SELECTION-SCREEN.

*  Validating selection screen fields
  PERFORM f_at_selection_screen.


FORM f_initialize_variant .

  CLEAR gv_variant.
  gv_save           = 'X'.
  gv_variant-report = gv_repname.
  gv_x_variant      = gv_variant.

  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = gv_save
    CHANGING
      cs_variant = gv_x_variant
    EXCEPTIONS
      not_found  = 2.

  IF sy-subrc = 0.

    sp_vari = gv_x_variant-variant.

  ENDIF.

ENDFORM.                    " f_initialize_variant

FORM f_f4_for_variant .
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = gv_variant
      i_save     = gv_save
    IMPORTING
      e_exit     = gv_exit
      es_variant = gv_x_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 gv_exit = space.
      sp_vari = gv_x_variant-variant.
    ENDIF.
  ENDIF.

ENDFORM.                    " f_f4_for_variant

FORM f_at_selection_screen .

* ALV Layout variant
  IF NOT sp_vari IS INITIAL.

    MOVE gv_variant TO gv_x_variant.
    MOVE sp_vari    TO gv_x_variant-variant.

    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
      EXPORTING
        i_save     = gv_save
      CHANGING
        cs_variant = gv_x_variant.
    gv_variant = gv_x_variant.

  ELSE.

    PERFORM f_initialize_variant.

  ENDIF.

ENDFORM.                    " f_at_selection_screen

And pass 'A' to I_SAVE export parameters of ALV FM.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,620

Hi,

Try out the following code enhancing your exitsing code:

wa_variant-report = sy-cprog.

if no variant is selected, put a default variant

some default variants include(1SAP,1STANDARD)

try passing them directly in your code above instead of p_var

or :

IF NOT pa_lv IS INITIAL.

Call the FM : REUSE_ALV_VARIANT_F4

ENDIF.

Reward if useful..

Regards

Shiva

Read only

Former Member
0 Likes
1,620

hi all,

I get the message "No Layou found"

if I klick F4 in the selection screen .

Why ?

Regards

ilhan

Read only

0 Likes
1,620

Hi,

You need to execute the report and choose the columns and save the layout. Go back to the selection screen and press F4. You can see the saved layout.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,620

Sriram this exactly the problem,

I have saved some layouts in my output (ALV). I can't see them when I press F4 at the selection screen.

I always get the message "No Layout found".

Regards

ilhan

Read only

0 Likes
1,620

Hi,

Please refer the sample ALV FM. Make sure that to pass 'A' to I_SAVE export parameter.


    CALL METHOD go_grid1->set_table_for_first_display
      EXPORTING
        is_layout       = gs_layout
        is_print        = gs_print
        is_variant      = gs_variant                      
        i_save          = gv_save                           
        i_default       = gv_default                        
      CHANGING
        it_outtab       = gt_item_data
        it_fieldcatalog = gt_field_catalog.            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Thanks,

Sriram Ponna.

Edited by: Sriram Ponna on Apr 29, 2008 4:43 PM