SAP IMPORT_TEXT Function Module for Text Conversion: Read and Convert Text From GUI File









IMPORT_TEXT is a standard import 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: Read and Convert Text From GUI File 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 import text FM, simply by entering the name IMPORT_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: 12-Jan-2001
Mode(Normal, Remote etc): Normal Function Module
Update:



Function IMPORT_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 'IMPORT_TEXT'"Text Conversion: Read and Convert Text From GUI File
EXPORTING
* CODEPAGE = "Character set of source file
FILE = "Name of file to be imported (with path!)
* FORMAT_TYPE = 'ITF' "Format of file ('ITF', 'RTF', or 'ASCII')
* HEADER = ' ' "See gen.document.; only important for ITF and RTF
* 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
* MASK_BRACKETS = 'X' "Mask special characters <..>

IMPORTING
NEWHEADER = "Text Header of SAPscript Result Text

TABLES
ITF_LINES = "Text table of resulting text

EXCEPTIONS
FILE_OPEN_ERROR = 1 FILE_READ_ERROR = 2 UPLOAD_ERROR = 3 NO_CONTENTS = 4
.



IMPORTING Parameters details for IMPORT_TEXT

CODEPAGE - Character set of source file

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

FILE - Name of file to be imported (with path!)

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

FORMAT_TYPE - Format of file ('ITF', 'RTF', or 'ASCII')

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

HEADER - See gen.document.; only important for ITF and RTF

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)

MASK_BRACKETS - Mask special characters <..>

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

EXPORTING Parameters details for IMPORT_TEXT

NEWHEADER - Text Header of SAPscript Result Text

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

TABLES Parameters details for IMPORT_TEXT

ITF_LINES - Text table of resulting text

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

EXCEPTIONS details

FILE_OPEN_ERROR - File cannot be opened

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

FILE_READ_ERROR - File cannot be read (completely)

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

UPLOAD_ERROR - Other error in uploading the file

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

NO_CONTENTS -

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

Copy and paste ABAP code example for IMPORT_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:
lv_codepage  TYPE TCP02-CPCODEPAGE, "   
lt_itf_lines  TYPE STANDARD TABLE OF TLINE, "   
lv_newheader  TYPE THEAD, "   
lv_file_open_error  TYPE THEAD, "   
lv_file  TYPE RLGRAP-FILENAME, "   
lv_file_read_error  TYPE RLGRAP, "   
lv_format_type  TYPE C, "   'ITF'
lv_upload_error  TYPE C, "   
lv_header  TYPE THEAD, "   SPACE
lv_no_contents  TYPE THEAD, "   
lv_ssheet  TYPE C, "   SPACE
lv_with_tab  TYPE TDBOOL, "   SPACE
lv_word_langu  TYPE SPRAS, "   SY-LANGU
lv_mask_brackets  TYPE TDBOOL. "   'X'

  CALL FUNCTION 'IMPORT_TEXT'  "Text Conversion: Read and Convert Text From GUI File
    EXPORTING
         CODEPAGE = lv_codepage
         FILE = lv_file
         FORMAT_TYPE = lv_format_type
         HEADER = lv_header
         SSHEET = lv_ssheet
         WITH_TAB = lv_with_tab
         WORD_LANGU = lv_word_langu
         MASK_BRACKETS = lv_mask_brackets
    IMPORTING
         NEWHEADER = lv_newheader
    TABLES
         ITF_LINES = lt_itf_lines
    EXCEPTIONS
        FILE_OPEN_ERROR = 1
        FILE_READ_ERROR = 2
        UPLOAD_ERROR = 3
        NO_CONTENTS = 4
. " IMPORT_TEXT




ABAP code using 7.40 inline data declarations to call FM IMPORT_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).
 
 
 
 
"SELECT single FILENAME FROM RLGRAP INTO @DATA(ld_file).
 
 
DATA(ld_format_type) = 'ITF'.
 
 
DATA(ld_header) = ' '.
 
 
DATA(ld_ssheet) = ' '.
 
DATA(ld_with_tab) = ' '.
 
DATA(ld_word_langu) = SY-LANGU.
 
DATA(ld_mask_brackets) = 'X'.
 


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!