‎2008 Aug 09 7:40 AM
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.
‎2008 Aug 09 7:58 AM
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.
‎2008 Aug 09 7:44 AM
>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.
‎2008 Aug 09 7:58 AM
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.
‎2008 Aug 09 8:01 AM
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