0
votes

I want to show a message of type E for which I have to first create a string. The string has mixed string and integer variables to be joined.

Since only strings can be concatenated, I copy integer variable into string variable, make a whole string and concatenate.

Is there a conversion function such as to_string(integer_variable) that can convert integers to string?

PROGRAM abc.
DATA: im_acc_no TYPE i VALUE 100,
      lv_acc_no TYPE string,
      lv_msg TYPE string.
START-OF-SELECTION.
      lv_acc_no = im_acc_no.
      CONCATENATE 'Acnt# ' lv_acc_no ' does not exist' INTO lv_msg.
      MESSAGE lv_msg TYPE 'E'.
1

1 Answers

4
votes

There is the CONV operator (SAP help) which can do something similar to to_string but it is not allowed in the CONCATENATE, so won't help you in your scenario.

You could use the && operator (SAP help) to create the message in-place in the MESSAGE command like:

 MESSAGE |Acnt# | && lv_acc_no && | does not exist| type 'E'.

Side note: do not use this variant of the MESSAGE command, it might be easy to program but it makes it hard to investigate where a message is being generated. For this reason it is better to actually create a message in SE91 and use that. Variable replacements (&) in the message also handle integers just fine.