New line character in Information Message in SAP v730 (via message class)? - message

I want the Information Message to show two lines of text.
Can this be done using one message class statement. Ex.
MESSAGE i001(z56_myclass) WITH lv_cust_id.
I tried putting the string of the short text with characters \n # \r \\n etc. but nothing worked. I don't know how to use long text editor for this particular requirement. Any help would be great.

You can't control the message carriage return in MESSAGE statement.
You can try instead with the following information popup
call function 'POPUP_TO_INFORM'
exporting
titel = 'Information'
txt1 = 'Registration successful'
txt2 = 'Customer Id is 0000001234'.
You have 4 text rows at your disposal (from txt1 to txt4).

Related

Error Message Not Displayed Properly and Wrong Input gets selected

I am using jquery select2 method for multiple selections and for users to enter their own input it uses tags property.
Now I want to display the error message when a user enters wrong input.
Therefore, I am using formatResult property of select2 and checking regex for input.
When the input is correct; it returns the input else it returns error message from the function.
But this message is not coming in the format as it comes for select2 example "No matches found" and even when the error message is displayed, on clicking enter it takes the wrong input.
I want to display the message in correct format and not to select the wrong input on enter.
Please help. Below is my code:
$("#abc").select2({
minimumInputLength:1,
maximumInputLength:10,
formatResult: function(term){
if(term.text === 0)
return "Zero Not Allowed";
else return term.text;
}});
In this code, "zero not allowed" is not coming in the same format as "Please enter 1 or more characters" and when we press enter, zero gets selected.

php str_replace produces strange results

I am trying to replace some characters in a text block. All of the replacements are working except the one at the beginning of the string variable.
The text block contains:
[FIRST_NAME] [LAST_NAME], This message is to inform you that...
The variables are defined as:
$fname = "John";
$lname = "Doe";
$messagebody = str_replace('[FIRST_NAME]',$fname,$messagebody);
$messagebody = str_replace('[LAST_NAME]',$lname,$messagebody);
The result I get is:
[FIRST_NAME] Doe, This message is to inform you that...
Regardless of which tag I put first or how the syntax is {TAG} $$TAG or [TAG], the first one never gets replaced.
Can anyone tell me why and how to fix this?
Thanks
Until someone can provide me with an explanation for why this is happening, the workaround is to put a string in front and then remove it afterward:
$messagebody = 'START:'.$messagebody;
do what you need to do
$messagebody = substr($messagebody,6);
I believe it must have something to do with the fact that a string starts at position 0 and that maybe the str_replace function starts to look at position 1.

How to make this UILabel move the email address to the next Line?

I have a simple UILabel that is printing text as follows:
John Doe sent a message to blahblah-
blah#blahblah.com
Thus, the email address here : blahblah-blah#blahblah.com is being cut and partially displayed on the next line. What do I need to do to make it display as :
John Doe sent a message to
blahblah-blah#blahblah.com
?
I already have the following :
self.mailLabel.lineBreakMode = NSLineBreakModeByWordWrapping;
self.mailLabel.numberOfLines = 0;
The string in question is :
[NSString stringWithFormat:#"You sent a message to %#", emailAddress];
What should I do here? Remember, the name can be long and hence, adding a line break in the string won't work because I don't want the following case :
Jonathon Dawson sent a message
to
blahblah-blah#blahblah.com
which should be
Jonathon Dawson sent a message
to blahblah-blah#blahblah.com
self.mailLabel = [NSString StringWithFormat:#"You sent a message to\n%#"];
You use \n to make a new line.
Also, make sure you set the numberOfLines to 2 on the label.
You need to add ZWNBSP(Zero-width no-break space) characters to the left and to the right of - (hyphen, aka dash) symbol:
self.mailLabel.text = [self.mailLabel.text stringByReplacingOccurrencesOfString:#"-" withString:#"\u2060-\u2060"];
Remarks:
U+2060 - Zero-width no-break space Unicode character prevents any line breaks that may be inserter to wrap the word before and after it. As soon as UILabel (as well as other text controls in Cocoa) respects Unicode, you will get text without undesired line breaks.
Wikipedia link: http://en.wikipedia.org/wiki/Zero-width_no-break_space

changing a variable using gets.chomp()

im trying to write to a file using this code:
puts "-------------------- TEXT-EDITOR --------------------"
def tor(old_text)
old_text = gets.chomp #
end
$epic=""
def torr(input)
tore= $epic += input + ", "
File.open("tor.txt", "w") do |write|
write.puts tore
end
end
loop do
output = tor(output)
torr(output)
end
i have read the ultimate guide to ruby programming
and it says if i want to make a new line using in the file im writing to using File.open
i must use "line one", "line two
how can i make this happend using gets.chomp()? try my code and you will see what i mean
thank you.
The gets method will bring in any amount of text but it will terminate when you hit 'Enter' (or once the STDIN receives \n). This input record separator is stored in the global variable $/. If you change the input separator in your script, the gets method will actually trade the 'Enter' key for whatever you changed the global variable to.
$/ = 'EOF' # Or any other string
lines = gets.chomp
> This is
> multilined
> textEOF
lines #=> 'This is\nmultilined\ntext'
Enter whatever you want and then type 'EOF' at the end. Once it 'sees' EOF, it'll terminate the gets method. The chomp method will actually strip off the string 'EOF' from the end.
Then write this to your text file and the \n will translate into new lines.
File.open('newlines.txt', 'w') {|f| f.puts lines}
newlines.txt:
This is
multilined
text
If you dont use .chomp() the \n character will be added whenever you write a new line, if you save this to the file it also will have a new line. .chomp() removes those escape characters from the end of the input.
If this doesnt answer your question, i am sorry i dont understand it.

Stop parsing when hitting an empty line

I have a Rails app parsing incoming e-mails on Heroku using the Cloud-mailin add-on. The app recieves a list of prices in an e-mail and inserts them into the database.
This works fine, but if the e-mail contains for instance a signature in the bottom the code fails because it's also trying to parse that text.
Therefor I would like to rewrite the below parsing code to stop when it hits an empty line in the e-mail. All the price data is always at the top of the e-mail.
email_text = params[:plain]
email_text_array = []
email_text.split("\n").each do |email_line|
email_text_array << email_line.split(" ")
end
How do I change the above to stop when it hits an empty line in the email_taxt variable?
Thanks!
You can add a break :
email_text.split("\n").each do |email_line|
break if email_line.blank? # ends loop on first empty line
email_text_array << email_line.split(" ")
end
Does this question help: Is there a "do ... while" loop in Ruby?
Edit 1:
From the above article I think something like this would work:
email_text.split("\n").each do |email_line|
break if email_line.length < 1
email_text_array << email_line.split(" ")
end

Resources