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 set column width in alvgrid

laxman_sankhla3
Participant
0 Kudos
316

hi

how to set column width in alvgrid.

thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
151

CLEAR wa_fieldcat.

wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'VBELN'.

wa_fieldcat-tabname = 'IT_FINAL'.

<b> wa_fieldcat-outputlen = '10'.</b>

wa_fieldcat-coltext = 'SALES ORDER'.

*wa_fieldcat-CHECKBOX = 'X'.

APPEND wa_fieldcat TO i_fieldcat.

7 REPLIES 7

p291102
Active Contributor
0 Kudos
151

hI,

GIVE IN THE FIELDCATLOG AS

FIELDCATALOG-OUTPUTLEN = '40'.

Thanks,

Shankar

Former Member
0 Kudos
151

Hi,

Check this,

REPORT ztest.

DATA: BEGIN OF i_scarr_tab OCCURS 0.

INCLUDE STRUCTURE scarr.

DATA: END OF i_scarr_tab.

DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,

w_scarr LIKE LINE OF i_scarr_tab.

DATA: o_grid TYPE REF TO cl_gui_alv_grid,

o_container TYPE REF TO cl_gui_custom_container.

DATA: lt_fcat TYPE lvc_t_fcat,

ls_layo TYPE lvc_s_layo,

ls_sort TYPE lvc_s_sort,

lt_sort TYPE lvc_t_sort,

ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

START-OF-SELECTION.

CALL SCREEN 9000.

&----


*& Module status_9000 OUTPUT

&----


  • text

----


MODULE status_9000 OUTPUT.

SET PF-STATUS '9000'.

SET TITLEBAR '9000'.

ENDMODULE. " status_9000 OUTPUT

&----


*& Module user_command_9000 INPUT

&----


  • text

----


MODULE user_command_9000 INPUT.

CASE sy-ucomm .

WHEN 'BACK' OR 'EXIT'.

SET SCREEN 0.

LEAVE SCREEN.

ENDCASE.

ENDMODULE. " user_command_9000 INPUT

&----


*& Module init_9000 OUTPUT

&----


  • text

----


MODULE init_9000 OUTPUT.

IF o_container IS INITIAL.

SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE

i_scarr UP TO 100 ROWS.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

  • Create a custom container control for ALV Control

CREATE OBJECT o_container

EXPORTING

container_name = 'CONTROL'.

  • Create a ALV Control

CREATE OBJECT o_grid

EXPORTING i_parent = o_container.

PERFORM build_field_catalgue.

ls_layo-sel_mode = 'A'.

CALL METHOD o_grid->set_table_for_first_display

EXPORTING

i_save = 'A'

i_default = 'X'

is_layout = ls_layo

CHANGING

it_outtab = i_scarr[]

it_fieldcatalog = lt_fcat

it_sort = lt_sort[].

ENDIF.

ENDIF.

ENDMODULE. " init_9000 OUTPUT

&----


*& Form build_field_catalgue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_field_catalgue .

DATA: ls_fcat TYPE lvc_s_fcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-cprog

i_internal_tabname = 'I_SCARR_TAB'

i_structure_name = 'SCARR'

  • i_client_never_display = 'X'

CHANGING

ct_fieldcat = ls_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE 'FCAT Error' TYPE 'I'.

EXIT.

ENDIF.

LOOP AT ls_fieldcat.

CLEAR ls_fcat.

ls_fcat-fieldname = ls_fieldcat-fieldname. "Fieldname

ls_fcat-ref_table = ls_fieldcat-tabname. "DDIC ref struct

ls_fcat-inttype = ls_fieldcat-inttype. "Data type

ls_fcat-outputlen = ls_fieldcat-outputlen. "Column width

ls_fcat-coltext = ls_fieldcat-seltext_m. "Column Header

ls_fcat-seltext = ls_fieldcat-seltext_m. "Column Desc

ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field

ls_fcat-ref_table = ls_fieldcat-ref_tabname. "Reference table

CASE ls_fieldcat-fieldname.

WHEN 'LUGGWEIGHT' OR 'FORCURAM'.

ls_fcat-edit = 'X'.

ls_fcat-do_sum = 'X'.

WHEN 'URL'.

ls_fcat-no_out = 'X'.

WHEN OTHERS.

ls_fcat-edit = ' '.

ls_fcat-do_sum = ' '.

ENDCASE.

APPEND ls_fcat TO lt_fcat.

ENDLOOP.

ENDFORM. " build_field_catalgue

check the programs bcalv_grid*.

check this link for more detailed example.

http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/

Regards

Sruthi

p291102
Active Contributor
0 Kudos
151

Hi,

Sorry for my posting. U can do this in only ALV LIST only not for alv grid display.

In ALV GRID u can drag the column know.

Thanks,

Shankar

Former Member
0 Kudos
152

CLEAR wa_fieldcat.

wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'VBELN'.

wa_fieldcat-tabname = 'IT_FINAL'.

<b> wa_fieldcat-outputlen = '10'.</b>

wa_fieldcat-coltext = 'SALES ORDER'.

*wa_fieldcat-CHECKBOX = 'X'.

APPEND wa_fieldcat TO i_fieldcat.

0 Kudos
151

hi sreekanth reddy

its not working

actually problem is i written column name <b>amount</b>

now i want column name as <b>base amount</b>.

but when i m running programe column name is coming<b> amount</b>.

base amount is coming when i resize column by mouse than base amount coming .

i written code like below

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'DMBTR'.

wa_fieldcat-tabname = 'INT_FINAL'.

wa_fieldcat-col_pos = 1.

wa_fieldcat-seltext_l = 'Base Amount'.

wa_fieldcat-outputlen = '30'.

wa_fieldcat-seltext_m = 'Amount'.

wa_fieldcat-seltext_s = 'Amount'.

APPEND wa_fieldcat TO int_fieldcat.

please give me suggestion .

thanks.

0 Kudos
151

Hi,

write as below

ls_fcat-coltext = 'Base Amount' "Column Header

ls_fcat-seltext = 'Base Amount'. "Column Desc

Regards,

Sruthi

0 Kudos
151

thanks to all