Application Development and Automation 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: 
Read only

regarding alv

Former Member
0 Likes
827

hi,

in ALV's How to assign field width at runtime?????????

give me with example?????????

hi,

in ALV's How to assign field width at runtime?????????

give me with example?????????

7 REPLIES 7
Read only

amit_khare
Active Contributor
0 Likes
812

You cannot do that in ALV.

Regards,

Amit

Reward all helpful replies.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
812

You can set the OUTPUTLEN in the field catalog to specify the output width of a specific column within the ALV.

Regards,

RIch Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
812

And an example.



report zrich_0003 .

* Global ALV Data Declarations
type-pools: slis.

* Internal Tables
data: begin of ialv occurs 0,
      test1(10) type c,
      test2(10) type c,
      end of ialv.

data: fieldcat  type slis_t_fieldcat_alv.

start-of-selection.

  perform get_data.
  perform call_alv.

*********************************************************************
*      Form  GET_DATA
*********************************************************************
form get_data.

  ialv-test1 = 'ABC'.
  ialv-test2 = 'DEF'.
  append ialv.

  ialv-test1 = 'GHI'.
  ialv-test2 = 'JKL'.
  append ialv.

  ialv-test1 = '123'.
  ialv-test2 = '456'.
  append ialv.

endform.

************************************************************************
*  CALL_ALV
************************************************************************
form call_alv.

  data: tmp_fc type slis_fieldcat_alv.

  clear: fieldcat. refresh: fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Test1'.
  tmp_fc-fieldname    = 'TEST1'.
  tmp_fc-tabname      = 'IALV'.
  tmp_fc-outputlen    = '10'.       "  <- SPECIFY OUTPUT LENGTH
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Test2'.
  tmp_fc-fieldname    = 'TEST2'.
  tmp_fc-tabname      = 'IALV'.
  tmp_fc-outputlen    = '20'.       "  <- SPECIFY OUTPUT LENGTH
  append tmp_fc to fieldcat.



* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      it_fieldcat  = fieldcat
    tables
      t_outtab     = ialv.

endform.

Regards,

RIch Heilman

Read only

0 Likes
812

form call_alv.

data: tmp_fc type slis_fieldcat_alv.

clear: fieldcat. refresh: fieldcat.

clear tmp_fc.

tmp_fc-reptext_ddic = 'Test1'.

tmp_fc-fieldname = 'TEST1'.

tmp_fc-tabname = 'IALV'.

tmp_fc-outputlen = '10'. " <- SPECIFY OUTPUT LENGTH

append tmp_fc to fieldcat.

clear tmp_fc.

tmp_fc-reptext_ddic = 'Test2'.

tmp_fc-fieldname = 'TEST2'.

tmp_fc-tabname = 'IALV'.

tmp_fc-outputlen = '20'. " <- SPECIFY OUTPUT LENGTH

append tmp_fc to fieldcat.

if user want to change the tmp_fc-outputlen to 10 for TEST2 IN RUNTIME HOW we can solve the problem?????????

Read only

0 Likes
812

All the user needs to do is expand the column by grabbing the right side of the column and move towards the right. You know, exactly how you can do this in Excel. That's it. No programming required.

Regards,

RIch Heilman

Read only

0 Likes
812

ok, but if the user wants to change the outputlen to 30. how can u do it?????????

Read only

0 Likes
812

Again, he can simply manipulate the output just like you can in Excel, where you click on the side of the cell or column and drag it to the desired length. If he then always wants to see it this way, he can save the ALV layout as a variant and then he would not need to do this each time.

Regards,

Rich Heilman