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: 

is there any options there in fieldcatalog ?

Former Member
0 Kudos
89

hi friends..

i am using ALV report using fieldcatalog..

in that i dispaly the field with output length 10..

but i want that output length as optimised one...

ie based on the maximum digitsin the field it get vary..

is there any options there in fieldcatalog ?

6 REPLIES 6

Former Member
0 Kudos
57

try this

fieldcat-fieldname = 'matnr'.

fieldcat-outputlen = '15'.

Former Member
0 Kudos
57

Hi

try using this

round type i, " round in write statement

or this

edit_mask type slis_edit_mask,

vivekanand

Former Member
0 Kudos
57

Hi see This program .

REPORT zn_alv_complex .

TABLES : vbrk .

TYPE-POOLS : slis .

CONSTANTS : gc_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

TYPES : BEGIN OF ty_vbrk ,

vbeln TYPE vbrk-vbeln ,

vkorg TYPE vbrk-vkorg,

vtweg TYPE vbrk-vtweg,

kunrg TYPE vbrk-kunrg,

END OF ty_vbrk,

BEGIN OF ty_vbrp,

vbeln TYPE vbrp-vbeln,

posnr TYPE vbrp-posnr,

matnr TYPE vbrp-matnr,

netwr TYPE vbrp-netwr,

END OF ty_vbrp,

BEGIN OF ty_final,

vbeln TYPE vbrk-vbeln ,

posnr TYPE vbrp-posnr,

matnr TYPE vbrp-matnr,

netwr TYPE vbrp-netwr,

vkorg TYPE vbrk-vkorg,

vtweg TYPE vbrk-vtweg,

kunrg TYPE vbrk-kunrg,

END OF ty_final .

DATA : it_vbrk TYPE TABLE OF ty_vbrk,

it_vbrp TYPE TABLE OF ty_vbrp,

it_final TYPE TABLE OF ty_final ,

wa_vbrk TYPE ty_vbrk,

wa_vbrp TYPE ty_vbrp,

wa_final TYPE ty_final ,

git_event TYPE slis_t_event,

git_layout TYPE slis_layout_alv,

git_fieldcat TYPE slis_t_fieldcat_alv,

gwa_fieldcat TYPE slis_fieldcat_alv.

SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln,

s_vkorg FOR vbrk-vkorg,

s_vtweg FOR vbrk-vtweg.

START-OF-SELECTION .

SELECT vbeln vkorg vtweg kunrg

FROM vbrk

INTO TABLE it_vbrk

WHERE vbeln IN s_vbeln

AND vkorg IN s_vkorg

AND vtweg IN s_vtweg .

SELECT vbeln posnr matnr netwr

FROM vbrp

INTO TABLE it_vbrp

FOR ALL ENTRIES IN it_vbrk

WHERE vbeln = it_vbrk-vbeln .

LOOP AT it_vbrp INTO wa_vbrp .

READ TABLE it_vbrk INTO wa_vbrk WITH KEY vbeln = wa_vbrp-vbeln .

wa_final-vbeln = wa_vbrk-vbeln.

wa_final-posnr = wa_vbrp-posnr.

wa_final-netwr = wa_vbrp-netwr.

wa_final-matnr = wa_vbrp-matnr.

wa_final-vkorg = wa_vbrk-vkorg.

wa_final-vtweg = wa_vbrk-vkorg.

wa_final-kunrg = wa_vbrk-kunrg.

APPEND wa_final TO it_final.

CLEAR : wa_vbrk , wa_vbrp , wa_final .

ENDLOOP .

PERFORM sub_fieldcatalog.

PERFORM sub_layout_init CHANGING git_layout.

PERFORM sub_build_event USING git_event[] .

PERFORM sub_alv_display.

&----


*& Form SUB_FIELDCATALOG

&----


  • text

----


FORM sub_fieldcatalog.

REFRESH git_fieldcat.

gwa_fieldcat-col_pos = 0.

gwa_fieldcat-fieldname = 'VBELN'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 14.

gwa_fieldcat-seltext_l = 'Billing Doc.' .

gwa_fieldcat-seltext_m = 'Billing Doc.' .

gwa_fieldcat-seltext_s = 'Billing Doc.' .

APPEND gwa_fieldcat TO git_fieldcat .

gwa_fieldcat-col_pos = 1.

gwa_fieldcat-fieldname = 'POSNR'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 5.

gwa_fieldcat-seltext_l = 'Item.' .

gwa_fieldcat-seltext_m = 'Item' .

gwa_fieldcat-seltext_s = 'Item' .

APPEND gwa_fieldcat TO git_fieldcat .

