Search code examples
dateconcatenationabap

How to delete space in character text?


I wrote a code that automatically pulls time-related information from the system. As indicated in the table is fixed t247 Month names to 10 characters in length. But it is a bad image when showing on the report screen.

enter image description here

I print this way:

  WRITE : 'Bugün', t_month_names-ltx, ' ayının'.
  CONCATENATE gv_words-word '''nci günü' INTO date.
  CONCATENATE date ',' INTO date.
  CONCATENATE date gv_year INTO date SEPARATED BY space.
  TRANSLATE   date TO LOWER CASE.

I tried the CONDENSE t_month_names-ltx NO-GAPS. method to delete the spaces, but it was not enough.

After WRITE, I was able to write statically by setting the blank value:

  WRITE : 'Bugün', t_month_names-ltx.
  WRITE : 14 'ayının'.
  CONCATENATE gv_words-word '''nci günü' INTO date.
  CONCATENATE date ',' INTO date.
  CONCATENATE date gv_year INTO date SEPARATED BY space.
  TRANSLATE   date TO LOWER CASE.

enter image description here

But this is not a correct use. How do I achieve this dynamically?


Solution

  • You could use a temporary field of type STRING:

    DATA l_month TYPE STRING.
    
    l_month = t_month_names-ltx.
    
    WRITE : 'Bugün', l_month.
    WRITE : 14 'ayının'.
    CONCATENATE gv_words-word '''nci günü' INTO date.
    CONCATENATE date ',' INTO date.
    CONCATENATE date gv_year INTO date SEPARATED BY space.
    TRANSLATE   date TO LOWER CASE.