Skip to Content
author's profile photo Former Member
Former Member

ALV Variant

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 26, 2009 at 08:54 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 26, 2009 at 08:55 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 26, 2009 at 09:17 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.