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

problem while using read_text fm

Former Member
0 Likes
1,018

Hi,

iam having one problem if i call read_text fm

only one line is coming in the output.

eg: material(Text)

plant (Text)

my progaram write only one line ie. material i want to consider f all the line in single line.

opt should be: materialplant.

please correct this code

loop at t_mara.

*CONCATENATE t_mara-matnr t_mara-dwerks INTO TeMP IN CHARACTER MODE.

temp = t_mara-matnr .

temp+19(4) = t_mara-dwerks .

WRK_NAME = temp.

*WRITE: / temp..

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'LTXT'

LANGUAGE = SY-LANGU

NAME = WRK_NAME

OBJECT = 'MDTXT'

  • IMPORTING

  • HEADER =

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 .

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

READ TABLE IT_LINES INDEX 1.

TXT_TD03 = IT_LINES-TDLINE.

MOVE TXT_TD03 TO T_MARA-TEXT.

MODIFY T_MARA.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
957

keep your internal table in the loop ,

loop at tlines.

use concatenate into string.

endloop.

finally you will have data in single line..

9 REPLIES 9
Read only

Former Member
0 Likes
957

Hi Arun ,

Check the IT IT_LINES , it must have more than one line .

So loop on IT_LINES and concatenate the text into a varaible separated by sapce.

Loop at IT_LINES.

concatenate T_MARA-TEXT IT_LINES-<TEXT> into T_MARA-TEXT separated by sapce.

endloop.

MODIFY T_MARA.

Hope this helps

Regards

Arun

Message was edited by:

Arun R

Read only

Former Member
0 Likes
957

Change as below,

<b>Looa at IT_LINES.</b>

TXT_TD03 = IT_LINES-TDLINE.

MOVE TXT_TD03 TO T_MARA-TEXT.

MODIFY T_MARA.

<b>endloop.</b>

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
958

keep your internal table in the loop ,

loop at tlines.

use concatenate into string.

endloop.

finally you will have data in single line..

Read only

Nawanandana
Active Contributor
0 Likes
957

hai

DATA wa_it_lines LIKE TLINE.

DATA WRK_NAME LIKE THEAD-TDNAME.

data TXT_TD03 (70).

CONCATENATE W_IT_NUMBER W_IT_DE_NUMBER INTO W_NUMBER.

*Get the dETAIL NUMBER

call function 'READ_TEXT'

exporting

id = 'LTXT'

language = sy-langu

name = WRK_NAME

object = 'MDTXT'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

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.

message id sy-msgid type 'I' number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

read table it_lines index 1 into wa_it_lines .

*GET THE NUMBER BY

TXT_TD03 = IT_LINES-TDLINE.

MOVE TXT_TD03 TO T_MARA-TEXT.

MODIFY T_MARA.

do it like this

regard

nawa

Read only

0 Likes
957

Hi thanks for ur help please iam not able to get u,can u please change the code and send to me let me check it here

Read only

0 Likes
957

Try this.

loop at t_mara.

*CONCATENATE t_mara-matnr t_mara-dwerks INTO TeMP IN CHARACTER MODE.

temp = t_mara-matnr .

temp+19(4) = t_mara-dwerks .

WRK_NAME = temp.

*WRITE: / temp..

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'LTXT'

LANGUAGE = SY-LANGU

NAME = WRK_NAME

OBJECT = 'MDTXT'

  • IMPORTING

  • HEADER =

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 .

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

<b>LOOP AT IT_LINES.</b>

TXT_TD03 = IT_LINES-TDLINE.

MOVE TXT_TD03 TO T_MARA-TEXT.

<b>APPEND T_MARA.</b>

<b>ENDLOOP.</b>

ENDIF.

It will work. Let me know the result.

Regards,

Atish

Read only

0 Likes
957

acutall my code is working the problem is if the text contains multiple lines its bringing only first line in the output i want to consider all the lines present there

it should be concatenated

Read only

0 Likes
957

Hi Arun,

where do you want to concatenate the same?

Do you want to print material number and description or what?

Regards,

Atish

Read only

Former Member
0 Likes
957

loop at t_mara.
*CONCATENATE t_mara-matnr t_mara-dwerks INTO TeMP IN CHARACTER MODE.
temp = t_mara-matnr .
temp+19(4) = t_mara-dwerks .
WRK_NAME = temp.

*WRITE: / temp..
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'LTXT'
LANGUAGE = SY-LANGU
NAME = WRK_NAME
OBJECT = 'MDTXT'
* IMPORTING
* HEADER =
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 .

<b>DATA : TEXT TYPE STRING.</b>
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
<b>LOOP AT IT_LINES.
  TXT_TD03 = IT_LINES-TDLINE.
  CONCATENATE TXT_TD03 INTO TXT_TD03 SEPERATED BY SPACE.
ENDLOOP. 
MOVE TXT_TD03 TO T_MARA-TEXT.
MODIFY T_MARA.
CLEAR TEXT.</b>