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: 

ALV-fieldcatlog

Former Member
0 Kudos
244

Hi

I am Filling Field Catlog i n ALV i have long texts and short Texts for the particular filed. If i expand the particular column in alv grid display the long text must appear

other wise short text must appear

Client had given specfic short texts to appear

any suggestions

Regards

Rasheed.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
202
  • Account Number of Vendor or Creditor...

LS_FCAT-FIELDNAME = 'NAME1'.

LS_FCAT-REF_TABLE = 'LFA1'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Vendor Name'(001).

LS_FCAT-SELTEXT = 'Vendor Name'(001).

APPEND LS_FCAT TO PT_FIELDCAT.

CLEAR LS_FCAT.

  • Creation date of the change document...

LS_FCAT-FIELDNAME = 'UDATE'.

LS_FCAT-REF_TABLE = 'CDHDR'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Change Date'(002).

LS_FCAT-SELTEXT = 'Change Date'(002).

APPEND LS_FCAT TO PT_FIELDCAT.

CLEAR LS_FCAT.

  • User name of the person responsible in change document...

LS_FCAT-FIELDNAME = 'USERNAME'.

LS_FCAT-REF_TABLE = 'CDHDR'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Modified by'(003).

LS_FCAT-SELTEXT = 'Modified by'(003).

APPEND LS_FCAT TO PT_FIELDCAT.

You can write the text as above....

Regards,

Pavan

7 REPLIES 7

Former Member
0 Kudos
202

hi,

If u have given short text and long text in the data elements decription this comes automatically.

u can also display long desc in the tool tip....

chk the code below

LOOP AT p_gt_fieldcat4 INTO ls_fcat .

CASE ls_fcat-fieldname .

WHEN l_pre_matnr.

ls_fcat-coltext = 'Pre-requisite art'(021).

ls_fcat-tooltip = 'Pre-requisite art'(021).

WHEN l_pre_maktx.

ls_fcat-coltext = 'PR art desc'(026).

ls_fcat-tooltip = 'PR art desc'(026).

WHEN l_artnum.

ls_fcat-key = 'X'.

WHEN l_artdesc.

ls_fcat-key = 'X'.

WHEN l_zdesc.

ls_fcat-key = 'X'.

ls_fcat-coltext = 'Context'(043).

ls_fcat-tooltip = 'Context'(043).

WHEN l_bbynr.

ls_fcat-key = 'X'.

ENDCASE.

MODIFY p_gt_fieldcat4 FROM ls_fcat.

CLEAR ls_fcat.

ENDLOOP.

<b>please reward points if useful</b>

regards,

raksha

Former Member
0 Kudos
202

Hi,

Generally the medium text will be displayed if no output length is specified for that field.

When output length is specified,depending on attributes either long text or short text is choosen..

So i don't think so u can do that...

Regards,

Omkar.

Former Member
0 Kudos
203
  • Account Number of Vendor or Creditor...

LS_FCAT-FIELDNAME = 'NAME1'.

LS_FCAT-REF_TABLE = 'LFA1'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Vendor Name'(001).

LS_FCAT-SELTEXT = 'Vendor Name'(001).

APPEND LS_FCAT TO PT_FIELDCAT.

CLEAR LS_FCAT.

  • Creation date of the change document...

LS_FCAT-FIELDNAME = 'UDATE'.

LS_FCAT-REF_TABLE = 'CDHDR'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Change Date'(002).

LS_FCAT-SELTEXT = 'Change Date'(002).

APPEND LS_FCAT TO PT_FIELDCAT.

CLEAR LS_FCAT.

  • User name of the person responsible in change document...

LS_FCAT-FIELDNAME = 'USERNAME'.

LS_FCAT-REF_TABLE = 'CDHDR'.

LS_FCAT-INTTYPE = 'C'.

LS_FCAT-OUTPUTLEN = '10'.

LS_FCAT-COLTEXT = 'Modified by'(003).

LS_FCAT-SELTEXT = 'Modified by'(003).

APPEND LS_FCAT TO PT_FIELDCAT.

You can write the text as above....

Regards,

Pavan

Former Member
0 Kudos
202

Hi,

In the field catalog use the following three fields to set up short, medium and long titles:

SCRTEXT_S

SCRTEXT_M

SCRTEXT_L

Regards,

Rao A

0 Kudos
202

Hi

Try like this <b>int_cat-outputlen = '200'.</b> by adjusting this length u can change the length

* Field Catalog

***MATERIAL NO no
  int_cat-tabname       = 'INT_OUT_NEW'.
  int_cat-fieldname     = 'MATNR'.
  int_cat-reptext_ddic  = 'MATERIAL NO'.
  APPEND int_cat .

