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: 

MESSAGE WITH & variable removes ending space character

SebastianK
Explorer
0 Kudos

Hi following example gives problems:

Message Class abc no. 123: &1&2&3&4

DATA lf_msg(200) TYPE c.
* Offset: 0       10        20        30        40        50 
lf_msg = 'This is a test. See, that on the 50th place!!!, a space character is there!'.
MESSAGE i123(abc) WITH lf_msg+0(50) lf_msg+50(50) lf_msg+100(50) lf_msg+150(50).

The output then is: "This is a test. See, that on the 50th place!!!,a space character is there!

I need to have the text correctly displayed in a message. Please don't suggest to put in a space between &1 and &2. The message must stay dynamic, as we get the text from an external system and we want to use it as a message in frontend / application log.

In my opinion this is a kernel issue where it just condenses the variable's ending spaces without having a chance to say RESPECTING BLANKS like in CONCATENATE.

7 REPLIES 7

FredericGirod
Active Contributor
0 Kudos

Apparently the problem is the space is at the end of the first variable. As it is a TEXT type, the space is automaticaly removed.

Even if you replace your 'text' by a `text` (to switch to string), as the value will be put in a TEXT ... the space will disapear.

So as you request it (to not do it), I will propose you to use smart function module to cut text in several part at space. and put space in the message class 🙂

mateuszadamus
Active Contributor

Hello sko_acn

How about this:

DATA:
  lv_message TYPE c LENGTH 200 VALUE 'This is a test. See, that on the 50th place!!!, a space character is there!'.

MESSAGE lv_message TYPE i.
Kind regards,
Mateusz

0 Kudos

To be honest, I think you should handle the errors in your logic and issue your own messages depending on the issue. Forwarding messages from the called report/function isn't a good practice. They might be too generic or too technical for users.


Kind regards,
Mateusz

SebastianK
Explorer
0 Kudos

This might work to some extend, if the message retrieved would be displayed immediately. Unfortunately I have about 5 stacks of calling sequences where I first store the message into BAL and later use the generic

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

to output the last error message which happened within a TRY. CATCH. Block.

But I think this too much effort for this minor issue. Also writing a smart routine, which analyzes the last character of a message variable and then uses a proper message class number with appropriate spaces isn't want I want to waste time on 🙂

Sandra_Rossi
Active Contributor
0 Kudos

kernel issue? I think it has always been like that... The trailing space has always been a bizarre thing in ABAP 😄

martin_parent
Explorer
0 Kudos

Hello Sebastian,

I ran into the same problem and also thought it was a kernel issue but after more investigation, the documentation says "To output multiple placeholders one after the other, the "&" characters must be separated by blanks in the short text.". Your message does not have any blank. &1&2&3&4

Nevertheless I do agree it's a bit strange that the space is not taken into consideration as a valid character like the others and removed automatically. I would have created a ticket for NetWeaver if I wouldn't have found that documentation.

Hope it helps,

Martin.

venkateswaran_k
Active Contributor
0 Kudos

May be this way,

Message Class abc no. 124: &1

DATA lf_msg(200) TYPE c.
DATA lf_fin(200) TYPE C.
CONCATINATE lf_msg+0(50) lf_msg+50(50) lf_msg+100(50) lf_msg+150(50) INTO lf_fin.

MESSAGE i124(abc) WITH lf_fin.