2023 Oct 18 10:51 AM
Hi together,
I am trying to save a text in the user exit: USEREXIT_SAVE_DOCUMENT. The requirement is after saving an order, a text should be automatically filled in the text part of the order. Now I am having the issue that with save text, the text is not being saved. The text ID, Object and Name are all correct. Does anyone know, why the text is not being saved or can I do it into another user exit? The standard transaction that I am using is VA41.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
* CLIENT = SY-MANDT
header = ls_header
insert = 'X'
* SAVEMODE_DIRECT = ' '
* OWNER_SPECIFIED = ' '
* LOCAL_CAT = ' '
* KEEP_LAST_CHANGED = ' '
* IMPORTING
* FUNCTION =
* NEWHEADER =
TABLES
lines = lt_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Thank you,
R
2023 Oct 18 11:23 AM
2023 Oct 18 11:52 AM
Hi @3a9e4ce873a94034b33dc62b0ce600ee, I thought about that, but if I am not wrong, we are not allowed to do savemode_direct = 'X' or commit work in a user exit, as it may lead to data inconsistency.
2023 Oct 18 12:41 PM
2023 Oct 18 1:00 PM
Hi tk_gerald If you don't want ot use SAVEMODE_DIRECT = X, call COMMIT_TEXT after SAVE_TEXT. Despite the name COMMIT_TEXT doesn't issue COMMIT WORK. You can test that with test sequences in SE37. This sequence doesn't really persists text changes:
However this one does:
2023 Oct 18 1:05 PM
As a rule don't use in SD the USEREXIT_SAVE_DOCUMENT for this kind of purpose, it's too late for the current document. Use USEREXIT_SAVE_DOCUMENT_PREPARE.
2023 Oct 18 1:10 PM
Hi @raymond.giuseppi, the issue with USEREXIT_SAVE_DOCUMENT_PREPARE, is that I need the vbeln for the tdname of the text. Thus I cannot use this userexit, as on the prepare user exit, the vbeln number is not yet created.
2023 Oct 18 1:22 PM
Debug the transaction in the PREPARE form, look for the in memory text catalog to replicate the way SAP store long text before SAVE (Look at a FM such as GET_TEXT_MEMORY or MEMORY ID 'SAPLSTXD')
Look also at content of table XTHEAD in the exit.
2023 Oct 18 1:31 PM
2023 Oct 18 1:33 PM
Hi tk_gerald One more comment SAVEMODE_DIRECT = X persists texts with EXPORT TO DATABASE, class CL_RSTX_TABLE_VIEW, method CHANGE_ALL:
export tline from i_text_lines
to database stxl(tx) "#EC DBACCESS_OK
client l_stxh-mandt
id l_stxl_id.
As per SAP documentation to EXPORT TO DATABASE
If DATABASE is specified, the data cluster with the ID id is stored in the database table dbtab and committed by the next database commit.
EXPORT TO DATABASE doesn't execute commit by itself. So it should be save to use SAVEMODE_DIRECT = X in the user-exit.
2023 Oct 18 3:20 PM
2023 Oct 20 1:46 PM
Hi @3a9e4ce873a94034b33dc62b0ce600ee, thanks for your help, yes, I used the commit_text 🙂