04-06-2016 9:33 AM
Hello ABAP friends,
at the moment i am trying to create a longtext via an user exit after entering an action. This shall be done in transaction IW21, IW22 which is creation and changing PM notifications! But this is minor.
In fact i want to read longtext from the catalog and post it to the actual action of the PM notification as default values.
The long text of the catalog is read by the FM READ_TEXT which is working quite well. After that i want to store the longtext to the action but i have to consider two things:
1. Text shall be inserted and readable after clicking the longtext button
2. Text shall only be saved when user pushes Save button of the transaction (when DB commit is done)
Now here comes my problem. When doing this i tried using FM SAVE_TEXT and COMMIT_TEXT which is working quite good for transaction IW22. So for an already existing document its no problem to store the longtext.
When i try to do this for an not posted document, the text is not stored wether in text memory nor in the database table STXH. What am i doing wrong. The key for the text is built with the temporary notification number %00000000001 and the counter of the action.
I think i am not getting how this SAP Script thing is working. Did anybody had a similar problem or can anyone figgure out what am i doing wrong! How is SAP handling temporary longtext while creating documents?
In my opinion and in my understanding i have to call SAVE_TEXT to store the text into ABAP memory and after that i have to call COMMIT_TEXT to create and posting job for the update programm that will then finally commit the text while leaving transactions.
I don't know what do to please give me some hints, how this whole SAP Script longtext thing is working!
Thank you in advance!
Greetings
Tobi wan Kenobi
04-06-2016 5:10 PM
You should do some more debug. IW21 registers a PERFORM TEXT_UPDATE_F00 ON COMMIT if the user has entered a text and executes it at the save time.
The form is executed during the COMMIT WORK. It renames the long text (function module RENAME_TEXT) and do a COMMIT_TEXT to save it to database.
If the user didn't enter any text, the *_TEXT function modules are not called.
You need to make sure when the user exit (which one?) is called, before or after the standard renaming.
Message was edited by: Sandra Rossi (little clarification)
04-12-2016 10:17 AM
Hello Sandra,
the user EXIT is called while creating actions. it is defined as preassigning maintenance notification actions with default values! User Exit is EXIT_SAPMIWO0_021!
I did some further debugging alreade and i handled to make the text displayable after performing user exit. So when you hit longtext button the default is displayed.
The problem is that INIT_TEXT was called and cleared the text i created with SAVE_TEXT in the user exit depending on ABAP Memory parameter.
When export ITX1 is filled with the text header of the new created text xou can display it. So i think i am missing some registration for this transaction at any point. I can fill it manually, but the text also will not be stored to database with the new message number.
So maybe the form you mentioned is not called! But i can't figure out why!?!
Source coude:
Data: LT_lines type STANDARD TABLE OF TLINE,
l_text_name TYPE TDOBNAME,
ls_header TYPE THEAD,
l_function type char1.
DATA: BEGIN OF LTXHEAD OCCURS 25. "Langtext-Köpfe
INCLUDE STRUCTURE THEAD. "Kopf
DATA: TXT_REF LIKE EQKT-KZLTX. "Text nach Referenz o.k.
DATA: PROPERTY TYPE C. "No Changes to Existing Long Text
DATA: END OF LTXHEAD.
"commit_text variables
data: l_count type SY-INDEX,
L_1 TYPE STANDARD TABLE OF STXDROBJ,
L_2 TYPE STANDARD TABLE OF STXDRNAME,
L_3 TYPE STANDARD TABLE OF STXDRID,
L_4 TYPE STANDARD TABLE OF STXDRLANG.
l_text_name+0(3) = sy-mandt.
l_text_name+3(1) = 2. "katalog maßnahmen indikator
l_text_name+4(8) = I_VIQMSM-MNGRP.
l_text_name+12(4) = I_VIQMSM-MNCOD.
l_text_name+16(6) = '000001'. "vermutlich tdversion!!! "this could variate
l_text_name+22(1) = sy-langu.
"1. Read notification longtext
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = 'QPCT' "Codelangtext
LANGUAGE = sy-langu
NAME = l_text_name
OBJECT = 'QKATALOG'
IMPORTING
HEADER = ls_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 = 4.
RETURN.
ELSEIF sy-SUBRC <> 0.
MESSAGE id sy-MSGID TYPE sy-MSGTY number sy-MSGNO with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"this is only working for IW22
if sy-TCODE = 'IW22'.
"2. Set_values for new txt header to set the notification action text
ls_header-TDOBJECT = 'QMSM'.
clear ls_header-tdname.
ls_header-tdname+0(12) = I_VIQMEL-QMNUM.
ls_header-tdname+12(4) = I_VIQMSM-MANUM.
ls_header-tdid = 'LTXT'.
ls_header-TDFUSER = sy-UNAME.
*clear: ls_header-tdfreles." , ls_header-TDVERSION.
ls_header-TDFDATE = sy-datum.
ls_header-TDFTIME = sy-UZEIT.
ls_header-TDLUSER = sy-UNAME.
ls_header-TDLTIME = sy-UZEIT.
ls_header-TDVERSION = 1.
"3. commit notification action text
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
* INSERT =
SAVEMODE_DIRECT = ABAP_FALSE
HEADER = ls_header
IMPORTING
FUNCTION = l_function " Sicherung-Status
NEWHEADER = ls_header
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.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
OBJECT = ls_header-TDOBJECT
NAME = ls_header-TDNAME
ID = ls_header-tdid
LANGUAGE = Sy-LANGU
* SAVEMODE_DIRECT = ' '
KEEP = ABAP_TRUE
* LOCAL_CAT = ' '
IMPORTING
COMMIT_COUNT = l_count
TABLES
T_OBJECT = L_1
T_NAME = L_2
T_ID = L_3
T_LANGUAGE = L_4.
"3. Set longtext flag Kennzeichen setzen wenn erfolgreich!
E_VIQMSM-INDTX = ABAP_TRUE.
else.
"2. Set_values for new txt header to set the notification action text
ls_header-TDOBJECT = 'QMSM'.
clear ls_header-tdname.
ls_header-tdname+0(12) = I_VIQMEL-QMNUM.
ls_header-tdname+12(4) = I_VIQMSM-MANUM.
ls_header-tdid = 'LTXT'.
ls_header-TDFUSER = sy-UNAME.
clear: ls_header-tdfreles, ls_header-TDVERSION.
ls_header-TDFDATE = sy-datum.
ls_header-TDFTIME = sy-UZEIT.
ls_header-TDLUSER = sy-UNAME.
ls_header-TDLTIME = sy-UZEIT.
ls_header-TDVERSION = 1.
"here try the other thiiiing
"3. commit notification action text
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
* INSERT =
SAVEMODE_DIRECT = ABAP_FALSE
HEADER = ls_header
IMPORTING
FUNCTION = l_function " Sicherung-Status
NEWHEADER = ls_header
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.
MOVE-CORRESPONDING ls_header to LTXHEAD.
append LTXHEAD to LTXHEAD.
export LTXHEAD to MEMORY id 'ITX1'.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
OBJECT = ls_header-TDOBJECT
NAME = ls_header-TDNAME
ID = ls_header-tdid
LANGUAGE = Sy-LANGU
SAVEMODE_DIRECT = ABAP_TRUE
* LOCAL_CAT = ' '
IMPORTING
COMMIT_COUNT = l_count
TABLES
T_OBJECT = L_1
T_NAME = L_2
T_ID = L_3
T_LANGUAGE = L_4.
"3. Set longtext flag Kennzeichen
E_VIQMSM-INDTX = ABAP_TRUE.
endif.