2011 Aug 08 2:25 PM
We are selecting data from an external MS SQL database into an internal table using ABAP. The data for the text field is coming out in the format below.
u2018{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs17 dsfdsgds gsgsdfgf\par }u2019
Does anyone know if there is a way in ABAP to convert this text into a readable format?
We want the text from this field to used in BAPI_PO_CREATE1 as the poitem-SHORT_TEXT.
Thank you
Karen
2011 Aug 10 11:06 PM
Hi Karen,
This should work:
DATA l_string TYPE string.
l_string = '{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}'
&' {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs17 dsfdsgds gsgsdfgf\par }'.
DATA lt_tline TYPE TABLE OF tline.
DATA lt_rtf TYPE tdtab_x256.
DATA l_size TYPE i.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = l_string
IMPORTING
length = l_size
TABLES
ftext_tab = lt_rtf.
DATA ls_thead TYPE thead.
CALL FUNCTION 'CONVERT_RTF_TO_ITF'
EXPORTING
header = ls_thead
x_datatab = lt_rtf
x_size = l_size
TABLES
itf_lines = lt_tline
EXCEPTIONS
invalid_tabletype = 1
missing_size = 2
OTHERS = 3.
DATA lt_string TYPE TABLE OF string.
CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
EXPORTING
lf = 'X'
IMPORTING
stream_lines = lt_string[]
TABLES
itf_text = lt_tline.
DESCRIBE TABLE lt_string.
ASSERT sy-tfill = 1.
DATA l_result TYPE string.
READ TABLE lt_string INDEX 1 INTO l_result.
ASSERT l_result = ' dsfdsgds gsgsdfgf'.
Note that the SAP function module returns an incorrect leading space, that you can easily remove.
Best regards,
Sandra
We are selecting data from an external MS SQL database into an internal table using ABAP. The data for the text field is coming out in the format below.
u2018{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs17 dsfdsgds gsgsdfgf\par }u2019
Does anyone know if there is a way in ABAP to convert this text into a readable format?
We want the text from this field to used in BAPI_PO_CREATE1 as the poitem-SHORT_TEXT.
Thank you
Karen
2011 Aug 10 11:06 PM
Hi Karen,
This should work:
DATA l_string TYPE string.
l_string = '{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}'
&' {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs17 dsfdsgds gsgsdfgf\par }'.
DATA lt_tline TYPE TABLE OF tline.
DATA lt_rtf TYPE tdtab_x256.
DATA l_size TYPE i.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = l_string
IMPORTING
length = l_size
TABLES
ftext_tab = lt_rtf.
DATA ls_thead TYPE thead.
CALL FUNCTION 'CONVERT_RTF_TO_ITF'
EXPORTING
header = ls_thead
x_datatab = lt_rtf
x_size = l_size
TABLES
itf_lines = lt_tline
EXCEPTIONS
invalid_tabletype = 1
missing_size = 2
OTHERS = 3.
DATA lt_string TYPE TABLE OF string.
CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
EXPORTING
lf = 'X'
IMPORTING
stream_lines = lt_string[]
TABLES
itf_text = lt_tline.
DESCRIBE TABLE lt_string.
ASSERT sy-tfill = 1.
DATA l_result TYPE string.
READ TABLE lt_string INDEX 1 INTO l_result.
ASSERT l_result = ' dsfdsgds gsgsdfgf'.
Note that the SAP function module returns an incorrect leading space, that you can easily remove.
Best regards,
Sandra
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |