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: 

Text retreiving thruogh Read_text

Former Member
0 Kudos

Hi All,

I am retreiving header text from ME21n transaction trough the read_text function module, It is getting sucessfull when it has text, But it is getting error when it did not have any text.

Please help on this,

Thanks in advance.

Regards,

Praveen

6 REPLIES 6

GauthamV
Active Contributor
0 Kudos

hi,

give some condition when sy-subrc fails.


ex:

if sy-subrc <> 0.

............
.............

endif.

Former Member
0 Kudos

I should not give error if the text is not present instead internal table will be blank...

Uncomment the Exception part of the FM and hadle through Sy-SUbrc

Please elobrate your question..

Edited by: avinash kodarapu on Nov 20, 2008 12:03 PM

Former Member
0 Kudos

HI,

If you still have a problem , u can use the below code instead of using FM read_text.

CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO loc_line.

*for reading the item text

wl_id = 'F05'.

wl_object = 'EKPO'.

wl_name = loc_line.

DATA : BEGIN OF stxl_id,

tdobject LIKE stxl-tdobject,

tdname LIKE stxl-tdname,

tdid LIKE stxl-tdid,

tdspras LIKE stxl-tdspras,

END OF stxl_id.

stxl_id-tdobject = wl_object.

stxl_id-tdname = wl_name.

stxl_id-tdspras = sy-langu.

stxl_id-tdid = wl_id.

IMPORT tline TO int_lines

FROM DATABASE stxl(tx)

CLIENT sy-mandt

ID stxl_id

IGNORING CONVERSION ERRORS.

READ TABLE int_lines INTO wa_lines INDEX 1.

This will give you the text.

int_tlinesa has same structuee as tlines.

Hope this helps...

former_member206439
Contributor
0 Kudos

Hi

Normally Read_Text FM don't give error when it don't find any text.

just it will give blank line in that case.

check your SY-SUBRC after executing that read_text Fm

Former Member
0 Kudos

U remove the comments in Exceptions part then u will not get the error if text does not exist

DATA : BEGIN OF IT_LINES OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA : END OF IT_LINES.

DATA : LANG LIKE THEAD-TDSPRAS.

LANG = 'EN'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'F01'

LANGUAGE = LANG

NAME = '4500008183'

OBJECT = 'EKKO'

TABLES

LINES = IT_LINES

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 NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

see this link

http://www.sapdev.co.uk/sapscript/sapscript_texts.htm

and also see the following example

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = 'ST'

language = 'E'

name = 'ZSMS_LR_INVOICE'

object = 'TEXT'

TABLES

lines = itline

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.