Skip to Content
-3

FM READ_TEXT export Lines to a string variable in smartform

Jul 24, 2017 at 09:10 AM

256

avatar image

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

10 |10000 characters needed characters left characters exceeded

Hi Elias,

Do you want to store the lines in a file or you wanted them to display in a report.

Regards,

Priyanka.

0

I want to store to a string variable. Here is what I do now:

CONCATENATE LINES OF it_bank INTO p_gv_text

0

I mean, after storing the value into string, you display it as an out put using WRITE statement?

0

Sorry, no I am displaying to a smartform.

0

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.

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Vogt Fabian Jul 24, 2017 at 10:59 AM
0

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

Show 7 Share
10 |10000 characters needed characters left characters exceeded

But why?

The string template |\n| replaces usage of the cumbersome

CL_ABAP_CHAR_UTILITIES=>NEWLINE. The result is the same. See example under

https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abencl_abap_char_utilities.htm

I always wonder why old fashioned ABAP is proposed if there is state-of-the-art ABAP available instead.
0

It does not work. It display the special character #:

* ABC#* EFG#* HIK

0

It does - check the Ascii. /n is a non-displayable control character.

0

Hi Horst,

just assumed he is working lower Rel. 740 and is not able to use new ABAP syntax ;-)

Regards

Fabian

0

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.

1

C'mon, string templates are 7.02.

0

HASHED tables are 4.6c (IIRC), and people still aren't using those - what hope for 7.02! :-D

1
Horst Keller
Jul 24, 2017 at 09:36 AM
0
Show 7 Share
10 |10000 characters needed characters left characters exceeded

This SEPARATED BY |\n| does not work. Thanks

0

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 ).
0

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

0

Please be precise. What exactly do you mean by "doesn't work".

0

Does not recognize DATA in DATA(sep) = |\n|.

0

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?

0

So your question was posted wrongly.

It should be something like "how to pass text with line feeds to smart forms" ...

0