*material Short Description
  int_cat-tabname       = 'INT_OUT_NEW'.
  int_cat-fieldname     = 'MAKTX'.
  int_cat-reptext_ddic  = 'MATERIAL SHORT DESCRIPTION'.
  int_cat-datatype = 'CHAR'.
  int_cat-outputlen = '45'.

  APPEND int_cat .

** Material Long Description
  int_cat-tabname       = 'INT_OUT_NEW'.
  int_cat-fieldname     = 'TDLINE'.
  int_cat-reptext_ddic  = 'MATERIAL LONG DESCRIPTION'.
  int_cat-datatype = 'CHAR'.
  int_cat-outputlen = '200'.

    APPEND int_cat .

Reward all helpfull answers

Regards

Pavan

former_member235056
Active Contributor
0 Kudos
202

Hi,

Have a look at setting field catalogi.e; set_fieldcat2.

===================================================================

  • This report was initially created by ALVRobot.com.ar

  • Please, read terms and conditions on the site.

===================================================================

  • Author:

  • 16.07.07 -

===================================================================

report .

========================== Global definitions ====================

**

  • Data Types

**

type-pools: slis.

types: begin of tp_data,

ebeln like ekko-ebeln,

aedat like ekko-aedat,

lifnr like ekko-lifnr,

name1 like lfa1-name1,

ebelp like ekpo-ebelp,

txz01 like ekpo-txz01,

matnr like ekpo-matnr,

netpr like ekpo-netpr,

menge like ekpo-menge,

meins like ekpo-meins,

peinh like ekpo-peinh,

end of tp_data,

tp_tbl_data type standard table of tp_data.

**

  • Constants

**

**

  • Data objects (variable declarations and definitions)

**

  • Report data to be shown.

data: it_data type standard table of tp_data.

  • Heading of the report.

data: t_heading type slis_t_listheader.

======================= Selection Screen ==========================

selection-screen: begin of block b1 with frame title text-t01.

DATA: w_aux_ebeln like ekko-ebeln.

SELECT-OPTIONS s_ebeln for w_aux_ebeln .

DATA: w_aux_aedat like ekko-aedat.

SELECT-OPTIONS s_aedat for w_aux_aedat .

DATA: w_aux_name1 like lfa1-name1.

SELECT-OPTIONS s_name1 for w_aux_name1 .

DATA: w_aux_stcd1 like lfa1-stcd1.

SELECT-OPTIONS s_stcd1 for w_aux_stcd1 .

DATA: w_aux_matnr like ekpo-matnr.

SELECT-OPTIONS s_matnr for w_aux_matnr .

selection-screen: end of block b1.

======================== Event Blocks =============================

at selection-screen.

start-of-selection.

perform get_data using it_data.

end-of-selection.

perform build_alv using it_data t_heading.

======================== Subroutines ==============================

&----


*& Form get_data

&----


  • Gets the information to be shown in the report.

----


form get_data using t_data type tp_tbl_data.

SELECT e~ebeln

e~aedat

e~lifnr

l~name1

p~ebelp

p~txz01

p~matnr

p~netpr

p~menge

p~meins

p~peinh

INTO CORRESPONDING FIELDS OF TABLE t_data

FROM ekko as e

inner join lfa1 as l on elifnr = llifnr

inner join ekpo as p on pebeln = eebeln

WHERE e~ebeln in s_ebeln

AND e~aedat in s_aedat

AND l~name1 in s_name1

AND l~stcd1 in s_stcd1

AND p~matnr in s_matnr

.

endform. " get_data

&----


*& Form build_alv

&----


  • Builds and display the ALV Grid.

----


form build_alv using t_data type tp_tbl_data

t_heading type slis_t_listheader.

  • ALV required data objects.

data: w_title type lvc_title,

w_repid type syrepid,

w_comm type slis_formname,

w_status type slis_formname,

x_layout type slis_layout_alv,

t_event type slis_t_event,

t_fieldcat type slis_t_fieldcat_alv,

t_sort type slis_t_sortinfo_alv.

refresh t_fieldcat.

refresh t_event.

refresh t_sort.

clear x_layout.

clear w_title.

  • Field Catalog

perform set_fieldcat2 using:

1 'EBELN' 'EBELN' 'EKKO' space space space space space space space space space space space space t_fieldcat ,

2 'AEDAT' 'AEDAT' 'EKKO' space space space space space space space space space space space space t_fieldcat ,

3 'LIFNR' 'LIFNR' 'EKKO' space space space space space space space space space space space space t_fieldcat ,

4 'NAME1' 'NAME1' 'LFA1' space space space space space space space space space space space space t_fieldcat ,

5 'EBELP' 'EBELP' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

