on 2021 May 05 11:50 AM
payload.jpgslash-n-converted-to-hash.jpgHello Experts,
I have to create Notification in SAP using POST method by using data from Mulesoft.
I have a field called LongText where it can take upto 30000 chars. In this text field, wherever \n is there, i need to break the text to new line. Now the problem is When i receive payload, no where i see the \n but system replacing \n with #.
SPLIT ls_data-long_text AT '#' INTO TABLE lt_ltext.
SPLIT ls_data-long_text AT '\n' INTO TABLE lt_ltext2.
Tried both the above statments to split, but not working. Because it is not exactly #.
Note : Facing this issue only in JSON format. When i test in XML format, It is working fine. But the business needs it in JSON format only.
Thanks
Deva
Hi!
The \n is not replaced by a # sign in the real data, but in that debugger screen, the newline character can not be displayed. Characters that can not be displayed will be displayed as # instead.
As to the SPLIT not working, when you use ' to define a character string, the literal characters are used, so '\n' is a c with length 2 consisting of \ and n, which is not what you want.
Instead you need to specify it as a string, using |, so |\n| will be a CString with length 1 containg a newline character. (Displayed like # in the debugger as explained above)
You can also usa a system constant for it, either of these lines should do the trick:
SPLIT ls_data-long_text AT |\n| INTO TABLE lt_ltext2.
SPLIT ls_data-long_text AT cl_abap_char_utilities=>newline INTO TABLE lt_ltext2.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.