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: 

showing the selection criteria

Former Member
0 Kudos
125

i want to show the selection criteria made by the user at the top_of_page event of the ALV report. how to do so?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
68

Hi,

Plz try with the hep of below code. In gt_comment we can show the selection screen parameters.

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_REPORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_report .

***** Fieldcatalogue Definition for ALV Report *****

******Fieldcat for 1st List*****************
  CLEAR  gs_fieldcat1.
  REFRESH gt_fieldcat1.

gs_fieldcat1-fieldname = 'RICON'.
  gs_fieldcat1-ref_tabname = 'GT_REPORT'.
  gs_fieldcat1-seltext_m   = text-025.
  APPEND gs_fieldcat1 TO gt_fieldcat1.
  CLEAR  gs_fieldcat1.
.
.
..
.
.
  gs_comment-typ = 'S'.
  gs_comment-key = text-055.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-050.
  gs_comment-info = variant.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-051.
  gs_comment-info = p_actgrp.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-052.
  gs_comment-info = p_pe.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-053.
  gs_comment-info = p_year.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  IF p_tstrun <> 'X'.
    gs_comment-typ = 'S'.
    gs_comment-key = text-056.
    gs_comment-info = 'OFF'.

    APPEND gs_comment TO gt_comment.
    CLEAR gs_comment.
  ELSE.
    gs_comment-typ = 'S'.
    gs_comment-key = text-056.
    gs_comment-info = 'ON'.

    APPEND gs_comment TO gt_comment.
    CLEAR gs_comment.
  ENDIF.

  gs_events-name = 'TOP_OF_PAGE'.
  gs_events-form = 'TOPOFPAGE'.

  APPEND gs_events TO gt_events.
  CLEAR gs_events.
***********************Display ALV Report in Grid Format**************************

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-cprog
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
            .
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = gs_layout
      it_fieldcat                      = gt_fieldcat1[]
      i_tabname                        = 'GT_REPORT'
      it_events                        = gt_events[]
*   IT_SORT                          =
     i_text                           = 'Error Message'
    TABLES
      t_outtab                         = gt_report
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3
            .
  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_REPORT

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       Display Header.
*----------------------------------------------------------------------*
FORM topofpage.

  count = count + 1.
  IF count LE 1.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary = gt_comment.
  ENDIF.

ENDFORM.                    " TOP_OF_PAGE

Hope this helps.

thanx,

dhanashri.

Edited by: Dhanashri Pawar on Aug 11, 2008 11:58 AM

Edited by: Dhanashri Pawar on Aug 11, 2008 12:04 PM

6 REPLIES 6

Former Member
0 Kudos
69

Hi,

Plz try with the hep of below code. In gt_comment we can show the selection screen parameters.

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_REPORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_report .

***** Fieldcatalogue Definition for ALV Report *****

******Fieldcat for 1st List*****************
  CLEAR  gs_fieldcat1.
  REFRESH gt_fieldcat1.

gs_fieldcat1-fieldname = 'RICON'.
  gs_fieldcat1-ref_tabname = 'GT_REPORT'.
  gs_fieldcat1-seltext_m   = text-025.
  APPEND gs_fieldcat1 TO gt_fieldcat1.
  CLEAR  gs_fieldcat1.
.
.
..
.
.
  gs_comment-typ = 'S'.
  gs_comment-key = text-055.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-050.
  gs_comment-info = variant.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-051.
  gs_comment-info = p_actgrp.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-052.
  gs_comment-info = p_pe.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  gs_comment-typ = 'S'.
  gs_comment-key = text-053.
  gs_comment-info = p_year.

  APPEND gs_comment TO gt_comment.
  CLEAR gs_comment.

  IF p_tstrun <> 'X'.
    gs_comment-typ = 'S'.
    gs_comment-key = text-056.
    gs_comment-info = 'OFF'.

    APPEND gs_comment TO gt_comment.
    CLEAR gs_comment.
  ELSE.
    gs_comment-typ = 'S'.
    gs_comment-key = text-056.
    gs_comment-info = 'ON'.

    APPEND gs_comment TO gt_comment.
    CLEAR gs_comment.
  ENDIF.

  gs_events-name = 'TOP_OF_PAGE'.
  gs_events-form = 'TOPOFPAGE'.

  APPEND gs_events TO gt_events.
  CLEAR gs_events.
***********************Display ALV Report in Grid Format**************************

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program             = sy-cprog
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
            .
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = gs_layout
      it_fieldcat                      = gt_fieldcat1[]
      i_tabname                        = 'GT_REPORT'
      it_events                        = gt_events[]
*   IT_SORT                          =
     i_text                           = 'Error Message'
    TABLES
      t_outtab                         = gt_report
   EXCEPTIONS
     program_error                    = 1
     maximum_of_appends_reached       = 2
     OTHERS                           = 3
            .
  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_REPORT

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       Display Header.
*----------------------------------------------------------------------*
FORM topofpage.

  count = count + 1.
  IF count LE 1.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        it_list_commentary = gt_comment.
  ENDIF.

ENDFORM.                    " TOP_OF_PAGE

Hope this helps.

thanx,

dhanashri.

Edited by: Dhanashri Pawar on Aug 11, 2008 11:58 AM

Edited by: Dhanashri Pawar on Aug 11, 2008 12:04 PM

Former Member
0 Kudos
68

Hi,

Take screen-shot of the selection screen and Upload it as a LOGO in the ALV TOP-OF-PAGE event.

