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 fcat

former_member329386
Participant
0 Kudos

Hi Abapers

I want to know the ways to build fieldcatlog in alvs.( I think there are 3 but not sure)

And what are the parameters to be passed to to them in each case ?

Please give example with all 3 ways .

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi

good

here is all the procedures to create the fieldcatalog.

Building a fieldcatalog based on a dictionary structure/table

  • This Method requires you to create a dictionary structure via

  • SE11 and pass that in the 'I_STRUCTURE_NAME' parameter.

  • The below example will be for all of EKKO but you could create a new

  • structure containing only the fields you require.

*For Function module ALV (report)

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat LIKE LINE OF it_fieldcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'EKKO'

CHANGING

ct_fieldcat = it_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 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.

*For object ALV (Screen)

DATA: gd_fieldcat2 type LVC_T_FCAT.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'EKKO'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

CHANGING

ct_fieldcat = gd_fieldcat2

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

  • Building a fieldcatalog based on an internal table

  • This method relies on the internal table(IT_EKKO) having been

  • declared within an include(i.e. ZDEMO_ALVGRID_STRUCTURE) using

  • version 4.0 methon of declaration:

  • data: begin of it_ekko occurs 0,

  • ebeln like ekko-ebeln,

  • ...

  • end of it_ekko.

data: gd_fieldcat type slis_fieldcat_alv occurs 1.

  • Include to store internal table structure required for FM

  • 'REUSE_ALV_FIELDCATALOG_MERGE'.

include: ZDEMO_ALVGRID_STRUCTURE.

-


call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = 'ZDEMO_ALVGRID'

i_internal_tabname = 'IT_EKKO'

i_inclname = 'ZDEMO_ALVGRID_STRUCTURE'

changing

ct_fieldcat = gd_fieldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

  • Another way is to build the fieldcatalog manualy by populating the

  • internal table fields individually and then appending the rows.

  • This method can be the most time consuming but can also allow you

  • more control of the final product.

  • Beware though, there are many fields that can be populated and you

  • need to ensure that those fields required are populated.

  • When using some of functionality available via ALV such as total.

  • You may need to provide more information than if you were simply

  • displaying the result

  • I.e. Field type may be required in-order for

  • the total function to work.

data: fieldcatalog type slis_t_fieldcat_alv with header line.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

reward point if helpful.

thanks

mrutyun^

6 REPLIES 6

Former Member
0 Kudos

Hi,

The easiest way to learn anything about ALV is just go to the programs starting with SALV*.

Regards,

Atish

Former Member
0 Kudos

hi

good

here is all the procedures to create the fieldcatalog.

Building a fieldcatalog based on a dictionary structure/table

  • This Method requires you to create a dictionary structure via

  • SE11 and pass that in the 'I_STRUCTURE_NAME' parameter.

  • The below example will be for all of EKKO but you could create a new

  • structure containing only the fields you require.

*For Function module ALV (report)

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat LIKE LINE OF it_fieldcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'EKKO'

CHANGING

ct_fieldcat = it_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 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.

*For object ALV (Screen)

DATA: gd_fieldcat2 type LVC_T_FCAT.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'EKKO'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

CHANGING

ct_fieldcat = gd_fieldcat2

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

  • Building a fieldcatalog based on an internal table

  • This method relies on the internal table(IT_EKKO) having been

  • declared within an include(i.e. ZDEMO_ALVGRID_STRUCTURE) using

  • version 4.0 methon of declaration:

  • data: begin of it_ekko occurs 0,

  • ebeln like ekko-ebeln,

  • ...

  • end of it_ekko.

data: gd_fieldcat type slis_fieldcat_alv occurs 1.

  • Include to store internal table structure required for FM

  • 'REUSE_ALV_FIELDCATALOG_MERGE'.

include: ZDEMO_ALVGRID_STRUCTURE.

-


call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = 'ZDEMO_ALVGRID'

i_internal_tabname = 'IT_EKKO'

i_inclname = 'ZDEMO_ALVGRID_STRUCTURE'

changing

ct_fieldcat = gd_fieldcat

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

  • Another way is to build the fieldcatalog manualy by populating the

  • internal table fields individually and then appending the rows.

  • This method can be the most time consuming but can also allow you

  • more control of the final product.

  • Beware though, there are many fields that can be populated and you

  • need to ensure that those fields required are populated.

  • When using some of functionality available via ALV such as total.

  • You may need to provide more information than if you were simply

  • displaying the result

  • I.e. Field type may be required in-order for

  • the total function to work.

data: fieldcatalog type slis_t_fieldcat_alv with header line.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

reward point if helpful.

thanks

mrutyun^

Former Member
0 Kudos

We need to buid the field catelog be.. we need the output struature.

In final internal table we have data but we need struture to place that data in output.

We can directly create the structure OR we need to create a field catelog.

In OOPS ALV we can have many components

Ex.

gs_fcat TYPE lvc_s_fcat, " Field Catalogue

gs_layo TYPE lvc_s_layo, " ALV control: Layout structure

  • Current

CLEAR gs_fcat.

gs_fcat-fieldname = 'CURRENT'.

