Application Development and Automation 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: 
Read only

How to read basic data text of material master with line break ?

former_member806437
Participant
0 Likes
2,205

Hi all,

I am new to SAP. Please help me in resolving the below issue.

Actually, I want to read a basic data text into a string variable. I have used FM READ_TEXT and used tdline to read the basic data text of material master. But the characters in the new line are getting ignored.

So, how to read the text?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

venkateswaran_k
Active Contributor
2,092

Hi

Change the loop statement as below you need to concatinate the tdline rows into single field - after your read_text.

data  : line type tdline.
clear : line.

IF sy-subrc = 0.
IF it_lines IS NOT INITIAL.
LOOP AT it_lines INTO x_line.
IF x_line-tdformat = '*'.
l_maktx = x_line-tdline .
CONCATENATE line x_line-tdline INTO line.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
10 REPLIES 10
Read only

venkateswaran_k
Active Contributor
2,092

Hi

Are you getting # as in the place of line-break ?

Read only

Astashonok
Participant
0 Likes
2,092

> But the characters in the new line are getting ignored

you mean that only the first line is being fetched? Maybe smth is wrong with the text?

Read only

venkateswaran_k
Active Contributor
0 Likes
2,092

Hi

Please update,

is the issue solved ?

1. Are you getting # in place of line-feed

2. Suppose you are entering three lines in text, and in READ_TEXT table returns 3 rows?

What is missing - can you give more details?

Read only

former_member806437
Participant
0 Likes
2,092

Hi,

Suppose if there are two lines in the basic data text only the first line is getting fetched and rest of the characters are getting ignored.

Eg: If the basic data description is

"SAP Material Master

basic data text"

Only SAP Material Master is getting fetched.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,092

okay,

can you please share your code on READ_TEXT and how you are looping it.

Also the screen shot of your material basic text

Regards

Venkat

Read only

former_member806437
Participant
0 Likes
2,092

DATA: l_maktx TYPE string.

CALL FUNCTION 'READ_TEXT'
EXPORTING
id = c_id “GRUN
language = l_language “SY-LANGU
name = l_name “MATNR
object = c_object “MATERIAL
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8 .
IF sy-subrc = 0.
IF it_lines IS NOT INITIAL.
LOOP AT it_lines INTO x_line.
IF x_line-tdformat = '*'.
l_maktx = x_line-tdline .
ENDIF.

ENDLOOP.
ENDIF.
ENDIF.

Basic Data Text:

YERT TEST MATERIAL HAVING DESCRIPTION AS XBDAWT-00-0000-00000BG50-01

AND OLD MATERIAL NUMBER AS XBDAWT-00-0000-00000bg50-01

OUTPUT:

YERT TEST MATERIAL HAVING DESCRIPTION AS XBDAWT-00-0000-00000BG50-01

Read only

venkateswaran_k
Active Contributor
2,093

Hi

Change the loop statement as below you need to concatinate the tdline rows into single field - after your read_text.

data  : line type tdline.
clear : line.

IF sy-subrc = 0.
IF it_lines IS NOT INITIAL.
LOOP AT it_lines INTO x_line.
IF x_line-tdformat = '*'.
l_maktx = x_line-tdline .
CONCATENATE line x_line-tdline INTO line.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
Read only

0 Likes
2,092

Hi,

I have changed the code as given . Still getting the same output when trying to print line.

Expected Output:

YERT TEST MATERIAL HAVING DESCRIPTION AS XBDAWT-00-0000-00000BG50-01

AND OLD MATERIAL NUMBER AS XBDAWT-00-0000-00000bg50-01

Actual Output:

Thanks.

Read only

0 Likes
2,092

please show me screenshot the debugger output of it_lines[]. table.

Also

1. you can change the data type line as string.

Read only

2,092

Hi,

Thank you so much. It is working now. I have removed line 4 and 7. Because of that condition I was not getting the output properly.

After removing them I am getting the exact output.

1 IF sy-subrc = 0.
2 IF it_lines IS NOT INITIAL.
3 LOOP AT it_lines INTO x_line.
4 IF x_line-tdformat = '*'.
5 l_maktx = x_line-tdline .
6 CONCATENATE line x_line-tdline INTO line.
7 ENDIF.
8 ENDLOOP.
9 ENDIF.
10 ENDIF.