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

write on database not committed

Former Member
0 Likes
3,097

Hi all

I am working on a exit of a transaction at save moment.

the problem is this: data has already sent to database, but commit is not yet done. So if I try to modify data in program, modifies are ignored because the modify is not sent. If I try to search data in database, I cannot find them because commit has not yet executed.

I cannot do a commit because I don't know the impact of a commit in this exit in case of error on the rest of the transaction.

Any hint is welcome.

Regards

Gabriele

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,748

Hi Gabriele,

do i right understand you, you want to access data which you send to database and haven't written to database?

Right?

The idea is to build a seperate program which writes the data to database. This program is called through the first program via job. This means the second runs in a separate LUV. After the job is finished the data is accessible in the first program. The only thing you have to ensure, the first program has to wait for the second one.

regards,

W.

18 REPLIES 18
Read only

Former Member
0 Likes
2,748

Please provide exit name and tcode that you are referring to

Read only

0 Likes
2,748

Hi

the transaction is VA01 (02 03) and there is no suitable exit for save: googling and searching on the sdn it seems that modifying FORM USEREXIT_SAVE_DOCUMENT of V45AFZZ is the only way.

Thanks

Gabriele

Read only

Former Member
0 Likes
2,749

Hi Gabriele,

do i right understand you, you want to access data which you send to database and haven't written to database?

Right?

The idea is to build a seperate program which writes the data to database. This program is called through the first program via job. This means the second runs in a separate LUV. After the job is finished the data is accessible in the first program. The only thing you have to ensure, the first program has to wait for the second one.

regards,

W.

Read only

0 Likes
2,748

yes