gs_fcat-ref_table = 'GT_FINAL'.

gs_fcat-coltext = text-025.

gs_fcat-seltext = text-025.

gs_fcat-col_pos = gv_colpos.

gs_fcat-outputlen = 13.

gs_fcat-no_zero = abap_true.

gs_fcat-datatype = 'CURR'.

gs_fcat-do_sum = abap_true.

APPEND gs_fcat TO gt_fcat.

We can also set other options like

ROW_POS

COL_POS

FIELDNAME

TABNAME

CURRENCY

CFIELDNAME

QUANTITY

QFIELDNAME

IFIELDNAME

ROUND

EXPONENT

KEY

KEY_SEL

ICON

SYMBOL

CHECKBOX

JUST

LZERO

NO_SIGN

NO_ZERO

NO_CONVEXT

EDIT_MASK

EMPHASIZE

FIX_COLUMN

DO_SUM

NO_SUM

NO_OUT

TECH

OUTPUTLEN

CONVEXIT

SELTEXT

TOOLTIP

ROLLNAME

DATATYPE

INTTYPE

INTLEN

LOWERCASE

REPTEXT

HIER_LEVEL

REPREP

DOMNAME

SP_GROUP

HOTSPOT

DFIELDNAME

COL_ID

F4AVAILABL

AUTO_VALUE

CHECKTABLE

VALEXI

WEB_FIELD

HREF_HNDL

STYLE

STYLE2

STYLE3

STYLE4

DRDN_HNDL

DRDN_FIELD

NO_MERGING

H_FTYPE

COL_OPT

NO_INIT_CH

DRDN_ALIAS ..........etc

Rewards if useful................

Minal

Former Member
0 Kudos

hi,

You declare the data like this.

DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

use performs

PERFORM BUILD_FIELDCATLOG.

build field catalog like this.

ORM BUILD_FIELDCATLOG . "Form BUILD_FIELDCATLOG, Start

WA_FIELDCAT-FIELDNAME = 'MAKTX'.
WA_FIELDCAT-SELTEXT_M = 'maktx.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'BEDAT'.
WA_FIELDCAT-SELTEXT_M = 'bedat.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.

Regards

Srinu

Former Member
0 Kudos

Hi

http://www.sapdevelopment.co.uk/reporting/alv/alv_variousfcat.htm

Check the following code.

I used it in my program:

*For Field cat.

SFLD-FIELDNAME = 'SWERK'.

SFLD-SELTEXT_L = 'Division'.

SFLD-OUTPUTLEN = 9.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'MSGRP'.

SFLD-SELTEXT_L = 'Depot'.

SFLD-OUTPUTLEN = 10.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'BEZDT'.

SFLD-SELTEXT_L = 'Date'.

SFLD-OUTPUTLEN = 10.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'EQUNR'.

SFLD-SELTEXT_L = 'Pole No.'.

SFLD-OUTPUTLEN = 16.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'ATFLV1'.

SFLD-SELTEXT_L = 'Size(M)'.

SFLD-OUTPUTLEN = 7.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'PLTXT'.

SFLD-SELTEXT_L = 'Location'.

SFLD-OUTPUTLEN = 30.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'ATWRT2'.

SFLD-SELTEXT_L = 'Authority'.

SFLD-OUTPUTLEN = 16.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'KURZTEXT'.

SFLD-SELTEXT_L = 'Reason for change'.

SFLD-OUTPUTLEN = 17.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'ATFLV3'.

SFLD-SELTEXT_L = 'Wattage(W)'.

SFLD-OUTPUTLEN = 11.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'ATWRT4'.

SFLD-SELTEXT_L = 'Lamp Type'.

SFLD-OUTPUTLEN = 9.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

SFLD-FIELDNAME = 'COMMENTS'.

SFLD-SELTEXT_L = 'Comments'.

SFLD-OUTPUTLEN = 25.

  • SFLD-KEY = 'X'.

APPEND SFLD TO ITFLD.

CLEAR SFLD.

PERFORM BUILD_LAYOUT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = 'ZRPMSLM'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'TOP'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = ITFLD[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = ITABMEL1

  • 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.

<b>Reward if usefull</b>

paruchuri_nagesh
Active Contributor
0 Kudos

hi

ucan build field catalog in threeways

1)by using typepool SLIS (manually)

2)If the structure of your output table corresponds to a structure stored in the Data Dictionary (DDIC), the ALV Grid Control can use this information to generate the field catalog automatically. In this case, all fields of this DDIC structure are displayed in the list by using function module(REUSE_ALV_FIELDCATALOG_MERGE) (atumatiacally

3)To generate a field catalog semi-automatically:

Declare an internal table of type LVC_T_FCAT .

Call function module LVC_FIELDCATALOG_MERGE and pass the DDIC structure of the output table and the internal table for the field catalog. The function module generates the field catalog and fills the internal table accordingly.

Read the rows you want to change, and adapt the fields accordingly. If your output table contains more fields than are stored in the Data Dictionary, you must append one row for each new field to the field catalog.

reward points if u find use ful

regards

Nagesh.Paruchuri