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: 

Changing sales item texts in userexit_save_document

former_member186741
Active Contributor
0 Kudos

Hi Learned folk,

the problem I have concerns a particular type of sales order item text which we wish to use to store text in addition to any entered by the user on VA01.

In sapmv45a userexit_save_document I have put a call to function module read_text to get the current text lines and then added my extra line and used save_text to apply the cahnges.

In debug I can see that save_text is dealing with the extra data, it does an 'úpdate' on STXH to indicate that there are the same number of lines in the text that I expect and then it does an 'éxport' to database STXL(TX) to send the text lines themselves. All the data I want is being exported. These commands are executed with 0 subrc. Shortly after leaving the exit the 'commit' occurs but tables STXH and STXL now have values consistent with how they were before my changed text lines were added. VA03 also shows that my additional text is not present.

The only thing that I can think is that another use of save_text is occurring somewhere between the user exit and the commit but I haven't been able to find it yet.

Does anybody have any other ideas why the text changes are not being retained?

Regards

Neil

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Neil,

1. U said u have used SAVE_TEXT

and it saves.

2. To check if this happens or not,

After that write COMMIT Work.

3. In DEBUG mode,

execute till the FM and COMMIT Work,

4. In another session,

see the table STXH

to know whether it REALLY Gets

updated or not!

regards,

amit m.

16 REPLIES 16

Former Member
0 Kudos

Hi,

Can I see your code.

With Regards,

Nelson

0 Kudos

sorry, Nelson but I am away from SAP at the moment and can't post the code.

former_member188685
Active Contributor
0 Kudos

Hi,

you can do this include <b>MV45AFZZ</b>

and user_exit_save_document form ,

and save the text using save_text.

regards

vijay

0 Kudos

as I wrote, I am already using userexit_save_document and using save_text. Please read the problem and answer if you think you can help.

Former Member
0 Kudos

Hi Neil,

1. U said u have used SAVE_TEXT

and it saves.

2. To check if this happens or not,

After that write COMMIT Work.

3. In DEBUG mode,

execute till the FM and COMMIT Work,

4. In another session,

see the table STXH

to know whether it REALLY Gets

updated or not!

regards,

amit m.

0 Kudos

Hi Amit,

thanks but I have already done as you said and found that immediately the commit happens that the 'óriginal' text values are being saved in stxh and stxl. I can see that the update is not happening as I expect but can't understand why not.

0 Kudos

Hi Neil,

Did you try the FM COMMIT_TEXT??See if it is of any use to you.

REgards,

Ravi

former_member186741
Active Contributor
0 Kudos

anybody else out there in the current timezone got any ideas about this one?

Former Member
0 Kudos

How are you reading the text using READ_TEXT in VA01 when the texts are not yet committed? Or did I read it wrong?

User enters item texts in VA01.

User saves it.

User exit USER_EXIT_SAVE_DOCUMENT is triggered.

You read the existing lines (which are still in the memory?).

You add some more lines.

You use SAVE_TEXT to save the texts.

Is this flow correct so far?

I think your changes are getting overwritten by SAP's call to the same function module.

Srinivas

0 Kudos

Please check if this will work.

Transaction VOTXN. Select the radiobutton for 'Sales Document -- Item'.

Click on change.

Select the text procedure in the subsequent screen and double click on 'Text IDs in the text procedure' in left pane.

Identify your text id and see what the access sequence is.

Again in the left pane, double click on 'Access Sequence for text id and enter the access sequence you found above.

In the next screen, in the access sequence table control on the right side, scroll to the column 'DatTr'. Here you can enter a number and write your own code. Read the documentation for that field. If not you may also use the 'Requirement' column.

Srinivas

0 Kudos

I did something in the past that was similar, but far from exactly the same.

I had to follow specific steps...

READ_TEXT (and keep the lines in the internal table)

DELETE_TEXT

INIT_TEXT

add additional lines to the data from READ_TEXT

SAVE_TEXT

I also remember having to set the SAVEMODE_DIRECT parameter to 'X'.

The DELETE_TEXT has a parameter for TEXTMEMORY_ONLY, but I think I took the default of ' '. I no longer have the code.

Not sure if this would work in your scenario. From your description, it sounds like your text is overwritten by the text captured before the user exit is triggered. Perhaps the DELETE_TEXT or INIT_TEXT would clear this memory area.

0 Kudos

I was a little worried because I have a similar requirement that I will need to implement in the coming weeks, and I played around and thought that I would just need to call SAVE_TEXT. After reading this thread I did some more playing around and Norman is right. You just need to set the SAVEMODE_DIRECT parameter of the SAVE_TEXT FM to 'X'.

0 Kudos

thankyou all for your suggestions. I have played around with a few of them and it's still not working but I think I'm not far away from cracking it. I'm working on something else at the moment but will have another go early next week.

Thanks.

Neil

0 Kudos

I wonder if you should try it in USEREXIT_SAVE_DOCUMENT_PREPARE instead of USEREXIT_SAVE_DOCUMENT.

I think the first happens before database updates.

I think the second happens after the database updates, but before the commit.

It might be worth a try if you can just cut and paste your code.

0 Kudos

Hi Norman,

unfortunately I can't use the prepare exit as the texts are supposed to reflect an existing popup which is currently produced in save_document.

Thanks and I'll let you know how I go next week.

0 Kudos

in the end the 'save_text' with direct_update set to 'X' worked. The slight complication was that if the text did not already exist (usually at create time in VA01) I had to also call 'init_text' immediately before calling 'save_text'.

Thanks for your contributions.