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

Column Width for Check Box

former_member194669
Active Contributor
0 Likes
1,188

Hi,

I have a ALV report (OOp) within i have column as checkbox. The heading for this column is of length 2. But while in report display system showing this column as displaying the length of 8 character width.

I have already check the following paratmers :

gt_fieldcatalog-outputlen = 3

gt_fieldcatalog-col_opt = 'X'.

gs_layout-cwidth_opt = 'X'

After setting above said parameters still system is showing 8 character width of column

Any info?

Thanks

aRs

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,062

multiple points of confusion..

I agree that i_hts has a field for status .. but what is it populated with ?

looking at your code, i assume, the check box field is showing contents (assuming properties) of the field which is displayed just before that column.

is this correct ? ls_fcat-fieldname = ynetstat-status. i doubt.

try changing it to

ls_fcat-fieldname = 'STATUS'.

ls_fcat-tabname = 'YNETSTAT'.

but, how can the system know, the values of ynetstat-status ? cos, the itab which u pass is i_hts .

9 REPLIES 9
Read only

Former Member
0 Likes
1,062

Hi,

If the field is referred to the Dictionary field, then the length will come for that Dctionary field ..

look at the below link, This link will have all the field catalog fields ..

http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649a6f17411d2b486006094192fe3/content.htm

Regards

Sudheer

Read only

former_member194669
Active Contributor
0 Likes
1,062

Hi,

It field declared as checkbox is dictionary field and have a length 2. But i don't figure why it is showing length of 8 as column width?

aRs

Read only

Former Member
0 Likes
1,062

Can you paste all the field catalog entries for that field ? also, while debugging check whether any field whoch is not cleared is affecting it ?

Read only

former_member194669
Active Contributor
0 Likes
1,062

Hi,

Please find code PBO call


form f_create_and_init_alv.
  data: lt_exclude type ui_functions.
  create object g_custom_container
         exporting container_name = g_container.
  create object g_grid
         exporting i_parent = g_custom_container.

  perform f_build_fieldcat changing gt_fieldcat.
  perform f_build_data.
  if p_input eq c_x.
    v_input = 0.
  else.
    v_input = 1.
  endif.
  set titlebar sy-dynnr with p_netwk.
  gs_layout-stylefname = 'CELLTAB'.
  gs_layout-sel_mode      = c_a.
  gs_layout-cwidth_opt    = c_x.
  gs_layout-zebra         = c_x.

  call method g_grid->set_table_for_first_display
    exporting
      is_layout            = gs_layout
      i_save               = 'A'
      it_toolbar_excluding = i_exclude[]
    changing
      it_fieldcatalog      = gt_fieldcat[]
      it_outtab            = <i_hts>[].
  call method g_grid->set_ready_for_input
    exporting
      i_ready_for_input = v_input.

  call method g_grid->refresh_table_display.

Code for form f_build_fieldcat.


form f_build_fieldcat changing pt_fieldcat type lvc_t_fcat.
  refresh pt_fieldcat.
  data ls_fcat type lvc_s_fcat.
  data p_out type c.
  if v_vflg eq c_a.
    p_out = c_x.
  else.
    clear p_out.
  endif.

  ls_fcat-tabname    = text-007.
  ls_fcat-fieldname  = text-008.
  ls_fcat-ref_field  = text-009.
  ls_fcat-ref_table  = 'Z012798'.
  ls_fcat-datatype   = 'CHAR'.
  ls_fcat-coltext    = text-003.
  ls_fcat-tooltip    = text-003.
  ls_fcat-seltext    = text-003.
  ls_fcat-fix_column = c_x.
  ls_fcat-col_opt   = c_x.
  append ls_fcat to pt_fieldcat.
  clear  ls_fcat.

   select * from ynetstat into ynetstat where status in s_stat.
    clear ls_fcat.
    ls_fcat-ref_field = 'STATUS'.
    ls_fcat-ref_table = 'YNETSTAT'.

    ls_fcat-fieldname = ynetstat-status.
    ls_fcat-datatype  = 'CHAR'.
    ls_fcat-checkbox  = c_x.
    ls_fcat-edit      = c_x.
    ls_fcat-coltext   = ynetstat-status.
    ls_fcat-outputlen = 2.
    append ls_fcat to pt_fieldcat.
  endselect.
  describe table pt_fieldcat lines v_rows.
  call method cl_alv_table_create=>create_dynamic_table
    exporting
      it_fieldcatalog = pt_fieldcat
    importing
      ep_table        = g_hts.
  assign g_hts->* to <i_hts>.

* Create a dummy
  call method cl_alv_table_create=>create_dynamic_table
    exporting
      it_fieldcatalog = pt_fieldcat
    importing
      ep_table        = g_hts.
  assign g_hts->* to <i_hts1>.

  select * from yfe075
      into corresponding fields of table <i_hts>
      where network eq p_netwk
        and status in s_stat.
endform.                                 " F_build_fieldcat

By declaring outputlen = 2 also system giving the column width for checkbox is showing 8.

Thnaks

aRs

Read only

Former Member
0 Likes
1,063

multiple points of confusion..

I agree that i_hts has a field for status .. but what is it populated with ?

looking at your code, i assume, the check box field is showing contents (assuming properties) of the field which is displayed just before that column.

is this correct ? ls_fcat-fieldname = ynetstat-status. i doubt.

try changing it to

ls_fcat-fieldname = 'STATUS'.

ls_fcat-tabname = 'YNETSTAT'.

but, how can the system know, the values of ynetstat-status ? cos, the itab which u pass is i_hts .

Read only

former_member194669
Active Contributor
0 Likes
1,062

Hi,

My field catalog is like


   FIELDNAME                       CHECKBOX           OUTPUTLEN
                                                              
 YFIELDNAME                     |                  |000000    
 CR                             |X                 |000002    
 A2                             |X                 |000002    

and <i_hts> looks like


YFIELDNAME                     A2 AE AP C5 C6 C7 CA CC CE CR
                                                            
NUMOVL                        |X |  |  |  |  |  |  |  |  |   
LOADRANGE                     |  |  |  |  |  |  |  |  |  |X   

Thanks

aRs.

Read only

0 Likes
1,062

Ok.

for second line in field catalog, fieldname = 'CR', . that means, while executing, it will look into table <i_hts> for contents of a field named, CR to display under this column.

But we dont have a field named CR in that table.

I have noticed many time,s that when a field which a field catalog refers to is missing, it just display one of the previous field in that internal table. I guess that is what happening in ur case.

Read only

former_member194669
Active Contributor
0 Likes
1,062

Hi,

Here fieldcatalog contains not all the field are available in the <i_hts> table. Here <i_hts> may contains more fields that all fields are not mandatory to be available in fieldcatalog.

valere nanni.

aRs

Read only

0 Likes
1,062

Hi,

you may forget about all the fieldcatalog hassle. Use the ALV Object Model (cl_salv_table)

Regards,

Clemens