05-04-2021 1:39 PM
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.
05-04-2021 2:54 PM
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 🙂
05-04-2021 3:00 PM
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,05-04-2021 4:07 PM
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.
05-04-2021 3:54 PM
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 🙂
05-04-2021 4:52 PM
kernel issue? I think it has always been like that... The trailing space has always been a bizarre thing in ABAP 😄
07-19-2022 8:53 PM
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.
07-19-2022 9:04 PM
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.