SAP CONVERT_TEXT Function Module for Text Conversion: Convert Text Formats









CONVERT_TEXT is a standard convert text SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Text Conversion: Convert Text Formats processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.


See here to view full function module documentation and code listing for convert text FM, simply by entering the name CONVERT_TEXT into the relevant SAP transaction such as SE37 or SE38.

Function Group: STXK
Program Name: SAPLSTXK
Main Program: SAPLSTXK
Appliation area: S
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function CONVERT_TEXT pattern details

In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.
CALL FUNCTION 'CONVERT_TEXT'"Text Conversion: Convert Text Formats
EXPORTING
* CODEPAGE = '0000' "Source or target character set (depending on DIRECTION)
* TAB_SUBSTITUTE = ' ' "Replacement for tab
* LF_SUBSTITUTE = ' ' "Replacement text for line feed
* REPLACE_SYMBOLS = 'X' "Evaluate symbols during export
* REPLACE_SAPCHARS = 'X' "Evaluate SAP characters during export
* MASK_BRACKETS = 'X' "Mask special characters <..> during import
* DIRECTION = 'EXPORT' "'IMPORT' (<--) or 'EXPORT' (-->)
* FORMAT_TYPE = 'RTF' "'RTF' or 'ASCII'
* FORMATWIDTH = 72 "Line width in results table (only for EXPORT)
* HEADER = ' ' "Text header of original text
* SSHEET = ' ' "Print format; only effective for print format conversion
* WITH_TAB = ' ' "Print format conversion; 'X' = yes or ' ' = no
* WORD_LANGU = SY-LANGU "Only for RTF conversion: System language from Word
* TABLETYPE = 'ASC' "Type of foreign format table: 'BIN' or 'ASC'

IMPORTING
NEWHEADER = "Text header of SAPscript resulting text
WITH_TAB_E = "
FORMATWIDTH_E = "Actual format width at export

TABLES
FOREIGN = "External text table
ITF_LINES = "SAPscript ITF table
* LINKS_TO_CONVERT = "Not implemented

EXCEPTIONS
NOT_SUPPORTED = 1
.



IMPORTING Parameters details for CONVERT_TEXT

CODEPAGE - Source or target character set (depending on DIRECTION)

Data type: TCP02-CPCODEPAGE
Default: '0000'
Optional: Yes
Call by Reference: No ( called with pass by value option)

TAB_SUBSTITUTE - Replacement for tab

Data type: C
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

LF_SUBSTITUTE - Replacement text for line feed

Data type: C
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

REPLACE_SYMBOLS - Evaluate symbols during export

Data type: TDBOOL
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

REPLACE_SAPCHARS - Evaluate SAP characters during export

Data type: TDBOOL
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

MASK_BRACKETS - Mask special characters <..> during import

Data type: TDBOOL
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

DIRECTION - 'IMPORT' (<--) or 'EXPORT' (-->)

Data type: C
Default: 'EXPORT'
Optional: Yes
Call by Reference: No ( called with pass by value option)

FORMAT_TYPE - 'RTF' or 'ASCII'

Data type: C
Default: 'RTF'
Optional: Yes
Call by Reference: No ( called with pass by value option)

FORMATWIDTH - Line width in results table (only for EXPORT)

Data type: ITCTK-TDLINESIZE
Default: 72
Optional: Yes
Call by Reference: No ( called with pass by value option)

HEADER - Text header of original text

Data type: THEAD
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

SSHEET - Print format; only effective for print format conversion

Data type: C
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

WITH_TAB - Print format conversion; 'X' = yes or ' ' = no

Data type: TDBOOL
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

WORD_LANGU - Only for RTF conversion: System language from Word

Data type: SPRAS
Default: SY-LANGU
Optional: Yes
Call by Reference: No ( called with pass by value option)

TABLETYPE - Type of foreign format table: 'BIN' or 'ASC'

Data type: C
Default: 'ASC'
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for CONVERT_TEXT

NEWHEADER - Text header of SAPscript resulting text

Data type: THEAD
Optional: No
Call by Reference: No ( called with pass by value option)

WITH_TAB_E -

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

FORMATWIDTH_E - Actual format width at export

Data type: ITCTK-TDLINESIZE
Optional: No
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for CONVERT_TEXT

FOREIGN - External text table

