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

READ_TEXT

Former Member
0 Likes
682

Hi,

I have developed one program to get purchase order with text.

taken purchase order number as input and PO number and text

as output.

For that i have used function module READ_TEXT.

Its shows error if text is not mentained for PO and program terminates.

My requirement is that how to handle such condition.

If i enter 10 po numbers and if text is mantained for only 8 po.

The function mudule should return that text only.

And prog should not terminate if text is not maintained for any of the purchase order number.

Please suggest me.

Regards,

Deepak.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
579

Hi Deepak.

Loop at it_ekko.

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = it_ekko-ebeln

LANGUAGE = sy-langu

NAME = <text name>

OBJECT = 'EKKO'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES =

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • OBJECT = 5

  • REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8

.

endloop.

Check the function module. In exceptions "NOT FOUND". sy-subrc value is 4. after this catch the exception.

write like this.

if sy-subrc = 4.

endif.

Handle the messages appropriately. Also take care of other exceptions based on the program requirement.

Regards,

Santosh Kumar M.

3 REPLIES 3
Read only

Former Member
0 Likes
579

>For that i have used function module READ_TEXT.

>Its shows error if text is not mentained for PO and program terminates.

>My requirement is that how to handle such condition.

if there is no text then it will not return any text, but it never gives short dump. that means you are doing some thing wrong in your code. May be you are passing parameters wrongly. that might be causing the problem. show the code once.

Read only

Former Member
0 Likes
580

Hi Deepak.

Loop at it_ekko.

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = it_ekko-ebeln

LANGUAGE = sy-langu

NAME = <text name>

OBJECT = 'EKKO'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES =

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • OBJECT = 5

  • REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8

.

endloop.

Check the function module. In exceptions "NOT FOUND". sy-subrc value is 4. after this catch the exception.

write like this.

if sy-subrc = 4.

endif.

Handle the messages appropriately. Also take care of other exceptions based on the program requirement.

Regards,

Santosh Kumar M.

Read only

Former Member
0 Likes
579

Check the sample code.. use the Read text function

REPORT  Z_READ_TEXT.

* Internal table to hold text in the standard text
  DATA:
    BEGIN OF T_TEXT OCCURS 0.
      INCLUDE STRUCTURE tline.     " Text Lines
  DATA: END OF  T_TEXT.

DATA:  TDNAME type  THEAD-TDNAME,
           TDID type  THEAD-TDID,
           TDOBJECT  THEAD-TDOBJECT.

TDID = '0001'.
TDNAME = '0000023232'. "for header , for item concatenate Item number
TDOBJECT = 'EKKO'. " for header , for item it is EKPO.


   CALL FUNCTION 'READ_TEXT'
           EXPORTING
             client                        = sy-mandt
             id                            =  TDID
             language                      = sy-langu
             name                          = TDNAME
             object                        = TDOBJECT
           TABLES
             lines                         = t_text
           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.                         " IF sy-subrc <> 0