Application Development and Automation 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: 
Read only

alv columns

Former Member
0 Likes
598

hi i hav a simple alv which contains five columns

i want to show only three columns

how to do this?

hi i hav a simple alv which contains five columns

i want to show only three columns

how to do this?

4 REPLIES 4
Read only

Former Member
0 Likes
583

comment the field catalogs for the columns which u dont want to show in output.

reward points please...

Read only

Former Member
0 Likes
583

i got idea

Read only

Former Member
0 Likes
583

Hi,

You can change the field catalog to achieve this.

And then call the method "alvgrid->set_table_for_first_display" and pass the field catalog to it.

Regards,

Sheron

Read only

Former Member
0 Likes
583

Hi,

In the field catalog , just define the columns which u want to display.Then only that columns will be displayed.I am sending a simple eg of ALV in which i am displaying three columns Purchase orde, material no and net price from ekpo table.

Plz reward if useful.

Thanks.

REPORT ZHALV.

tables:ekpo.

data itab_ekpo type ekpo occurs 100 with header line.

types: begin of itab_new,

ebeln type ekpo-ebeln,

matnr type ekpo-matnr,

netpr type ekpo-netpr,

end of itab_new.

data itab1 TYPE STANDARD TABLE OF itab_new initial size 0.

type-pools: slis.

DATA: l_layout TYPE slis_layout_alv.

DATA : l_sort TYPE slis_t_sortinfo_alv,

w_sort TYPE slis_sortinfo_alv.

DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, lf_fieldcat TYPE slis_fieldcat_alv.

DATA: ws_repid TYPE sy-repid VALUE 'ZHALV'.

selection-screen Begin of block block1 with frame title text-111.

select-options : S_EBELN for EKPO-EBELN.

selection-screen end of block block1.

INITIALIZATION.

start-of-selection.

select ebeln matnr netpr from ekpo into table itab1 up to 10 rows WHERE EBELN IN S_EBELN.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM GET_DETAILS.

PERFORM sort_layout.

end-of-selection.

&----


*& Form build_fieldcatalog

&----


  • text

----


**********************************************************************

Look fieldcatlog below carefully wher i am displaying three columns po,mat.no and

netprice.

*********************************************************************

FORM build_fieldcatalog .

  • PURCHASING DOCUMENT NUMBER

CLEAR lf_fieldcat.

lf_fieldcat-fieldname = 'EBELN'.

lf_fieldcat-ref_tabname = 'EKKO'.

lf_fieldcat-ref_fieldname = 'EBELN'.

APPEND lf_fieldcat TO lt_fieldcat.

  • MATERIAL NUMBER

CLEAR lf_fieldcat.

lf_fieldcat-fieldname = 'MATNR'.

lf_fieldcat-ref_tabname = 'EKPO'.

lf_fieldcat-ref_fieldname = 'MATNR'.

APPEND lf_fieldcat TO lt_fieldcat.

  • NET PRICE IN PURCHASING DOCUMENT

CLEAR lf_fieldcat.

lf_fieldcat-fieldname = 'NETPR'.

lf_fieldcat-ref_tabname = 'EKPO'.

lf_fieldcat-ref_fieldname = 'NETPR'.

  • lf_fieldcat-cfieldname = 'WAERS'.

lf_fieldcat-do_sum = 'X'.

APPEND lf_fieldcat TO lt_fieldcat.

ENDFORM. " build_fieldcatalog

&----


*& Form GET_DETAILS

&----


  • text

----


FORM GET_DETAILS.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = ws_repid

IT_FIELDCAT = lt_fieldcat

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

.

IF SY-SUBRC <> 0.

WRITE: 'SY-SUBRC: ', SY-SUBRC .

ENDIF.

ENDFORM. "GET_DETAILS