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 display field value only once in REUSE_ALV_GRID_DISPLAY

Former Member
0 Kudos

hi experts,

i am using REUSE_ALV_GRID_DISPLAY, for alv outpur display.but i want one of the field in output ,not to display the value which is of same, it have to be displayed only once, I mean i have a number which contains multiple line items corresponding, here i want to display the field value only once when it is repeating , for the same header number, how can i achieve it

8 REPLIES 8

Former Member
0 Kudos

Hi,

check the sample code,

REPORT Z_ALV.

"----


  • Database table declaration

"----


TABLES:

sflight.

"----


  • Typepool declaration

"----


TYPE-POOLS:

slis.

"----


  • Selection screen elements

"----


SELECTION-SCREEN BEGIN OF BLOCK blk_1 WITH FRAME TITLE text-000.

SELECT-OPTIONS:

s_carrid FOR sflight-carrid.

SELECTION-SCREEN END OF BLOCK blk_1.

*"----


  • Field string to hold sflight data

*"----


DATA:

BEGIN OF fs_sflight ,

carrid TYPE sflight-carrid, " Carrier Id

connid TYPE sflight-connid, " Connection No

fldate TYPE sflight-fldate, " Flight date

seatsmax TYPE sflight-seatsmax, " Maximum seats

seatsocc TYPE sflight-seatsocc, " Occupied seats

END OF fs_sflight.

*"----


  • Internal table to hold sflight data

*"----


DATA:

t_sflight LIKE

STANDARD TABLE

OF fs_sflight .

"----


  • Work variables

"----


DATA:

t_fieldcat TYPE slis_t_fieldcat_alv,

fs_fieldcat LIKE

LINE OF t_fieldcat.

*"----


*START-OF-SELECTION

*"----


START-OF-SELECTION.

PERFORM get_data_sflight. " Getting data for display

PERFORM create_field_cat. " Create field catalog

PERFORM alv_display.

&----


*& Form create_field_cat

&----


  • Subroutine to create field catalog

----


  • There is no interface paramete

----


FORM create_field_cat .

PERFORM fill_fieldcat USING 'Carrier Id' 'CARRID' '2'.

PERFORM fill_fieldcat USING 'Connection No' 'CONNID' '1'.

PERFORM fill_fieldcat USING 'Flight Date' 'FLDATE' '3'.

PERFORM fill_fieldcat USING 'Maxm.Seats' 'SEATSMAX' '4'.

PERFORM fill_fieldcat USING 'Seats Occ' 'SEATSOCC' '5'.

ENDFORM. "create_field_cat

&----


*& Form fill_fieldcat

&----


  • Subroutine to fill data to field column

----


  • -->p_seltext Column label

  • -->p_fieldname Fieldname of database table

  • -->p_col_pos Column position

----


FORM fill_fieldcat USING

p_seltext LIKE fs_fieldcat-seltext_m

p_fieldname LIKE fs_fieldcat-fieldname

p_col_pos LIKE fs_fieldcat-col_pos.

fs_fieldcat-seltext_m = p_seltext.

fs_fieldcat-fieldname = p_fieldname.

fs_fieldcat-col_pos = p_col_pos.

APPEND fs_fieldcat TO t_fieldcat.

CLEAR fs_fieldcat.

ENDFORM. " fill_fieldcat

&----


*& Form get_data_sflight

&----


  • Subroutine to fetch data from database table

----


  • There is no interface parameter

----


FORM get_data_sflight .

SELECT carrid

connid

fldate

seatsmax

seatsocc

FROM sflight

INTO TABLE t_sflight

WHERE carrid IN s_carrid.

ENDFORM. " get_data_sflight

&----


*& Form alv_display

&----


  • Subroutine for ALV display

----


  • There is no interface parameter

----


FORM alv_display .

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = t_fieldcat

TABLES

t_outtab = t_sflight

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " alv_display

"----


  • End of code

krishnendu_laha
Active Contributor
0 Kudos

Hi Friend,

Sort the column, you will not get repeative value.

Field the internal table with sort fileld name and sort type;

Pass to IT_SORT parameter of REUSE_ALV..function module.

Hope your problem will solve.

Regards

Krishnendu

0 Kudos

thank u for ur reply,

but i have sorted it with another field, for that field we get the required field values to be displayed once same in multiple rows, that have to be also diaplyed once only, i achieved before field in gwetting once , but i could not get the second field value once.

0 Kudos

Just include my coding in your existing isort . You may have to change the spos = 2 in this case.

Append another one time your second field in isort and check . After that if it wont work let us know.

0 Kudos

hi friends,

i have done it but i am not able to display once the repeating value

0 Kudos

may be you are doing some mistake in that..

You have to use the sort table.Populate it properly.

and also refer the sample program

BALVST02_GRID

Former Member
0 Kudos

data : isort type slis_t_sortinfo_alv,

wsort type slis_sortinfo_alv.

wsort-spos = 1.

wsort-fieldname = 'YOUR FNAME IN CAPS'.

wsort-up = 'X'.

wsort-group = 'UL'.

append wsort to isort.

now pass isort into REUSE_ALV_GRID_DISPLAY fn modules I_SORT = isort.

It may be useful.

Former Member
0 Kudos

hi,

u can use delete duplicate entries to get the text displsyed only once.

regards,

sri.