Application Development 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: 

Getting texts out of STXL

Former Member
0 Kudos
2,432

Hi frnd's.

To read text from STXL, you will have to issue the statement like

DATA: tline_tab LIKE tline OCCURS 0 WITH HEADER LINE.

BEGIN OF itab_key OCCURS 0,

tdob LIKE stxh-tdobject,

tdid LIKE stxh-tdid,

tdspras LIKE stxh-tdspras,

tdname LIKE stxh-tdname,

END OF itab_key,

IMPORT tline TO tline_tab FROM database stxl(tx) ID itab_key.

but i am not getting the records.

9 REPLIES 9

abdul_hakim
Active Contributor
0 Kudos
1,015

hi suganya

you need to call the <b>READ_TEXT</b> function module afterwards.otherwise u wont get your long texts..

Cheers,

Abdul Hakim

0 Kudos
1,015

AFTER IMPORT STATEMENT THE SY-SUBRC RETURNED IS 4.

0 Kudos
1,015

yeah that will happen.

You need to use READ_TEXT for getting the text by the values you have obtained from STXL.

Cheers,

Abdul Hakim

0 Kudos
1,015

In my example after the import stateement tline_tab is empty

how can i use read text.

0 Kudos
1,015

hi,

read the entries from stxh using the select statement and then pass the necessary interface parameters to READ_TEXT.

Cheers,

Abdul Hakim

0 Kudos
1,015

Hi Suganya,

I think sy-subrc can be 4 when the key is not correct.

Then the execution of the IMPORT statement will not be carried out correctly and the table will not be populated.

So just verify the key ITAB_KEY.

Regards,

SP.

vinod_gunaware2
Active Contributor
1,015

ABAP READ_TEXT functions to read the SAP Long Text

You have to used the READ_TEXT functions to read the SAP long text. e.g. Sales Order, Purchase Order Item text etc.

To check your long text header, go into the long text. Click Goto -> Header

Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.

REPORT ZTEXT .

TABLES: PBIM.

  • stxh, stxl, stxb - trans tables for text

  • ttxit - text on text-ids

  • ttxot - Short texts on text objects

  • Transaction MD63

SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,

S_WERKS FOR PBIM-WERKS.

DATA: BEGIN OF HTEXT.

INCLUDE STRUCTURE THEAD.

DATA: END OF HTEXT.

DATA: BEGIN OF LTEXT OCCURS 50.

INCLUDE STRUCTURE TLINE.

DATA: END OF LTEXT.

DATA: BEGIN OF DTEXT OCCURS 50.

DATA: MATNR LIKE PBIM-MATNR.

INCLUDE STRUCTURE TLINE.

DATA: END OF DTEXT.

DATA: TNAME LIKE THEAD-TDNAME.

SELECT * FROM PBIM WHERE WERKS IN S_WERKS.

MOVE PBIM-BDZEI TO TNAME.

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = 'PB'

LANGUAGE = 'E'

NAME = TNAME

OBJECT = 'PBPT'

  • ARCHIVE_HANDLE = 0

IMPORTING

HEADER = HTEXT

TABLES

LINES = LTEXT

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

LOOP AT LTEXT.

IF LTEXT-TDLINE NE ''.

MOVE LTEXT-TDLINE TO DTEXT-TDLINE.

MOVE PBIM-MATNR TO DTEXT-MATNR.

APPEND DTEXT.

ENDIF.

ENDLOOP.

ENDSELECT.

LOOP AT DTEXT.

WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.

ENDLOOP .

regards

vinod

0 Kudos
1,015

I was struggling hard to extract the value. Thank you so much!! 🙂

Former Member
0 Kudos
1,015

Hi Suganya,

Use the following code instead.


data : it_tline type table of TLINE.
CALL FUNCTION 'READ_TEXT'
    EXPORTING
*    CLIENT                        = SY-MANDT
      ID                            = TDID
      LANGUAGE                      = SY-LANGU
      NAME                          = TDNAME
      OBJECT                        = TDOBJECT
*     ARCHIVE_HANDLE                = 0
*     LOCAL_CAT                     = ' '
*     IMPORTING
*     HEADER                        =
    TABLES
      LINES                         = IT_TLINE
     EXCEPTIONS
     ID                            = 1
     LANGUAGE                      = 2
     NAME                          = 3
     NOT_FOUND                     = 4
     OBJECT                        = 5
     REFERENCE_CHECK               = 6
     WRONG_ACCESS_TO_ARCHIVE       = 7
     OTHERS                        = 8
            .

Hope it helps..

Lokesh

pls. reward appropriate points