2007 Aug 24 7:44 AM
Hi
I am using following function modules to change line item text of PO
This works perfectly for already generated PO. But it is giving error while creating new PO as
" Text not available in database or update memory. Use INIT_TEXT & SAVE_TEXT "
Pls. give me solution as this is very urgent.
DATA : l_name LIKE thead-tdname,
l_header TYPE thead,
lt_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
LOOP AT it_ekpo INTO wa_ekpo.
CLEAR : lt_lines[], lt_lines, l_header, l_name.
CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO l_name.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'F01'
language = 'E'
name = l_name
object = 'EKPO'
IMPORTING
header = l_header
TABLES
lines = lt_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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CHECK lt_lines[] IS NOT INITIAL.
READ TABLE lt_lines WITH KEY tdformat = '*'.
CHECK sy-subrc <> 0.
lt_lines-tdformat = '*'.
MODIFY lt_lines transporting tdformat where tdformat eq space.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = l_header
INSERT = ' '
savemode_direct = 'X'
OWNER_SPECIFIED = ' '
LOCAL_CAT = ' '
IMPORTING
FUNCTION =
NEWHEADER =
TABLES
lines = lt_lines
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.
ENDLOOP.
Regards
Harshada
2007 Aug 24 7:47 AM
READ_TEXT needs to be used, if the data is already stored in EKPO. During PO creation, its not stored & hence the error.
But a logic of check the tcode.
IF sy-tcode = ... "PO change
READ TEXT
SAVE TEXT
else if sy-tcode = .... "PO Creation
SAVE TEXT
ENDIF.
2007 Aug 24 7:47 AM
Hi !
After SAVE_TEXT you'll have to call the FM COMMIT_TEXT.
Otherwise the text is not written to the database !
... Not to forget a COMMIT WORK after that !
Regards
rainer
Some points would be nice
2007 Aug 24 8:04 AM
2007 Aug 24 7:47 AM
READ_TEXT needs to be used, if the data is already stored in EKPO. During PO creation, its not stored & hence the error.
But a logic of check the tcode.
IF sy-tcode = ... "PO change
READ TEXT
SAVE TEXT
else if sy-tcode = .... "PO Creation
SAVE TEXT
ENDIF.
2007 Aug 24 8:05 AM
2007 Aug 24 8:11 AM
as per ur logic
if i use read_text only if ekpo is not initail
then wht should i pass to parameter
<b>tables</b> in save_text
b'coz the table lines to be updated are coming from read_text.
pls. reply
2007 Aug 24 8:16 AM
well, if you have nothing read, since EKPO was initial, what would you like to save then?
In your logic it makes no sense to save a text without having read one before.
2007 Aug 24 9:56 AM
Thanks all of you for the reply.
I got solution for this problem.
Now calling funtion modules only if ekpo-ebeln is not initail (PO not created)