Data type: TLINE
Optional: No
Call by Reference: No ( called with pass by value option)

ITF_LINES - SAPscript ITF table

Data type: TLINE
Optional: No
Call by Reference: No ( called with pass by value option)

LINKS_TO_CONVERT - Not implemented

Data type: HELP_LINKA
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

NOT_SUPPORTED -

Data type:
Optional: No
Call by Reference: Yes

Copy and paste ABAP code example for CONVERT_TEXT Function Module

The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.

DATA:
lt_foreign  TYPE STANDARD TABLE OF TLINE, "   
lv_codepage  TYPE TCP02-CPCODEPAGE, "   '0000'
lv_newheader  TYPE THEAD, "   
lv_not_supported  TYPE THEAD, "   
lv_tab_substitute  TYPE C, "   SPACE
lv_lf_substitute  TYPE C, "   SPACE
lv_replace_symbols  TYPE TDBOOL, "   'X'
lv_replace_sapchars  TYPE TDBOOL, "   'X'
lv_mask_brackets  TYPE TDBOOL, "   'X'
lv_direction  TYPE C, "   'EXPORT'
lt_itf_lines  TYPE STANDARD TABLE OF TLINE, "   
lv_with_tab_e  TYPE TLINE, "   
lv_format_type  TYPE C, "   'RTF'
lv_formatwidth_e  TYPE ITCTK-TDLINESIZE, "   
lt_links_to_convert  TYPE STANDARD TABLE OF HELP_LINKA, "   
lv_formatwidth  TYPE ITCTK-TDLINESIZE, "   72
lv_header  TYPE THEAD, "   SPACE
lv_ssheet  TYPE C, "   SPACE
lv_with_tab  TYPE TDBOOL, "   SPACE
lv_word_langu  TYPE SPRAS, "   SY-LANGU
lv_tabletype  TYPE C. "   'ASC'

  CALL FUNCTION 'CONVERT_TEXT'  "Text Conversion: Convert Text Formats
    EXPORTING
         CODEPAGE = lv_codepage
         TAB_SUBSTITUTE = lv_tab_substitute
         LF_SUBSTITUTE = lv_lf_substitute
         REPLACE_SYMBOLS = lv_replace_symbols
         REPLACE_SAPCHARS = lv_replace_sapchars
         MASK_BRACKETS = lv_mask_brackets
         DIRECTION = lv_direction
         FORMAT_TYPE = lv_format_type
         FORMATWIDTH = lv_formatwidth
         HEADER = lv_header
         SSHEET = lv_ssheet
         WITH_TAB = lv_with_tab
         WORD_LANGU = lv_word_langu
         TABLETYPE = lv_tabletype
    IMPORTING
         NEWHEADER = lv_newheader
         WITH_TAB_E = lv_with_tab_e
         FORMATWIDTH_E = lv_formatwidth_e
    TABLES
         FOREIGN = lt_foreign
         ITF_LINES = lt_itf_lines
         LINKS_TO_CONVERT = lt_links_to_convert
    EXCEPTIONS
        NOT_SUPPORTED = 1
. " CONVERT_TEXT




ABAP code using 7.40 inline data declarations to call FM CONVERT_TEXT

The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.

 
"SELECT single CPCODEPAGE FROM TCP02 INTO @DATA(ld_codepage).
DATA(ld_codepage) = '0000'.
 
 
 
DATA(ld_tab_substitute) = ' '.
 
DATA(ld_lf_substitute) = ' '.
 
DATA(ld_replace_symbols) = 'X'.
 
DATA(ld_replace_sapchars) = 'X'.
 
DATA(ld_mask_brackets) = 'X'.
 
DATA(ld_direction) = 'EXPORT'.
 
 
 
DATA(ld_format_type) = 'RTF'.
 
"SELECT single TDLINESIZE FROM ITCTK INTO @DATA(ld_formatwidth_e).
 
 
"SELECT single TDLINESIZE FROM ITCTK INTO @DATA(ld_formatwidth).
DATA(ld_formatwidth) = 72.
 
DATA(ld_header) = ' '.
 
DATA(ld_ssheet) = ' '.
 
DATA(ld_with_tab) = ' '.
 
DATA(ld_word_langu) = SY-LANGU.
 
DATA(ld_tabletype) = 'ASC'.
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!