Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAVE_TEXT function

Former Member
0 Likes
1,845

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.

8 REPLIES 8
Read only

Former Member
0 Likes
1,605

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.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,605

The SAVEMODE_DIRECT parameter of this FM should help you.

Read only

0 Likes
1,605

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

Read only

0 Likes
1,605

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).

Read only

0 Likes
1,605

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.

Read only

0 Likes
1,605

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.

Read only

0 Likes
1,605

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....

Read only

Former Member
0 Likes
1,605

This message was moderated.