READ_TEXT — READ_TEXT function module for SAPscript long text
READ_TEXT is the standard released function module for retrieving SAPscript long text stored in STXH and STXL, given a text ID, object type, name and language. It returns a THEAD header structure and a TLINE table of raw text lines. NOT_FOUND is a normal, expected outcome for most documents, not a system error, and must be handled explicitly rather than swallowed.
This page covers what READ_TEXT actually does when it fails silently versus when it raises an exception, since the vast majority of related support tickets come from callers treating NOT_FOUND as an error or building the NAME key incorrectly. It also covers the language-key trap, the risk of naive TLINE concatenation, and where READ_TEXT stands relative to clean-core extensibility on S/4HANA.
Published 16 Sept 2026· 1,169 words
What it does
READ_TEXT reads long text objects stored in SAPscript text tables (STXH header, STXL lines) for a given text ID, language, object type and name. It is the standard low-level API used to retrieve item text, header text, purchase order notes, customer master text, and any custom long text created against a text object registered in text object customizing. It returns a THEAD structure describing the text found and a table of TLINE records holding the raw text lines in SAPscript line format, including control blocks for formatting. It is released for customer use and is one of the most widely called function modules in the system, invoked both from print programs and from ad hoc reporting where a text needs to be pulled outside its normal display context.
Parameters
- ID (TDID) - the text ID, must match a value configured in text object customizing for the given object; a valid-looking but wrong ID returns NOT_FOUND, not a syntax error.
- LANGUAGE (TDSPRAS) - single character SAP language key, not the ISO code; passing an ISO code silently finds nothing because the stored key simply does not match.
- NAME (TDNAME) - the object's key, built exactly as the text was originally saved, including any required leading zeros or concatenation of sub-fields such as document number plus item number.
- OBJECT (TDOBJECT) - the text object type, defines which application logic and key structure apply to NAME.
- ARCHIVE_HANDLE - optional, used only when the text has been moved to archive storage; normally left at its default value.
- LOCAL_CAT - optional, controls whether the text catalog is read locally; rarely changed by callers.
- HEADER (exporting) - returns the THEAD structure with text status, change information, and the actual ID/language/name that was found.
- LINES (tables) - returns the text as a table of TLINE, one row per SAPscript line, each carrying a format column and the raw text content.
Exceptions
- ID - the text ID passed does not exist in text customizing; usually a typo or a text ID valid for one object but not this one.
- LANGUAGE - the value is not a valid single-character SAP language key; common when a caller passes an ISO two-letter code without converting it first.
- NAME - the value does not correspond to a valid key for the given object, usually a formatting problem in how the caller built NAME.
- NOT_FOUND - the combination of ID, LANGUAGE, NAME and OBJECT is syntactically valid but no text exists for it; this is a routine outcome for most business documents and must be handled as a normal case, not logged as an error.
- OBJECT - the object type is not registered in text object customizing.
- REFERENCE_CHECK - the text found is a reference to another text object and that reference chain could not be resolved.
- Swallowing all of these behind a bare IF SY-SUBRC NE 0 with no branch produces print output or interface files with a silently missing text block and no trace of why, which is the most common ticket this function module generates.
How to call it safely
Call it with OBJECT, NAME, ID and LANGUAGE fully populated and always check SY-SUBRC afterward. If the result is NOT_FOUND, decide explicitly in the calling program whether that is acceptable for this business scenario or whether a fallback language or fallback text ID should be tried with a second, separate call, rather than assuming LINES is unchanged from a prior attempt. After a successful call the caller still owns reassembling LINES into a flat string or into a formatted stream, honoring the TDFORMAT and TDLINE columns; a naive concatenation discards line-break and formatting control information that downstream print forms rely on. When the text is destined for a SAPscript or Smart Form output, it is usually better to let the form's own text node resolve the text than to pre-read it here and pass a flat string, since that bypasses the form's built-in language and fallback handling.
ECC vs S/4HANA
READ_TEXT is unchanged in S/4HANA; SAPscript long text storage was not restructured in the move to HANA, so the same STXH/STXL structures and the same function module signature apply. It is not part of the released API allowlist for S/4HANA extensibility, and it is not positioned as a clean-core-compatible interface; side-by-side extensions on BTP that need document long text are expected to use a released OData or BAPI-based text service where one exists for the relevant object rather than calling this function module directly over RFC. Inside the classic ABAP stack it remains the standard tool with no announced deprecation or replacement.
Common pitfalls
- Passing an ISO language code instead of the SAP language key, so the call always returns NOT_FOUND even though the text exists.
- Building NAME with an incorrect key format, especially missing leading zeros on numeric keys or omitting a required segment such as an item number.
- Treating NOT_FOUND as a hard error and aborting a batch run, when the majority of business documents legitimately never had the text field populated.
- Concatenating TLINE rows without regard to TDFORMAT, producing garbled line breaks and stray control characters in downstream output.
- Calling READ_TEXT in a tight loop across thousands of documents in a report or interface, generating heavy repeated access to STXH and STXL where a single bulk select would have sufficed if the raw text content was all that was needed.
- Assuming the returned HEADER-TDNAME always equals the NAME passed in, when a reference text can resolve transparently to a different underlying key.
Whose problem this is
This is ABAP development's problem, since it is invoked from custom code, user exits, and print or output logic rather than configured through the IMG. Functional consultants own the upstream data question: whether the relevant text ID exists for the object and whether users are actually maintaining the long text, which is the more frequent root cause of empty output than a coding defect. Basis has no role unless the failure traces back to archive access on ARCHIVE_HANDLE.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-function-modules/read-textERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.