you understand correctly, but the problem is that the write on database, is not made by me, but by the VA01 code (don't know where). I would like to modify data sent to database by VA01 before commit. This is the timeline:

VA01 insert/update data on db (not committed)

the user exit I can handle <----


here data have been sent so modify internal table has no effect

VA01 retrieve control

(VA01 operations)

COMMIT

data here are present in DB

I am pretty sure of this, because if I insert a COMMIT in exit, I find data on db, but I cannot COMMIT in this way ... the VA01 decides if commit ...

Read only

0 Likes
2,748

I am not sure of your requirement. But to update data in this exit, you have to update corresponding internal tables available during run time. For eg: tables like xvbap, xvbuv, hvbuv.... are available.

Put a break point inside this form and check for the required internal table and carryout the changes.

Read only

0 Likes
2,748

I have already did it:

if I set for example a data in VBAP, data are not carried out to db because UPDATE OF VBAP has already be done BEFORE the form I am working is called. And data are not present on db yet because no commit has been done.

I don't know if a solution exists .. what I need is something allowing me to modify data sent to db before commit, but I don't know if abap/sap has visibility of this data and only dbms has visibility..

Read only

0 Likes
2,748

Hi Gabriele,

The exit your are using is meant for you to make some last minute changes to the data in the internal tables available to you in this exit. At this point in the program no data has been commited to the DB. This done by the function RV_SALES_DOCUMENT_UPDATE which is triggered after this exit.

So any changes you want to pass on to the DB should be done at this point.

Also never trigger your own explicit commit work in an user-exit as this will mess up your LUW and can result in DB inconsistencies...

Regards,

Robert

Read only

0 Likes
2,748

I suggest you to try to modify any data: I did not say that COMMIT has been done. I know it is not done because data are not present on db (putting a breakpoint on save form I watch se16 to see if data were present). But anyway data has already been sent to database: the proof is that changing any data, the change is not written on db. For example, if in this form i change the value of VBKD-BSTKD, the change is not saved. Why? I think because WRITE DB command has been given before (and COMMIT has not been given) and data has been sent to db BEFORE I can modify them in this form. So the problem remains: how to change data already sent to database but not yet committed?

Read only

0 Likes
2,748

Be aware that in VA01/VA02 SAP uses internal tables like XVBKD and YVBKD, XVBAP and YVBAP.

The X-versions are the ones actually used for the updates. So if you want to make a change in VBKD, update the corresponding entry in internal table XVBKD.

And as a rule: never use COMMIT in a user-exit/BADI/enhancement point.

Read only

0 Likes
2,748

No way: I already tried to change XVBKD YVBKD and also *VBKD ...

I know that I cannot commit in a exit, otherwise this post would not exist

Read only

0 Likes
2,748

for precision I try to change value in

CVBKD-BSTKD
SVBKD-BSTKD
HVBKD-BSTKD
*HVBKD-BSTKD
KVBKD-BSTKD
*KVBKD-BSTKD
NA_VBKD-BSTKD
VBKD-BSTKD
YVBKD-BSTKD
XVBKD-BSTKD
*VBKD-BSTKD

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,748

Hello,

I would rather use the BAdI BADI_SD_SALES instead of the user-exit. Beacuse the interface parameters are defined & you know which params you would be working with.

The method of interest for you would be SAVE_DOCUMENT.

BR,

Suhas

Read only

0 Likes
2,748

I think, you are using the wrong user exit, You should modify the data in user exit MV45AFZZ, form-routine "USEREXIT_SAVE_DOCUMENT_PREPARE" which is called just before saving the data. Changes made to the structures/internal tables in "USEREXIT_SAVE_DOCUMENT" will not have any effect while writing to DB.

Read only

0 Likes
2,748

Hi Gabriele,

But did you, like Maen Anachronos suggested, mark the corresponding field in the X-structure with an ' X'? Just trying to rule out possibilities.

Good luck with your problem!

Guus

Read only

0 Likes
2,748

Hi Gabriele,

Please read the SAP help documentation for this exit.

[User Exits In Sales Document Processing|http://help.sap.com/saphelp_46c/helpdata/en/1c/f62c7dd435d1118b3f0060b03ca329/content.htm]

Check if maybe the USEREXIT_MOVE_FIELD_TO_VBAK, USEREXIT_MOVE_FIELD_TO_VBAP, etc. work for your requirements.

Regards,

Robert

PS. Another thing is to verify that the UPDKZ field is set in the internal table in question.

PPS. In case you turn on update debugging you will be able to debug the update routine (RV_SALES_DOCUMENT_UPDATE ) to determine where your value is being "lost".

Read only

0 Likes
2,748

Hi Gabriele,

very praiseworthy that you already asked google and sdn. Another sueful source is SAP online documentation for [User Exits In Sales Document Processing|http://help.sap.com/saphelp_46c/helpdata/en/1c/f62c7dd435d1118b3f0060b03ca329/content.htm]

I wonder if this won't help:

USEREXIT_MOVE_FIELD_TO_VBKD

Use this user exit to assign values to new fields for business data of the sales document. It is described in the section ["Copy customer master fields into sales document" .|http://help.sap.com/saphelp_46c/helpdata/en/08/f62c7dd435d1118b3f0060b03ca329/content.htm]

The user exit is called up at the end of the FORM routine VBKD_FUELLEN.

USEREXIT_SAVE_DOCUMENT_PREPARE

Use this user exit to make certain changes or checks immediately before saving a document. It is the last possibility for changing or checking a document before posting.

The user exit is carried out at the beginning of the FORM routine BELEG_SICHERN.

Regards,

Clemens

Read only

0 Likes
2,748

Thanks both to RJ. Schamhart and Clemens Li.

I did not see that document, but anyway tried to use that forms (and I use it succesfully for other purposes); I don't need to chang VBKD .. VBKD was just an example. That forms (for anyone will read in the future) change data while transaction is running .. so if you change for example the WBS vale in form USEREXIT_MOVE_FIELD_TO_VBAP, the WBS field is updated in transaction. What I was looking for was the proof for what I was thinking:

  • USEREXIT_SAVE_DOCUMENT

Use this user exit to fill user-specific statistics update tables.

The user exit is called up by the FORM routine BELEG-SICHERN before the COMMIT command.

And I did not see

  • USEREXIT_SAVE_DOCUMENT_PREPARE

Use this user exit to make certain changes or checks immediately before saving a document.

My problem still is change data just before saving and the forms you told me act while processing VA01 data (header and positions .. for example USEREXIT_MOVE_FIELD_TO_VBAP is called each row I insert )

The USEREXIT_SAVE_DOCUMENT_PREPARE was suggested by Vinod Kumar , but trying it, I get no result. Anyway it's obvious that the solution must be searched in this form instead of USEREXIT_SAVE_DOCUMENT.

So I'll try again and I will let you know ...

Thanks to you all

Gabriele

Read only

0 Likes
2,748

Ok

it works. I made tries with VBKD, but it seems that VBKD is a bad example (there are many many table in this user exit ... really annoying to find the one you really need): instead trying to change data in VBAP (changing XVBAP data that is not the X structure as someone suggested) data modified are correctly saved.

Thanks to all of you