gwa_fieldcat-col_pos = 2.

gwa_fieldcat-fieldname = 'VKORG'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 14.

gwa_fieldcat-seltext_l = 'Sales Org' .

gwa_fieldcat-seltext_m = 'Sales Org' .

gwa_fieldcat-seltext_s = 'Sales Org' .

APPEND gwa_fieldcat TO git_fieldcat .

gwa_fieldcat-col_pos = 3.

gwa_fieldcat-fieldname = 'VTWEG'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 14.

gwa_fieldcat-seltext_l = 'Dist. Ch.' .

gwa_fieldcat-seltext_m = 'Dist. Ch.' .

gwa_fieldcat-seltext_s = 'Dist. Ch.' .

APPEND gwa_fieldcat TO git_fieldcat .

gwa_fieldcat-col_pos = 4.

gwa_fieldcat-fieldname = 'MATNR'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 18.

gwa_fieldcat-seltext_l = 'Material' .

gwa_fieldcat-seltext_m = 'Material' .

gwa_fieldcat-seltext_s = 'Material' .

APPEND gwa_fieldcat TO git_fieldcat .

gwa_fieldcat-col_pos = 5.

gwa_fieldcat-fieldname = 'NETWR'.

gwa_fieldcat-tabname = 'IT_FINAL'.

gwa_fieldcat-outputlen = 14.

gwa_fieldcat-seltext_l = 'Price' .

gwa_fieldcat-seltext_m = 'Price' .

gwa_fieldcat-seltext_s = 'Price' .

gwa_fieldcat-do_sum = 'X' .

APPEND gwa_fieldcat TO git_fieldcat .

ENDFORM . "SUB_FIELDCATALOG

&----


*& Form sub_alv_display

&----


  • text

----


FORM sub_alv_display .

DATA : gv_repid TYPE sy-repid .

gv_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gv_repid

i_callback_user_command = 'USER-COMMAND'

is_layout = git_layout

it_fieldcat = git_fieldcat

i_save = 'A'

it_events = git_event[]

TABLES

t_outtab = it_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM . "sub_alv_display

&----


*& Form

&----


  • text

----


FORM sub_layout_init CHANGING xyt_layout TYPE slis_layout_alv.

CLEAR xyt_layout .

xyt_layout-colwidth_optimize = 'X'.

xyt_layout-zebra = 'X' .

ENDFORM. "SUB_LAYOUT_INIT

&----


*& Form SUB_BUILD_EVENT

&----


  • text

----


  • -->XT_EVENT text

----


FORM sub_build_event USING xt_event TYPE slis_t_event .

DATA : lwa_event TYPE slis_alv_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = xt_event

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

READ TABLE xt_event WITH KEY name = slis_ev_top_of_page INTO

lwa_event.

lwa_event-form = gc_top_of_page.

IF sy-subrc EQ 0 .

MODIFY xt_event FROM lwa_event TRANSPORTING form WHERE name =

gc_top_of_page.

ENDIF.

ENDFORM. "SUB_BUILD_EVENT

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page .

CONSTANTS : lc_s TYPE char01 VALUE 'S'.

DATA : lv_ecfld(250) TYPE c ,

lwa_header TYPE slis_listheader ,

lv_date(10) TYPE c,

lv_user(10) TYPE c,

lit_alv_header TYPE slis_t_listheader .

CLEAR : lv_user , lv_date .

CLEAR : lwa_header .

lwa_header-typ = 'S'.

lv_ecfld = 'User'.

lwa_header-key = lv_ecfld .

lwa_header-info = sy-uname.

APPEND lwa_header TO lit_alv_header .

CLEAR : lwa_header .

lwa_header-typ = 'S'.

lv_ecfld = 'Date'.

lwa_header-key = lv_ecfld .

lwa_header-info = sy-datum .

APPEND lwa_header TO lit_alv_header .

CLEAR : lwa_header .

lwa_header-typ = 'S'.

APPEND lwa_header TO lit_alv_header .

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = lit_alv_header.

ENDFORM . "TOP_OF_PAGE

Regards,

Nihar Swain.

Former Member
0 Kudos
57

Hi Deva ,

I dont think there is a filed in the catalog , but there is a field in the layout called CWIDTH_OPT (in LVC_S_LAYO ) there is also a similar field in the the SLIS structure , you can use this to get your desired output.

Regards

Arun

0 Kudos
57

s arun..

u r correct.. i solved by myself like as u specified

raymond_giuseppi
Active Contributor
0 Kudos
57

In the layout parameter (IS_LAYOUT in REUSE modules) there is a parameter to optimize column width : <i>colwidth_optimize</i>

Regards