Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

FM READ_TEXT export Lines to a string variable in smartform

ekekakos
Participant
0 Kudos

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

21 REPLIES 21

satyapriyanka_vana
Active Participant
0 Kudos

Hi Elias,

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

Regards,

Priyanka.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Concatenate the lines of the table into the string SEPARATED BY |\n|.

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

0 Kudos

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

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

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 Kudos

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

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

So your question was posted wrongly.

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

matt
Active Contributor
0 Kudos

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

0 Kudos

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

matt
Active Contributor
0 Kudos

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?

ekekakos
Participant
0 Kudos

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

CONCATENATE LINES OF it_bank INTO p_gv_text

satyapriyanka_vana
Active Participant
0 Kudos

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

ekekakos
Participant
0 Kudos

Sorry, no I am displaying to a smartform.

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

0 Kudos

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_u...

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

0 Kudos

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

* ABC#* EFG#* HIK

0 Kudos

Hi Horst,

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

Regards

Fabian

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.

0 Kudos

C'mon, string templates are 7.02.

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

0 Kudos

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

satyapriyanka_vana
Active Participant
0 Kudos

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.