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 add a field in a field catalog

Former Member
0 Kudos

i have a field catalog wherein i need to add the fields i want. how should i go about this??

regards,

frank

6 REPLIES 6

Former Member
0 Kudos
*ALV data declarations
type-pools: slis.                                 "ALV Declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
      gd_tab_group type slis_t_sp_group_alv,
      gd_layout    type slis_layout_alv,
      gd_repid     like sy-repid.

*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
 END OF t_ekko.


* There are a number of ways to create a fieldcat. 
* For the purpose of this example i will 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, you need to ensure that all 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.

  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-do_sum      = 'X'.        "Display column total
  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.



finally  passing the fieldcatalog to display ....

call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
*            i_callback_user_command = 'USER_COMMAND'
*            i_grid_title           = outtext
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
*            it_special_groups       = gd_tabgroup
*            IT_EVENTS                = GT_XEVENTS
            i_save                  = 'X'
*            is_variant              = z_template

       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.

reward points if it is usefulll

Girish

Former Member
0 Kudos

HI,

Use FM : REUSE_ALV_FIELDCATALOG_MERGE

regards

Deepak

S0025444845
Active Participant
0 Kudos

Hi,

u can take help of below code.

FORM f_display_report.

DATA: l_it_fcat TYPE slis_t_fieldcat_alv,

l_wa_layout TYPE slis_layout_alv.

l_wa_layout-zebra = c_x.

PERFORM f_build_fcatlog TABLES l_it_fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = l_wa_layout

it_fieldcat = l_it_fcat

i_save = c_a

TABLES

t_outtab = it_final

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

&----


*& Form f_BUILD_FCATLOG

&----


  • This subroutine fills the field catalog internal table.

----


*INPUT/OUTPUT -->L_IT_FCAT FIELD CATALOG INTERNAL TABLE

----


FORM f_build_fcatlog TABLES l_it_fcat TYPE slis_t_fieldcat_alv.

PERFORM f_fill_catab: TABLES l_it_fcat

USING c_belnr text-003 c_20, *(c_belnr is field name,

*(text-003 name u want to *diplay in output and c_20 is field lenght 20

TABLES l_it_fcat

USING c_gjahr text-004 c_20,

TABLES l_it_fcat

USING c_ebeln text-005 c_20,

TABLES l_it_fcat

USING c_ekorg text-006 c_25,

TABLES l_it_fcat

USING c_ekgrp text-007 c_15,

TABLES l_it_fcat

USING c_eknam text-009 c_20,

TABLES l_it_fcat

USING c_usnam text-010 c_20.

ENDFORM. "f_BUILD_FCATLOG

&----


*& Form f_FILL_CATAB

&----


  • This subroutine fills the Field catalog Internal table row wise

  • for ALV display

----


*OUTPUT: -->L_IT_FCAT Field catalog table

*INPUT: -->P_FNAME field name

  • -->P_COLTXT Column text

  • -->P_OUTLEN Output Display length

----


FORM f_fill_catab TABLES l_it_fcat TYPE slis_t_fieldcat_alv

USING p_fname TYPE any

p_coltxt TYPE any

p_outlen TYPE any.

l_it_fcat-fieldname = p_fname.

l_it_fcat-seltext_l = p_coltxt.

l_it_fcat-outputlen = p_outlen.

APPEND l_it_fcat TO l_it_fcat.

CLEAR l_it_fcat.

ENDFORM. "f_FILL_CATAB

regards,

Sudha.

reward points if helpful.

Former Member
0 Kudos

hi,

d_fieldcat_wa-fieldname = 'MATNR'.

d_fieldcat_wa-seltext_l = 'material number'.

d_fieldcat_wa-edit = 'X'.

d_fieldcat_wa-col_pos = 1.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

data : gd_repid like sy-repid.

gd_repid = sy-repid.

call function module reuse_alv_grid_display.

exporting.

program name = gd_repid.

t_fieldcatalog = d_fieldcat.

importing.

t_outtab = itab.

exceptions.

Reward with points if helpful.

Former Member
0 Kudos

Thx for the replies.

Bt if i don't want to use a manual method and instead add a field by Navigating to 'Sales and Distribution -> Basic Functions -> Pricing -> Pricing Control' and execute 'Define Condition Tables'.

Plz, if possible suggest a method on these lines.

Regards,

Frank

Former Member
0 Kudos

To add the field you should know the field name ... If you know the field for eg

ZZPRLAND1 , you add this with description by executing the step

Sales and Distribution -> Basic Functions -> Pricing -> Pricing Control' and execute 'Define Condition Tables'.

Also make sure that you have authorisation to add it