10-19-2010 12:19 PM
HI All,
I am creating text for PO item through user exit.
If it contains any text already..it need to add the new text to the next line.
for this i am reading the existing data and appending taht data to internal table , appending new data to this internal table along with old data.
i am getting the error as " I/O error for text EKPO 450000090500001 F01 EN'.
please check my code and provide me the suggtions to avoid this error.
IF sy-tcode = 'ME21N' OR sy-tcode = 'ME22N' .
DATA : v_thead LIKE thead,
v_tline LIKE tline,
t_it_tline LIKE tline OCCURS 0,
t_it_tline_r LIKE tline OCCURS 0,
wa_tline_r TYPE tline,
v_auart TYPE auart,
v_kdmat TYPE kdmat.
DATA: cc LIKE sy-index.
DATA: t_object LIKE STANDARD TABLE OF stxdrobj.
DATA: t_name LIKE STANDARD TABLE OF stxdrname.
DATA: t_id LIKE STANDARD TABLE OF stxdrid.
DATA: t_language LIKE STANDARD TABLE OF stxdrlang.
CLEAR : v_auart,
v_kdmat,
v_tline,
v_thead.
REFRESH t_it_tline.
MOVE : 'F01' TO v_thead-tdid,
'EKPO' TO v_thead-tdobject,
sy-langu TO v_thead-tdspras.
LOOP AT xekpo.
CLEAR v_tline.
REFRESH t_it_tline.
READ TABLE xekkn WITH KEY ebelp = xekpo-ebelp.
IF sy-subrc = 0.
SELECT SINGLE auart FROM vbak INTO v_auart WHERE
vbeln = xekkn-vbeln.
IF v_auart = 'ZYCA'.
SELECT SINGLE kdmat FROM vbap INTO v_kdmat
WHERE vbeln = xekkn-vbeln
AND posnr = xekkn-vbelp
AND matnr = xekpo-matnr.
CONCATENATE 'Customer Part No:' v_kdmat INTO v_tline-tdline.
v_thead-tdname+0(10) = i_ekko-ebeln.
v_thead-tdname+10(5) = xekpo-ebelp.
*If any text already exits.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = v_thead-tdid
language = sy-langu
name = v_thead-tdname
object = v_thead-tdobject
TABLES
lines = t_it_tline_r
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.
LOOP AT t_it_tline_r INTO wa_tline_r.
IF NOT wa_tline_r-tdline CS v_tline-tdline AND
wa_tline_r-tdline NE space.
APPEND wa_tline_r TO t_it_tline.
ENDIF.
ENDLOOP.
* CALL FUNCTION 'DELETE_TEXT'
* EXPORTING
* id = v_thead-tdid
* language = sy-langu
* name = v_thead-tdname
* object = v_thead-tdobject
* EXCEPTIONS
* not_found = 0
* OTHERS = 0.
* IF sy-subrc NE 0.
* ENDIF.
ENDIF.
*----- Now append the customer material part number to existing text.
v_tline-tdformat = '*'.
APPEND v_tline TO t_it_tline.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = v_thead
TABLES
lines = t_it_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = 'EKPO'
name = '*'
id = 'F01'
language = sy-langu
savemode_direct = 'X'
IMPORTING
commit_count = cc
TABLES
t_object = t_object
t_name = t_name
t_id = t_id
t_language = t_language.
IF sy-subrc EQ 0.
* MESSAGE s000(zm01) WITH text-m01.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
Edited by: Thomas Zloch on Oct 19, 2010 2:31 PM * please use tags!
10-19-2010 12:28 PM
In debug, where does error occur? An additional point, I think you have to do the delete step.
10-19-2010 12:28 PM
Hi,
dont pass sy-langu to language parameter tdspras. Check the document 4500000905 and item 00001 item text language .
I am sure it is not EN as your login language.
I hope you know how to check the item text tdid , tdname, tdobject and tdspras.
Thanks,
subash