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 - How to default variant change.

Former Member
0 Kudos

I have coded one report with ALV output.

I have /DEFAULT variant in my ALV output and the output contains 12 fields.

When I execute the this report

problem 1). How can i shift the 7th field to 12 th field and save as a new variant.

Problem 2).If I rerun this new variant, how can I keep new set of arranged fields of new variant in the new order( means 7th field in 12 th position ).

I mean in while re-running the program the fields are arranged in old manner ( 7 th field in 7th position only - my functional consultant told me ) .

Could you please help me ?

6 REPLIES 6

Former Member
0 Kudos

I have coded one report with ALV output.

I have "/DEFAULT" variant in my ALV output and the output contains 12 fields.

When I execute this report

problem 1). How can I shift the 7th field to 12 th field and save as a new default variant.

Problem 2).If I re-run this new variant, how can I keep new order of arranged fields of this new variant( means 7th field in 12 th position ).

Actually while re-running the program, the fields are arranging in old manner ( 7 th field in 7th position only ) .

Could you please help me ?

former_member186741
Active Contributor
0 Kudos

1.

a. click on the change layout button ctrl-f8

b.select the 7th field

c. click 'hide selected fields' button

d. select the newly hidden field on the right panel

e. select the destination on the left, the 11th column

f. click the 'show selected fields' button

2.

a. click the save layout button, ctrl-f10

b. enter a name and description, eg sams

c. hit enter

d. click the select layout button, ctrl-f9, you will now see layout 'sams' in addition to the /default one

Former Member
0 Kudos

Neil Woodruff ,

Thank you for your reply and is helpful!

My problem is

when I shifted the fields and save as a new variant layout - it is saving as per my order .

But when come back and rerun program with the new variant, this fields arrangement order was coming like older layout .

How can I avoid this ? PLEASE HELP ME.

Former Member
0 Kudos

Do I need to change my coding :

I am using

    • For field.( Z500_XMIT )

CLEAR lf_fieldcat.

lf_fieldcat-fieldname = 'KTEXT'.

lf_fieldcat-tabname = 'GT_ZGXMIT_L'.

lf_fieldcat-ref_tabname = 'CEPCT'.

lf_fieldcat-ref_fieldname = 'KTEXT'.

  • lf_fieldcat-reptext_ddic = '0500 Transmit'.

lh_index = lh_index + 1.

lf_fieldcat-col_pos = lh_index.

lf_fieldcat-no_sum = y_x.

lf_fieldcat-outputlen = '20'.

APPEND lf_fieldcat TO lt_fieldcat.

...

...

...

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "#EC *)

EXPORTING

i_callback_program = ws_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = v_alv_layout

it_fieldcat = lt_fieldcat

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

is_variant = g_variant

it_events = events[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

TABLES

t_outtab = gt_zgxmit_l

EXCEPTIONS

program_error = 1

OTHERS = 2.

.

IF sy-subrc <> 0.

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

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

ENDIF.

0 Kudos

are you sure that g_variant has got the correct value in it? Here's the components I use for programs that need the variant logic:

PARAMETERS: p_varint LIKE disvariant-variant.

*----


initialization.

perform alv_setup_layout_variant.

*----


AT SELECTION-SCREEN.

PERFORM alv_validate_layout_variant.

*----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varint.

PERFORM alv_f4_for_layout_variant.

*----


CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

...............etc

i_save = 'A'

is_variant = w_variant

............................etc

EXCEPTIONS

OTHERS = 0.

*----


FORM alv_setup_layout_variant .

DATA: lw_variant LIKE disvariant. " Layout structure

CLEAR w_variant.

w_variant-report = sy-repid.

w_save = 'A'.

  • Get default variant

lw_variant = w_variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = w_save

CHANGING

cs_variant = lw_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

p_varint = lw_variant-variant.

ENDIF.

ENDFORM. " alv_setup_layout_variant

FORM alv_validate_layout_variant.

DATA: lw_variant LIKE disvariant. " Layout structure

IF NOT p_varint IS INITIAL.

lw_variant = w_variant.

lw_variant-variant = p_varint.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

i_save = w_save

CHANGING

cs_variant = lw_variant.

w_variant = lw_variant.

ENDIF.

ENDFORM. " alv_validate_layout_variant

FORM alv_f4_for_layout_variant.

DATA: lw_variant LIKE disvariant.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = w_variant

i_save = w_save

  • it_default_fieldcat =

IMPORTING

e_exit = w_exit

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

  • Store returned variant

IF w_exit = space.

p_varint = lw_variant-variant.

ENDIF.

ENDIF.

ENDFORM. " alv_f4_for_layout_variant

Former Member
0 Kudos

Hi,

I am not sure this might work..

But try passing I_BYPASSING_BUFFER = 'X' to the ALV FM...

Thanks,

Naren