Hello everyone,
I'm trying to better understand how to dynamically update the long text in transaction CC02 from a custom program. I have debugged through CC02 and found that it uses SAVE_TEXT and COMMIT_TEXT so I too, have tried the same.
What I've found is that as long as a Change Header Long Text was created first in CC02, the code below works successfully without issue, and is reflected when I go into CC02 - I can see my changes.
On the other hand, if the Change Header Long Text was not already created, and I create it for the first time, this text is stored and I can successfully read it using READ_TEXT Function Modules. However CC02 does not show this saved text. Therefore, any changes made in CC02 will then overwrite my changes made in my custom program.
I have explored the INSERT parameter of SAVE_TEXT, and pass an X if the Change Header Long Text does not already exist (Determined using READ_TEXT). However, this did not seem to yield any success.
Can anyone explain why this works correctly when it is already created, but does not work correctly if I am creating the long text for the first time in my program?
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = lwa_thead
savemode_direct = c_x
* insert = i_new_longtxt
TABLES
lines = lwa_ltext_tmp
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc = 0.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = lwa_thead-tdobject
name = lwa_thead-tdname
id = lwa_thead-tdid
language = s_lang
IMPORTING
commit_count = iv_updated_texts.
ENDIF.
Useful hints or tips will be rewarded! Thank you!