6 'TXZ01' 'TXZ01' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

7 'MATNR' 'MATNR' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

8 'NETPR' 'NETPR' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

9 'MENGE' 'MENGE' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

10 'MEINS' 'MEINS' 'EKPO' space space space space space space space space space space space space t_fieldcat ,

11 'PEINH' 'PEINH' 'EKPO' space space space space space space space space space space space space t_fieldcat .

  • Layout

x_layout-zebra = 'X'.

  • Top of page heading

perform set_top_page_heading using t_heading t_event.

  • Events

perform set_events using t_event.

  • GUI Status

w_status = ''.

w_repid = sy-repid.

  • Title

  • w_title = <<If you want to set a title for

  • the ALV, please, uncomment and edit this line>>.

  • User commands

w_comm = 'USER_COMMAND'.

  • Order

  • Example

  • PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.

  • Displays the ALV grid

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = w_repid

it_fieldcat = t_fieldcat

is_layout = x_layout

it_sort = t_sort

i_callback_pf_status_set = w_status

i_callback_user_command = w_comm

i_save = 'X'

it_events = t_event

i_grid_title = w_title

tables

t_outtab = t_data

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. " build_alv.

&----


*& Form set_top_page_heading

&----


  • Creates the report headings.

----


form set_top_page_heading using t_heading type slis_t_listheader

t_events type slis_t_event.

data: x_heading type slis_listheader,

x_event type line of slis_t_event.

  • Report title

clear t_heading[].

clear x_heading.

x_heading-typ = 'H'.

x_heading-info = ''(001).

append x_heading to t_heading.

  • Program name

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Program: '.

x_heading-info = sy-repid.

append x_heading to t_heading.

  • User who is running the report

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'User: '.

x_heading-info = sy-uname.

append x_heading to t_heading.

  • Date of execution

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Date: '.

write sy-datum to x_heading-info.

append x_heading to t_heading.

  • Time of execution

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Time: '.

write sy-uzeit to x_heading-info.

append x_heading to t_heading.

  • Top of page event

x_event-name = slis_ev_top_of_page.

x_event-form = 'TOP_OF_PAGE'.

append x_event to t_events.

endform.

&----


*& Form set_events

&----


  • Sets the events for ALV.

  • The TOP_OF_PAGE event is alredy being registered in

  • the set_top_page_heading subroutine.

----


form set_events using t_events type slis_t_event.

data: x_event type line of slis_t_event.

**

  • Example

  • -------

  • clear x_event.

  • x_event-name = .

  • x_event-form = .

  • append x_event to t_event.

**

endform.

&----


*& Form set_order

&----


  • Adds an entry to the order table.

----


FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot

t_sort TYPE slis_t_sortinfo_alv.

DATA: x_sort TYPE slis_sortinfo_alv.

CLEAR x_sort.

x_sort-fieldname = p_fieldname.

x_sort-tabname = p_tabname.

x_sort-up = p_up.

x_sort-down = p_down.

x_sort-subtot = p_subtot.

APPEND x_sort TO t_sort.

ENDFORM. "set_order

&----


*& Form set_fieldcat2

&----


  • Adds an entry to the field catalog.

  • p_colpos: Column position.

  • p_fieldname: Field of internal table which is being described by

* this record of the field catalog.

  • p_ref_fieldname: (Optional) Table field / data element which

* describes the properties of the field.

* If this field is not given, it is copied from

* the fieldname.

  • p_ref_tabname: (Optional) Table which holds the field referenced

* by <<p_ref_fieldname>>.

  • If this is not given, the parameter

  • <<p_ref_fieldname>> references a data element.

  • p_outputlen: (Optional) Column width.

  • p_noout: (Optional) If set to 'X', states that the field is not

* showed initially. If so, the field has to be

  • included in the report at runtime using the display

  • options.

  • p_seltext_m: (Optional) Medium label to be used as column header.

  • p_seltext_l: (Optional) Long label to be used as column header.

  • p_seltext_s: (Optional) Small label to be used as column header.

  • p_reptext_ddic: (Optional) Extra small (heading) label to be

* used as column header.

  • p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select

  • whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,

  • or REPTEXT_DDIC as text for column header.

  • p_hotspot: (Optional) If set to 'X', this field will be used

* as a hotspot area for cursor, alolowing the user

* to click on the field.

  • p_showasicon: (Optional) If set to 'X', this field will be shown

  • as an icon and the contents of the field will set

* which icon to show.

  • p_checkbox: (Optional) If set to 'X', this field will be shown

  • as a checkbox.

  • p_edit: (Optional) If set to 'X', this field will be editable.

  • p_dosum: (Optional) If set to 'X', this field will be summed

  • (aggregation function) according to the grouping set

  • by the order functions.

  • t_fieldcat: Table which contains the whole fieldcat.

