cancel
Showing results for 
Search instead for 
Did you mean: 

Suppress leading zeros for ALV column

Former Member
0 Kudos

Hello,

I have an ALV with a column mapped to a context attribute of type NUMC and would like to suppress the leading zeros being displayed. My initial solution was to change the attribute to a char/string type and remove the zeros in my code, but then, the sort functionality no longer works correctly. Any ideas if the ALV can use a 'hidden' field to do the sorting for a certain column... that way, I can display the number as a char/string without the zeros and when the user sorts the column, the ALV will use the hidden NUMC type field.

Thanx for any directions...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Husein.

You can format attributes using the node info. I use it to show zero as blank.

I am not sure whether you can suppress leading zeros:


DATA:
        lr_node_contract_items      TYPE REF TO if_wd_context_node,
        lr_node_info                TYPE REF TO if_wd_context_node_info.

  DATA:
        ls_att_format               TYPE wdy_attribute_format_prop.

  lr_node_contract_items = wd_context->get_child_node( name = if_componentcontroller=>wdctx_contract_items ).
  lr_node_info = lr_node_contract_items->get_node_info( ).

  ls_att_format-null_as_blank = 'X'.

  lr_node_info->set_attribute_format_props(
    name = 'ITM_NUMBER'
    format_properties = ls_att_format
  ).

Just check out wdy_attribute_format_prop. Maybe you can use one of its attributes.

Cheers,

Sascha

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Husein Ali ,

U can set the 'no_zero' field of the field catalog as 'X' to suppress the leading zeros.

Former Member
0 Kudos

Hi,

You can follow the following way which i implemnted for one of my application. Here i am setting this property for the context attrubute. May be this will work. But in ALV there is no separate method for this type of setting.

**This method is used to display the Leading zeros for the Lot Number in Step-1
  DATA:
    node_do_not_change                  TYPE REF TO if_wd_context_node,
    node_d0130_sapmf05a                 TYPE REF TO if_wd_context_node,
    node_pstap                          TYPE REF TO if_wd_context_node,
    node_info                           TYPE REF TO if_wd_context_node_info,
    ls_fprops                           TYPE wdy_attribute_format_prop.

  node_do_not_change = wd_context->get_child_node( name = wd_this->wdctx_do_not_change ).
  node_d0130_sapmf05a = node_do_not_change->get_child_node( name = wd_this->wdctx_d0130_sapmf05a ).
  node_pstap = node_d0130_sapmf05a->get_child_node( name = wd_this->wdctx_pstap ).
  node_info = node_pstap->get_node_info( ).

  ls_fprops = node_info->get_attribute_format_props( 'VALUE' ).
  ls_fprops-null_as_blank = if_wd_context_node_info=>c_format_null_as_BLANK.
  node_info->set_attribute_format_props(
    name              = 'VALUE'
    format_properties = ls_fprops ).

Warm Regards,

Vijay