‎2007 Oct 17 4:08 PM
Hi,
How can I compare the old value of an item note (Text tab) with the new value item note at MV45AFZZ method USEREXIT_SAVE_DOCUMENT_PREPARE? I always get the new one (using READ_TEXT).
For example. Sales order number 0005000001 is created. It has one position (000010) and its text item (item note) is HELLO.
Using VA02 I modify the text item (item note) of the sales order 0005000001 / position 000010 as GOODBYE.
When the following code is executed at user exit MV45AFZZ method USEREXIT_SAVE_DOCUMENT_PREPARE:
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = '0002'
LANGUAGE = SY-LANGU
NAME = 0005000001000010
OBJECT = 'VBBP'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
LINES table contains "GOODBYE".
I dont know how I can get the old value (HELLO), and I dont understand why I get GOODBYE, because the new value has not been stored yet (commit comes later).
Thanks in advance,
Ricard.
‎2007 Oct 17 4:14 PM
Hello
I think you get goodbye because that text is modified before the user exit activates...so if you try to get "hello2, you will not be able to get it because is already modified.
Bye
Gabriel
‎2007 Oct 17 4:50 PM
Hello Gabriel,
The documentation of MV45AFZZ explains:
USEREXIT_SAVE_DOCUMENT_PREPARE
Use this user exit to make certain changes or checks immediately before saving a document. It is the last possibility for changing or checking a document before posting.
The user exit is carried out at the beginning of the FORM routine BELEG_SICHERN.
I think the value is still no changed....
Thanks,
Ricard.
‎2007 Oct 17 5:30 PM
Hello Oscar,
Is the code you wrote before inside the user Exit?....check it....you are getting the text with READ_TEXT and getting goodbye....it seems to be already modied...
Try this....just for testing:
Go to yout tcode and change the text but dont save....
Go to SE37 and execute READ_TEXT FM.....what do you get....is it modified?
Bye
gabriel
‎2007 Oct 18 7:55 AM
Hello Gabriel,
I have set a breakpoint when the function (READ_TEXT) is called into the user exit. When the flow has stopped, I executed READ_TEXT (in another session tx-se37). Results found:
READ_TEXT of the user-exit returns GOODBYE.
READ_TEXT of the function returns HELLO.
Both are executed at the same time. I think the problem is that the READ_TEXT function of the user-exit is called in transaction (and then returns the uncommitted modification).
How can I execute READ_TEXT into the user-exit outside the transaction?
Thanks in advance,
Ricard.
‎2007 Oct 18 1:22 PM
Hello Ricard,
This seems to be a strange behavior....I have never use it...but try to use this stament:
CALL FUNCTION - IN UPDATE TASK
Maybe will work....Im not sure....but give it a try!!
Bye
Gabriel
‎2007 Oct 19 11:22 AM
Hello Gabriel,
I have found the solution. To get the texts entered by the user (and still uncommitted) I use the READ_TEXT function. To get the texts from the database:
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.
.
. Fill stxl_id fields with the same values used in READ_TEXT function
import tline to lines_bd
from database stxl(tx)
client SY-MANDT
id stxl_id
IGNORING CONVERSION ERRORS.
Finally, I have implemented this code in the USEREXIT_SAVE_DOCUMENT method of MV45AFZZ user exit (presentation behaviour, nothing related with this issue).
Thanks you for your help,
Ricard.