Application Development and Automation 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: 
Read only

Error while reading the Long text Using READ_TEXT

Former Member
0 Likes
2,975

Hi friends,

Right now I am working with Smartforms.While I am reading the Long text of the material using function module READ_TEXT I am getting the following error if the text is not there.

OUT_PURCH_PO ID GRUN language EN not found.

I should not get this error Instead I should get the blank value.

OUT_PURCH_PO - my material name.

Following is my code.

IF WA_EKPO-KNTTP = 'F' AND WA_MTART-MTART = 'ZMSC'.

  • READ TABLE IT_SGTXT INTO WA_SGTXT WITH KEY MATNR = WA_EKPO-MATNR.

  • WA_EKPO-TXZ01 = WA_SGTXT-SGTXT.

NAME = WA_EKPO-MATNR.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = ID

LANGUAGE = SY-LANGU

NAME = NAME

OBJECT = OBJECT

  • IMPORTING

  • HEADER = THEAD

TABLES

LINES = LTEXT.

1 ACCEPTED SOLUTION
Read only

saumya_govil
Active Contributor
0 Likes
1,568

Hi Xavier,

I guess you need to handle exceptions also in the FM.

Please call the FM READ_TEXT using pattern and uncomment the exceptions so that they can be caught.

When no text is found, handle the sy-subrc (i guess it should be 4) and perform the desired operation.

Regards,

Saumya

5 REPLIES 5
Read only

saumya_govil
Active Contributor
0 Likes
1,569

Hi Xavier,

I guess you need to handle exceptions also in the FM.

Please call the FM READ_TEXT using pattern and uncomment the exceptions so that they can be caught.

When no text is found, handle the sy-subrc (i guess it should be 4) and perform the desired operation.

Regards,

Saumya

Read only

Former Member
0 Likes
1,568

Hi,

I think you are getting the message because you are not treating the exception. After the call to the function, try intercepting the result, for example:

CASE SY-SUBRC .

WHEN 1.

.... code for error treatment (or not)

WHEN 2.

ENDCASE.

Regards,

Bruno

Read only

Former Member
0 Likes
1,568

Hi,



CALL FUNCTION 'READ_TEXT'
  EXPORTING
    client                  = sy-mandt
    id                      = id
    language                = sy-langu
    name                    = name
    object                  = object
  TABLES
    lines                   = ltext
  EXCEPTIONS                           " --> have this 
    id                      = 1
    language                = 2
    name                    = 3
    not_found               = 4
    object                  = 5
    reference_check         = 6
    wrong_access_to_archive = 7
    OTHERS                  = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Edited by: Avinash Kodarapu on Jun 5, 2009 7:32 PM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,568

Hello Xavier,

This is because you have no handled the exceptions of the the FM. Try like this:

CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = ID 
LANGUAGE = SY-LANGU
NAME = NAME 
OBJECT = OBJECT
* IMPORTING
* HEADER = THEAD
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.
IF sy-subrc = 0.
" --> Work with the table LTEXT here.
ENDIF.

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
1,568

Thank you friends,

All of your Answers are very helpful.

Regards,

Xavier.P