Application Development 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: 

How to delete space in character text?

shrgrl
Participant
0 Kudos

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.


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.

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

1 ACCEPTED SOLUTION

ClausB
Active Participant

I think this should help you

DATA(lv_text) = |Bugün { t_month_names-ltx } ayının { gv_words-word } 'nci günü, { gv_year }  |.
CONDENSE lv_text.
WRITE:/ lv_text.

8 REPLIES 8

0 Kudos

use backspace it may help you

ClausB
Active Participant

I think this should help you

DATA(lv_text) = |Bugün { t_month_names-ltx } ayının { gv_words-word } 'nci günü, { gv_year }  |.
CONDENSE lv_text.
WRITE:/ lv_text.

michael_piesche
Active Contributor

Some clarification regarding CONDENSE:

  • "CONDENSE text." removes redundant spaces, meaning removing any leading and trailing spaces as well as reducing any sequential spaces to one single space:
    => ' My text ' becomes 'My text'.
  • "CONDENSE text NO-GAPS" removes any spaces, meaning there are no gaps between words afterwords:
    => ' My text ' becomes 'Mytext'.

Also, you are not showing all of your relevant coding, as there are the final WRITE statements missing.

0 Kudos

Hi,

You can also use

REPLACE ALL OCCURRENCES OF space IN lv_text WITH ''.

0 Kudos

Sorry! But with your solution, I get a short dump. The statement "REPLAECE ALL OCCURRENCES OF space..." runs into an endless loop

michael_piesche
Active Contributor
0 Kudos
text = '   My   text   '.
CONDENSE text.            " => '   My   text   ' becomes 'My text'.


text = '   My   text   '.
CONDENSE text NO-GAPS.    " => '   My   text   ' becomes 'Mytext'.

Sandra_Rossi
Active Contributor
0 Kudos

You currently get:

Bugün Temmuz     ayının yirmidört'nci günü, 2020
OR
Bugün Temmuz ayının yirmidört'nci günü, 2020

What exact text do you expect please? Do you expect this text to be stored in a variable or to be output with WRITE?

shrgrl
Participant
0 Kudos

I did it this way and it worked :

DATA l_month TYPE STRING.
l_month = t_month_names-ltx.
WRITE : 'Bugün', l_month.
WRITE : '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.

thank you to everyone for reply!