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

Thousand Separator in Quantity fields

Former Member
0 Likes
7,658

Hi Gurus,

I am displaying a custom ALV using REUSE_ALV_GRID_DISPLAY with all the item quantities, weight, volume from sales order and delivery.

There is a requirement where in I dont have to show the thousand separator as either ',' or '.' ('X'-1,234,567.89 ; 'Y'-1 234 567.89; blank-1.234.567,89) in all the item quantities, weight and volume.

During debugging, I dont see any separator in all these field values and only when ALV is shown, I can see the separators based on user profile settings.

Also I tried using, 1. REPLACE ALL OCCURENCES OF 2. split the field values and condense but this didn't work as I dont see the separator in internal tables.

Suggest me if we can restrict at fieldcatalog level or alternate ways to display these values without thousand separator.

Example:

Weight - 146780.65 is now shown as 146,780.65

Volume - 14567890.00 is now shown as 145,678,90.00

Thanks in advance.

Regards

Lakshmanan

9 REPLIES 9
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,748

I would not have done it as it is as per the expectations and i can use all total/subtotal alv functionality easily. In case you still want to then Check your field catalog for this field..what is the reference fields you have given remove them and let it be character type only. Please think about total/subtotal before doing this stuff

Nabheet

Read only

0 Likes
3,748

Hi Nabheet,

Yes we cannot change it to character field as I need to show subtotal for these fields for each delivery and grandtotal for all the deliveries. Suggest me alternate way to do this.

Regards

Lakshmanan

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,748

Did you try EDIT_MASK field in field catalog ?

Regards,
Raymond

Read only

0 Likes
3,748

Raymond,

What would be the mask option to be used to remove thousand separator?
I tried using '==DEC02' but it doesn't work. Suggest me any other solution.

JK

Read only

0 Likes
3,748

Any mask like _____.__V (with enough _) should do the job.

The conversion exit DEC02 only insures number of decimals but use user profile settings for numeric display. You could create your own z-conversion-exit similar to DEC02 but removing thousand separator and/or condensing the string to remove space.

Regards,

Raymond

Read only

Private_Member_7726
Active Contributor
0 Likes
3,748

Hi,

There is EDIT_MASK attribute in the field catalog, it accepts an edit mask of a WRITE statement, which you can assign in program. Something like 'RR_____.__V' for instance. The edit mask would need to vary according to the length of decimal fields. Alternatively, if the output structure is defined in DDIC and uses specific domains, the output conversion routine could be assigned statically in domain attributes. The latter approach would be helpful if there are several reports to change.

cheers

Janis

Read only

0 Likes
3,748

Hi Janis,

This field is a numeric field and it doesnt accept EDIT MASK when I use WRITE statement.

Can you suggest me the EDIT MASK option to be provided for this? Is there any way to check all the EDIT MASK options?

JK

Read only

0 Likes
3,748

Hi,

Hmm... this quick code fragment works fine for me... and illustrates the principle - you'd need to assign edit masks to decimal fields before calling ALV display.

Please bear in mind that the SUPPRESS_DEC_SEPARATORS subroutine relies on what fieldcatalog attributes REUSE_ALV_FIELDCATALOG_MERGE sets for the DDIC structure - you might need to figure out another way to determine output length and number of digits after decimal point, if you have build the field catalog some other way.

  DATA: gt_fieldcat TYPE slis_t_fieldcat_alv .
  FIELD-SYMBOLS: <gs_fieldcat> TYPE  slis_fieldcat_alv .

  ....

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = {ddic structure name}

    CHANGING
      ct_fieldcat            = gt_fieldcat   

    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  LOOP AT gt_fieldcat ASSIGNING <gs_fieldcat> WHERE datatype = 'DEC'.
    PERFORM suppress_dec_separators
      CHANGING
        <gs_fieldcat> .
  ENDLOOP .

FORM suppress_dec_separators
  CHANGING
    cs_fieldcat TYPE slis_fieldcat_alv .

  DATA: l_editmask TYPE slis_fieldcat_alv-edit_mask  .
  DATA: l_elementname TYPE string .
  DATA: lo_elemdescr TYPE REF TO cl_abap_elemdescr .

  CONCATENATE cs_fieldcat-ref_tabname cs_fieldcat-fieldname
    INTO l_elementname SEPARATED BY '-' .

  lo_elemdescr ?= cl_abap_elemdescr=>describe_by_name( l_elementname ).

  l_editmask = 'RR' . "right-justified


  DO lo_elemdescr->output_length - lo_elemdescr->decimals TIMES .
    l_editmask = l_editmask && '_' .
  ENDDO .


  IF lo_elemdescr->decimals GT 0 .
    l_editmask = l_editmask && '.' .
    DO lo_elemdescr->decimals TIMES .
      l_editmask = l_editmask && '_' .
    ENDDO .
  ENDIF .


  l_editmask = l_editmask && 'V' . "sign to the right

  cs_fieldcat-edit_mask = l_editmask .

ENDFORM .                    "suppress_dec_separators

Edit In: when you write "numeric field", what are the types of those fields - packed decimal?

cheers

Janis

Read only

Former Member
0 Likes
3,748

Hi , Solution is here...

You can increase or decrease no of underscores as per your requirement.