----


FORM set_fieldcat2 USING

p_colpos p_fieldname p_ref_fieldname p_ref_tabname

p_outputlen p_noout

p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt

p_hotspot p_showasicon p_checkbox p_edit

p_dosum

t_fieldcat TYPE slis_t_fieldcat_alv.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

CLEAR wa_fieldcat.

  • General settings

wa_fieldcat-fieldname = p_fieldname.

wa_fieldcat-col_pos = p_colpos.

wa_fieldcat-no_out = p_noout.

wa_fieldcat-hotspot = p_hotspot.

wa_fieldcat-checkbox = p_checkbox.

wa_fieldcat-icon = p_showasicon.

wa_fieldcat-do_sum = p_dosum.

  • Set reference fieldname, tablenam and rollname.

  • If p_ref_tabname is not given, the ref_fieldname given

  • is a data element.

  • If p_ref_tabname is given, the ref_fieldname given is a

  • field of a table.

  • In case ref_fieldname is not given,

  • it is copied from the fieldname.

IF p_ref_tabname IS INITIAL.

wa_fieldcat-rollname = p_ref_fieldname.

ELSE.

wa_fieldcat-ref_tabname = p_ref_tabname.

IF p_ref_fieldname EQ space.

wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.

ELSE.

wa_fieldcat-ref_fieldname = p_ref_fieldname.

ENDIF.

ENDIF.

  • Set output length.

IF NOT p_outputlen IS INITIAL.

wa_fieldcat-outputlen = p_outputlen.

ENDIF.

  • Set text headers.

IF NOT p_seltext_m IS INITIAL.

wa_fieldcat-seltext_m = p_seltext_m.

ENDIF.

IF NOT p_seltext_l IS INITIAL.

wa_fieldcat-seltext_l = p_seltext_l.

ENDIF.

IF NOT p_seltext_s IS INITIAL.

wa_fieldcat-seltext_s = p_seltext_s.

ENDIF.

IF NOT p_reptext_ddic IS INITIAL.

wa_fieldcat-reptext_ddic = p_reptext_ddic.

ENDIF.

IF NOT p_ddictxt IS INITIAL.

wa_fieldcat-ddictxt = p_ddictxt.

ENDIF.

  • Set as editable or not.

IF NOT p_edit IS INITIAL.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

ENDIF.

APPEND wa_fieldcat TO t_fieldcat.

ENDFORM. "set_fieldcat2

======================== Subroutines called by ALV ================

&----


*& Form top_of_page

&----


  • Called on top_of_page ALV event.

  • Prints the heading.

----


form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

  • i_logo = <<If you want to set a logo, please,

  • uncomment and edit this line>>

it_list_commentary = t_heading.

endform. " alv_top_of_page

&----


*& Form user_command

&----


  • Called on user_command ALV event.

  • Executes custom commands.

----


form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

**

  • Example Code

  • Executes a command considering the sy-ucomm.

  • CASE r_ucomm.

  • WHEN '&IC1'.

  • Set your "double click action" response here.

*

  • Example code: Create and display a status message.

  • DATA: w_msg TYPE string,

  • w_row(4) TYPE n.

  • w_row = rs_selfield-tabindex.

  • CONCATENATE 'You have clicked row' w_row

  • 'field' rs_selfield-fieldname

  • 'with value' rs_selfield-value

  • INTO w_msg SEPARATED BY space.

  • MESSAGE w_msg TYPE 'S'.

  • ENDCASE.

  • End of example code.

**

endform. "user_command

Pls reward points if helpful.

Regards,

Ameet

Former Member
0 Kudos
202

hi Rasheed,

you can do it following

FORM fill_fieldcat .

  • Preparing Fieldcatalog

REFRESH gi_fieldcatalog.

gi_fieldcatalog-fieldname = 'COL1'.

gi_fieldcatalog-seltext_l = text-001.

gi_fieldcatalog-seltext_m = text-002.

gi_fieldcatalog-seltext_s = text-003.

gi_fieldcatalog-col_pos = 0.

gi_fieldcatalog-no_zero = gc_x.

gi_fieldcatalog-just = c_c.

gi_fieldcatalog-do_sum = gc_x.

APPEND gi_fieldcatalog .

CLEAR gi_fieldcatalog.

where seltext_l = long text

seltext_m = medium length text

seltext_s = short text

text-001 = Vendor number

text-002 = Vendor no.

text-003 = Vend no.

and these seltext is given according to the name defined in the database table of the particular field

Example

EKPO --> ebeln --> data element --> feild label --> here three names for EBELn is defined Short medium and long