‎2012 Feb 09 1:17 PM
Hello all.
I have a problem regarding the save_text function.
If, for an outbound delivery, in the header, texts tab i have more than one text for the shipping instruction, English and German for example and in an user exit i am trying to modify the text for English (add a new text and also keep the old one) function SAVE_TEXT + COMMIT_TEXT does not save anything.
I have noticed that if you delete one of the shipping instructions texts, German for example, the english text is updated, otherwise no update.
Did someone encounter this behaviour before ?
Regards,
Cristian.
‎2012 Feb 09 11:17 PM
Hi Cris,
This FM is not a very reliable one, although if you wish to use , you should write a commit work (BAPI_TRANSACTION_COMMIT). To check it best idea will be create a program in SE38 call this FM with some default values, and then CALL BAPI_TRANNSACTION_COMMIT this will work.
Best Regards,
Tapodipta Khan.
‎2012 Feb 09 11:47 PM
‎2012 Feb 10 8:29 AM
Hello.
This is the code:
*** shipping instructions ***
ls_head-tdid = '0012'.
ls_head-tdspras = ls_kna1-spras.
ls_head-tdname = likp-vbeln.
ls_head-tdobject = 'VBBK'.
ls_head-tdform = 'SYSTEM'.
ls_head-tdlinesize = 72.
CLEAR: lt_lines[],
ls_lines.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = ls_head-tdid
language = ls_head-tdspras
name = ls_head-tdname
object = ls_head-tdobject
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.
CASE sy-subrc.
WHEN 4.
ls_lines-tdformat = '*'.
ls_lines-tdline = lv_text.
APPEND ls_lines TO lt_lines.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ls_head
insert = 'X'
TABLES
lines = lt_lines[].
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = ls_head-tdobject
name = ls_head-tdname
id = ls_head-tdid
language = ls_head-tdspras
savemode_direct = 'X'.
WHEN 0.
READ TABLE lt_lines INTO ls_lines WITH KEY tdline = lv_text.
IF sy-subrc NE 0.
ls_lines-tdformat = '*'.
ls_lines-tdline = lv_text.
APPEND ls_lines TO lt_lines.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ls_head
* insert =
TABLES
lines = lt_lines[].
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = ls_head-tdobject
name = ls_head-tdname
id = ls_head-tdid
language = ls_head-tdspras
savemode_direct = 'X'.
ENDIF.
ENDCASE.
ENDIF.
If the code would be wrong, i suppose the update should not work even if i have only one language in the shipping instruction. But it works for one language, not working for more than one.
Edited by: Cristian Boartes on Feb 10, 2012 9:29 AM
‎2012 Feb 10 10:06 AM
Hi,
By using this code, I am able to update the text for which both languages values are already maintained in the delivery header for that text id.
WHEN 0.
READ TABLE lt_lines INTO ls_lines WITH KEY tdline = lv_text.
IF sy-subrc NE 0.
Please check whether the value in lv_text is already available in intenal table lt_lines (Already that value is maintained in the text id for that language).
‎2012 Feb 10 1:20 PM
Thats allready done, it checks if the text is allready in.
If sy-subrc ne 0 then it will add another line to the lt_lines table and it will be processed by SAVE_TEXT function.
The problem is that the code runs, no errors are given but i dont find the text.
‎2012 Feb 10 1:45 PM
Hi,
Try creating a Z program with the same code and hardcoding the ls_head-tdspras & ls_head-tdname. Put a value "TEST' in variable lv_text.
Now for a delivery where initialy there is no value maintained for the text id, execute the program with 'EN' language and also execute with 'DE' language. Now two values will be created for the text id in the delivery one with EN language and another with DE language with the same value "TEST".
Now change the value of lv_text to "TESTING" and execute the program with EN language. Now the new value TESTING will be updated along with the value TEST in the delivery header text.
I was able to execute this scenario with your code.
‎2012 Feb 10 2:44 PM
Hello.
You are right, it should work as there is no rocket science for this code but the problem is that in the user exit is not working and i have no clue why in a Z program it works and in the user exit it does not....
‎2012 Feb 10 4:53 AM