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: 

How to give range value and different value in headerof alv report

Former Member
0 Kudos

Hi All,

If User is giving range value 10 to 20 and also wants 25 28 30 and these all values should be displayed in Alv header.How is it possible.I have tried by using if variable-option eq 'BT'

elseif variable-option eq 'EQ'.then individually it is running fine but if user is giving both the option then differnt code is to be executed.

Can you please suggest me how it can be possible.

in header it should display as

Values: 10-20,25,28,30.

Edited by: RahulP5 on Dec 27, 2011 2:57 PM

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Rahul,

define the ALV grid for the maximum possible columns. Populate internal table as per selection requirements. Before displaying, set all empty columns to TECHNICAL = 'X'.

You may use this routine to do it as fast as possible:

*&---------------------------------------------------------------------*
*&      Form alv_fcat_tech_initial
*&---------------------------------------------------------------------*
*       mark initial columns as tech
*----------------------------------------------------------------------*
FORM alv_fcat_tech_initial
  USING    pt_list                        TYPE table
  CHANGING pt_fieldcat                    TYPE slis_t_fieldcat_alv.
  FIELD-SYMBOLS:
    <rec>                                 TYPE ANY,
    <fld>                                 TYPE ANY,
    <fcat>                                TYPE LINE OF slis_t_fieldcat_alv,
    <name>                                TYPE fieldname.
  DATA:
    lt_fieldname                          TYPE SORTED TABLE OF fieldname
      WITH UNIQUE KEY table_line.
* get fields
  LOOP AT pt_fieldcat ASSIGNING <fcat>.
    INSERT <fcat>-fieldname INTO TABLE lt_fieldname.
  ENDLOOP." at pt_fieldcat assigning <fcat>.
* scan table
  LOOP AT pt_list ASSIGNING <rec>.
    LOOP AT lt_fieldname ASSIGNING <name>.
      ASSIGN COMPONENT <name> OF STRUCTURE <rec> TO <fld>.
      CHECK NOT <fld> IS INITIAL.
      DELETE lt_fieldname.
    ENDLOOP." at lt_fieldname assigning <name>.
  ENDLOOP." at pt_list assigning <rec>.
  LOOP AT pt_fieldcat ASSIGNING <fcat>.
    READ TABLE lt_fieldname TRANSPORTING NO FIELDS
      WITH TABLE KEY table_line           = <fcat>-fieldname.
    CHECK sy-subrc                        = 0.
    <fcat>-tech                           = gc_true.
  ENDLOOP." at pt_fieldcat assigning <fcat>.
ENDFORM.                    "alv_fcat_tech_initial

Regards,

Clemens

6 REPLIES 6

Former Member
0 Kudos

I wouldn't do it that way. I'd put out a separate line for each row in the range along with the sign and option.

Rob

Clemenss
Active Contributor
0 Kudos

<processing error>

Clemenss
Active Contributor
0 Kudos

Hi Rahul,

define the ALV grid for the maximum possible columns. Populate internal table as per selection requirements. Before displaying, set all empty columns to TECHNICAL = 'X'.

You may use this routine to do it as fast as possible:

*&---------------------------------------------------------------------*
*&      Form alv_fcat_tech_initial
*&---------------------------------------------------------------------*
*       mark initial columns as tech
*----------------------------------------------------------------------*
FORM alv_fcat_tech_initial
  USING    pt_list                        TYPE table
  CHANGING pt_fieldcat                    TYPE slis_t_fieldcat_alv.
  FIELD-SYMBOLS:
    <rec>                                 TYPE ANY,
    <fld>                                 TYPE ANY,
    <fcat>                                TYPE LINE OF slis_t_fieldcat_alv,
    <name>                                TYPE fieldname.
  DATA:
    lt_fieldname                          TYPE SORTED TABLE OF fieldname
      WITH UNIQUE KEY table_line.
* get fields
  LOOP AT pt_fieldcat ASSIGNING <fcat>.
    INSERT <fcat>-fieldname INTO TABLE lt_fieldname.
  ENDLOOP." at pt_fieldcat assigning <fcat>.
* scan table
  LOOP AT pt_list ASSIGNING <rec>.
    LOOP AT lt_fieldname ASSIGNING <name>.
      ASSIGN COMPONENT <name> OF STRUCTURE <rec> TO <fld>.
      CHECK NOT <fld> IS INITIAL.
      DELETE lt_fieldname.
    ENDLOOP." at lt_fieldname assigning <name>.
  ENDLOOP." at pt_list assigning <rec>.
  LOOP AT pt_fieldcat ASSIGNING <fcat>.
    READ TABLE lt_fieldname TRANSPORTING NO FIELDS
      WITH TABLE KEY table_line           = <fcat>-fieldname.
    CHECK sy-subrc                        = 0.
    <fcat>-tech                           = gc_true.
  ENDLOOP." at pt_fieldcat assigning <fcat>.
ENDFORM.                    "alv_fcat_tech_initial

Regards,

Clemens

Former Member
0 Kudos

Hi , using dynamic internal table creation u can achieve this for this

see this sample example

DATA :GFINAL TYPE TABLE OF ANY .

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = FIELD_CATALOG

IMPORTING

EP_TABLE = GFINAL.

ASSIGN GFINAL->* TO <GFINAL>.

CREATE DATA WFINAL LIKE LINE OF <GFINAL>.

ASSIGN WFINAL->* TO <WFINAL>.

so create field catalog with type lvc_t_fcat and pass it to method create_dynamic_table , then u get the final internal table pass it to reuse_alv_grid_display

Regards

Siva

Former Member
0 Kudos

Dear Rahul,

As per my understanding, you need to display the values of a select-option from selection screen in TOP-OF-PAGE of an ALV.

if my understanding is correct then you should loop on your selection option and concatenate all the values in a string and display the string in TOP-OF-PAGE.

eg:


Loop at s_opt.
  if string is not initial.
    concatenate string ', ' into string.
  endif.
  concatenate string s_opt-low into string.
  if s_opt-high is not initial.
    concatenate string ' - ' s_opt-high into string.
  endif.
endloop.

use the string in your TOP-OF_PAGE.

Hope this helps

Regards,

Sachinkumar Mehta

Former Member
0 Kudos

Using class

DATA: lro_alv_grid TYPE REF TO cl_salv_form_layout_grid,

and looping we can get this.