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 Variant

Former Member
0 Kudos

Hi All,

I'm developing a ALV report where in i've two radio buttons based on which the report output varies.

Now for each i've saved two variant.

I've a variant option also on my selection screen.

When 1st radio button is clicked in the F4 help it is showing both the variants which are saved. I need to show a variant related to the report output of the radio button.

Is there any way to differentiate, where in i can pass an extra field while saving the variant.

Please help

1 ACCEPTED SOLUTION

Former Member
0 Kudos

well actually the variant saves which radio button is checked, so you end up getting a snake here biting its own edge when trying to do what you plan.

No its not possible to differentiate while saving the variant.

4 REPLIES 4

Former Member
0 Kudos

well actually the variant saves which radio button is checked, so you end up getting a snake here biting its own edge when trying to do what you plan.

No its not possible to differentiate while saving the variant.

naveen_inuganti2
Active Contributor
0 Kudos

Hi,

We can't display the variants wrt user inputs on selection screen.

Here user should select the correct variant to run corresponding option, where we can maintain th eshort text also.

Thanks,

Naveen Inuganti.

Former Member
0 Kudos

Hi ,

I hope this ill help u

TABLES : sflight.

TYPE-POOLS : slis.

**INTERNAL TABLE DECLARTION

DATA : wa_sflight TYPE sflight,

it_sflight TYPE TABLE OF sflight.

**DATA DECLARTION

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid,

g_save TYPE c VALUE 'X',

g_variant TYPE disvariant,

gx_variant TYPE disvariant,

g_exit TYPE c,

ispfli TYPE TABLE OF spfli.

  • To understand the importance of the following parameter, click here.

**SELECTION SCREEN DETAILS

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002 .

PARAMETERS: variant LIKE disvariant-variant DEFAULT '/DEFAULT'..

SELECTION-SCREEN END OF BLOCK b1.

**GETTING DEFAULT VARIANT

INITIALIZATION.

gx_variant-report = sy-repid.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR variant.

DATA: ls_layout TYPE salv_s_layout_info,

ls_key TYPE salv_s_layout_key.

DATA :i_restrict TYPE salv_de_layout_restriction.

ls_key-report = sy-repid.

ls_layout = cl_salv_layout_service=>f4_layouts(

s_key = ls_key

restrict = i_restrict ).

variant = ls_layout-layout.

g_variant-report = ls_key-report.

g_variant-username = sy-uname.

g_variant-variant = variant.

**PERFORM DECLARATIONS

START-OF-SELECTION.

PERFORM data_retrivel.

PERFORM build_fieldcatalog.

PERFORM display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcatalog .

fieldcatalog-fieldname = 'CARRID'.

fieldcatalog-seltext_m = 'Airline Code'.

fieldcatalog-col_pos = 0.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'CONNID'.

fieldcatalog-seltext_m = 'Flight Connection Number'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'FLDATE'.

fieldcatalog-seltext_m = 'Flight date'.

fieldcatalog-col_pos = 2.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'PRICE'.

fieldcatalog-seltext_m = 'Airfare'.

fieldcatalog-col_pos = 3.

fieldcatalog-outputlen = 20.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form DISPLAY_ALV_REPORT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_report .

gd_repid = sy-repid.

BREAK-POINT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = fieldcatalog[]

i_save = 'X'

is_variant = g_variant

TABLES

t_outtab = it_sflight

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.

ENDFORM. "DISPLAY_ALV_REPORT

" DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIVEL

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_retrivel .

SELECT * FROM sflight INTO TABLE it_sflight.

ENDFORM. " DATA_RETRIVEL

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


FORM top-of-page.

*ALV Header declarations

DATA: t_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader,

t_line LIKE wa_header-info,

ld_lines TYPE i,

ld_linesc(10) TYPE c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'SFLIGHT Table Report'.

APPEND wa_header TO t_header.

CLEAR wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

APPEND wa_header TO t_header.

CLEAR: wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header.

ENDFORM. "TOP-OF-PAGE

0 Kudos

Its solved by passing the different handle values on saving the variant