Application Development 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: 

Function SAVE_TEXT in transaction VA01

0 Kudos

Hi gurus,

     i have a requirement to add a new text in sales order header when saving the document (transaction VA01). I use the SAVE_DOCUMENT userexit in program MV45AFZZ to do this. I loop at xvbap table and retrieve some texts in a Z table to fill the 'IT_LINES' required by the function 'SAVE_TEXT'. It works fine if I don't type anything directly on the text before saving (id 0001, object VBBK). But if something is inputed on the text during sales order creation, I lost the texts I have in the Z table, the only text saved is the text I inputed manually. Curiously, if I call transaction VA02 to change the sales order ( I have to change at least one field, like customer purchase order number), then all texts are saved. I have tried several different options with many functions related to text as SAVE_TEXT, INIT_TEXT, READ_TEXT, DELETE_TEXT and CREATE_TEXT bu with no success. The last code I have is:

if not it_lines[] is initial.

   call function 'SAVE_TEXT'

   exporting

   header                   = st_thead

   save_mode_direct = 'X'

tables

    lines                     = it_lines

exceptions

   bla bla bla

endif.

Does anyone have a suggestion that may help me?

Thanks in advance.

Paulo Café.

7 REPLIES 7

FredericGirod
Active Contributor
0 Kudos

Hi,

did you try code like this to check if text have been updated :

* Read the old text (before saving)

  DATA:  BEGIN OF STXL_ID,

           TDOBJECT LIKE STXL-TDOBJECT,

           TDNAME   LIKE STXL-TDNAME,

           TDID     LIKE STXL-TDID,

           TDSPRAS  LIKE STXL-TDSPRAS,

         END OF STXL_ID.

  STXL_ID-TDOBJECT = STXH-TDOBJECT.

  STXL_ID-TDNAME   = STXH-TDNAME.

  STXL_ID-TDID     = STXH-TDID.

  STXL_ID-TDSPRAS  = STXH-TDSPRAS.

  IMPORT TLINE TO T_OLD_LINES

    FROM DATABASE STXL(TX)

         CLIENT   SY-MANDT

         ID       STXL_ID.

regards

Fred

0 Kudos

Hi Frédéric,

    thanks for you reply.

    I have tried your sugestion but it didn't work. The time we create the sales order, this command doesn't retrive anything.

    I use the READ_TEXT function to do this, and it works fine, getting the text I typed manually. But, as I said,, the Z texts are lost.after saving the order. The system keeps the text I typed, but not the complemente (my Z text wich i added to the existing text).

   Regards,

Paulo Café

Former Member
0 Kudos

Hi Paulo,

I guess first you have to read out all the text using READ_TEXT , then append your internal table with new text , use EDIT_TEXT and last SAVE_TEXT.

Hope this works.

Regards,

Deepti

0 Kudos

Hi Deepti,

    i do exactly as you said (and  many other variants...) but it really doesn't work during creation. As I said before, if i change the order, then all texts are saved.

   Thanks for you help.

Paulo Café

0 Kudos

Hi Paulo,

Did you fix the issue? I have tried to create order and replicate the scenario what you have mentioned.

At the time of order creation, you will not get text name so either you need to use XTHEAD internal table as this table has all the text or you need to create implicit enhancement in routine MV45AF0B_BELEG_SICHERN after FM sd_commit_text as this FM is called after all user exits and at this point you have sales order number available to pass in TDNAME.

regards,

Deepti

0 Kudos

Hi Deepti,

    I took another way to solve the problem and gave up saving all texts in one text ID. The Z texts are now saved in other text ID and this worked fine for my purposes.

   Thanks for you help.

   Regards,

Paulo Café

0 Kudos

ok, great..good to know that Issue has been fixed.

Regards,

Deepti