Regards,

Rama.

Former Member
0 Kudos
68

Hi,

Take screen-shot of the selection screen and Upload it as a LOGO in the ALV TOP-OF-PAGE event.

Regards,

Rama.

Former Member
0 Kudos
68

try PRINT_SELECTIONS in the top-of-page event of the ALV (only if its classic ALV).

former_member188685
Active Contributor
0 Kudos
68

You can do some thing like this ,

Use the Function RS_REFRESH_FROM_SELECTOPTIONS get the selection details, now format the data accordingly in the TOP_OF_PAGE using the calss CL_DD_DOCUMENT.

Check the below mention code.

REPORT  ztest_page.

TABLES: sflight.
DATA : it_flight TYPE TABLE OF sflight WITH HEADER LINE.
DATA BEGIN OF it_sel_opt OCCURS 0.
        INCLUDE STRUCTURE rsparams.
DATA END   OF it_sel_opt.
SELECT-OPTIONS: s_carrid FOR sflight-carrid.

START-OF-SELECTION.

  SELECT * FROM sflight INTO TABLE it_flight
   WHERE carrid IN s_carrid.

END-OF-SELECTION.

  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
      curr_report     = sy-repid
    TABLES
      selection_table = it_sel_opt
    EXCEPTIONS
      not_found       = 01
      no_report       = 02.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program          = sy-repid
      i_callback_html_top_of_page = 'TOP_OF_PAGE'
      i_structure_name            = 'SFLIGHT'
    TABLES
      t_outtab                    = it_flight
    EXCEPTIONS
      program_error               = 1
      OTHERS                      = 2.

*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->DOCUMENT   text
*----------------------------------------------------------------------*
FORM top_of_page USING document TYPE REF TO cl_dd_document.
  DATA : dl_text(255) TYPE c.  "Text

* Add new-line
  CALL METHOD document->new_line.

  CALL METHOD document->new_line.

  CLEAR : dl_text.
* program ID
  dl_text = 'Program Name :'.
  CALL METHOD document->add_gap.
  CALL METHOD document->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_heading_int.

  CLEAR dl_text.
  dl_text = sy-repid.
  CALL METHOD document->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD document->new_line.
  CLEAR : dl_text.

  dl_text = 'Selection Criteria'.
  CALL METHOD document->add_gap
    EXPORTING
      width = 34.
  CALL METHOD document->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD document->new_line.

  CLEAR : dl_text.
  CONCATENATE 'SELECT Option' 'SIGN' 'OPTION' 'LOW' 'HIGH'
  INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

  CALL METHOD document->add_gap
    EXPORTING
      width = 34.
  CALL METHOD document->add_text
    EXPORTING
      text         = dl_text
      sap_emphasis = cl_dd_area=>heading
      sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
  CALL METHOD document->new_line.
  LOOP AT it_sel_opt.

    CLEAR : dl_text.
    CONCATENATE it_sel_opt-selname  it_sel_opt-sign
     it_sel_opt-option it_sel_opt-low it_sel_opt-high
    INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

    CALL METHOD document->add_gap
      EXPORTING
        width = 34.
    CALL METHOD document->add_text
      EXPORTING
        text         = dl_text
        sap_emphasis = cl_dd_area=>heading
        sap_color    = cl_dd_area=>list_negative_inv.

* Add new-line
    CALL METHOD document->new_line.

  ENDLOOP.

ENDFORM.                    "top_of_page

Former Member
0 Kudos
68

hi,


DATA: gt_events TYPE slis_t_event,
      gt_list_top_of_page TYPE slis_t_listheader.

CONSTANTS g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.    "name of the subroutine to be executed (TOP_OF_PAGE)

PERFORM fieldcat_build.
    PERFORM eventtab_build USING gt_events[].
    PERFORM comment_build USING gt_list_top_of_page[].
    PERFORM display_alv_report.

-------------------------------------------------------------------------------------------
FORM fieldcat_build.
...
ENDFORM.

FORM eventtab_build USING rt_events TYPE slis_t_event.

*Registration of events to happen during list display
  DATA ls_event TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = rt_events.
  READ TABLE rt_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
  IF sy-subrc = 0.
    MOVE g_top_of_page TO ls_event-form.
    APPEND ls_event TO rt_events.
  ENDIF.

ENDFORM.                    "eventtab_build


FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.

  DATA: ls_line TYPE slis_listheader,
        rp_date TYPE string.              "report date

*List heading line - type 'H'
  CLEAR ls_line.
  ls_line-typ  = 'H'.
* LS_LINE-KEY:  NOT USED FOR THIS TYPE
  ls_line-info = text-002.
  APPEND ls_line TO lt_top_of_page.

*Convert date to required format
  CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum(4) INTO rp_date SEPARATED BY '.'.

*status line - type 'S'
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = text-003.
  ls_line-info = rp_date.
  APPEND ls_line TO lt_top_of_page.

ENDFORM.                    "comment_build


FORM top_of_page.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gt_list_top_of_page.

ENDFORM.                    "top_of_page


FORM display_alv_report.

  gd_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      it_fieldcat_lvc    = it_fieldcat[]
      it_events          = gt_events[]
    TABLES
      t_outtab           = it_employee_details
    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

"FORM comment_build" is used to enter the text that needs to be displayed on top of page. replace "text-002" and "text-003" with data that u want to display on top of page.

in the FM REUSE_ALV_GRID_DISPLAY_LVC it is inportant to pass value for "it_events" parameter.