07-24-2017 10:10 AM
Hello,
Can someone tell me how to pass the LINES table to a variable string but each line of the table to each line of the string variable.
Namely, I am getting from the FM the table LINES which has 3 lines:
1st line: ABC, 2nd line: DEF and 3rd line: HIK and I want the string variable to show:
ABC
DEF
HIK
How can I do this?
Thanks in advance.
Elias
07-24-2017 10:29 AM
Hi Elias,
Do you want to store the lines in a file or you wanted them to display in a report.
Regards,
Priyanka.
07-24-2017 10:36 AM
Concatenate the lines of the table into the string SEPARATED BY |\n|.
07-24-2017 10:59 AM
07-24-2017 11:17 AM
Of course it does.
DATA itab TYPE TABLE OF string WITH EMPTY KEY.
itab = VALUE #( ( `aaa` ) ( `bbb` ) ( `ccc` ) ).
DATA(sep) = |\n|.
CONCATENATE LINES OF itab INTO DATA(text) SEPARATED BY sep.
cl_demo_output=>display( text ).
07-24-2017 11:56 AM
1st off all I would like to thank you for patience, but I am not an expert abaper.
What i am doing to a perform is:
Declare an itab: DATA: it_bank LIKE TABLE OF tline.
Then call FM READ_TEXT, pass the variables that needs and geting its result to the internal table it_bank. This table has 3 lines. Then I am trying to pass these 3 lines in a string variable with the same 3 lines by using the CONCATENATE: CONCATENATE LINES OF it_bank INTO p_gv_text.
Finally I am displaying this variable to a smartform.
I will be much obliged if someone can help me to dispaly the 3 lines of the table into 3 lines in the string.
Unfortunately the 'seperated by cl_abap_char_utilities=>cr_lf' does not work.
Again Thanks
Elias
07-24-2017 12:11 PM
So your question was posted wrongly.
It should be something like "how to pass text with line feeds to smart forms" ...
07-24-2017 12:13 PM
07-24-2017 12:23 PM
07-24-2017 4:48 PM
What doesn't? Where are you typing this? What version of ABAP are you running? Are you aware that new syntax is often being available and sometimes what's posted here won't work on your system if it's older? And that then you need to do a little research to figure out how to retrofit an answer?
07-24-2017 11:06 AM
I want to store to a string variable. Here is what I do now:
CONCATENATE LINES OF it_bank INTO p_gv_text
07-24-2017 11:10 AM
I mean, after storing the value into string, you display it as an out put using WRITE statement?
07-24-2017 11:38 AM
07-24-2017 11:59 AM
Hi Elias,
the alternative to the solution proposed by Horst Keller would be using the ABAP Char Utilities:
CONCATENATE LINES OF itab INTO <YOUR_STRING> SEPARATED BY CL_ABAP_CHAR_UTILITIES=>NEWLINE.
Those constants represent invisible formatting characters.
Regards
Fabian
07-24-2017 12:05 PM
But why?
The string template |\n| replaces usage of the cumbersome
CL_ABAP_CHAR_UTILITIES=>NEWLINE. The result is the same. See example under
I always wonder why old fashioned ABAP is proposed if there is state-of-the-art ABAP available instead.07-24-2017 12:07 PM
It does not work. It display the special character #:
* ABC#* EFG#* HIK
07-24-2017 12:11 PM
Hi Horst,
just assumed he is working lower Rel. 740 and is not able to use new ABAP syntax 😉
Regards
Fabian
07-24-2017 12:12 PM
Well, not everyone is on the latest version. However, given the reluctance to use hashed or sorted tables, I guess the main reason (once upgrade) is intellectual laziness.
07-24-2017 12:15 PM
07-24-2017 12:22 PM
HASHED tables are 4.6c (IIRC), and people still aren't using those - what hope for 7.02! 😄
07-24-2017 12:49 PM
It does - check the Ascii. /n is a non-displayable control character.
07-25-2017 2:40 AM
You can use include text by passing the variables that you pass to the FM read_text in your smartform. What's the reason for storing the lines in a string?
Regards,
Priyanka.