11-05-2008 3:09 PM
HI Gurus,
Scenario:
User-exit called from SAP transaction.
It needs to update Z*table and then do standard Sap processing.
Whats it doing:
However when I run it, I realise that it is not updating the Z*table.
I tried to introduce a wait statement and then sometimes it does commit data to Z*table and sometimes it doesnt.(NO error returned. Sy-subrc = 0. However if I use a COMMIT statement, the program gives runtime error.
What I need:
Is there a way how I can make sure that data is written to Z* table first and only then is the stanadrd SAP processing done. (as mentioned writing a COMMIT staement is not helping...so how do I commit data to Z*table before going ahead in same transaction? )
Appreciate your response on same.
Many thanks
Shirin
11-05-2008 3:16 PM
Hi
if the Ztable needs to be updated you will be using Modify , Insert statments... the structure of the work area and Ztable need to be same.
11-05-2008 3:22 PM
Hi Jay,
i guess you did not get my question. Let me give some more details
I am using an UPDATE statement withing the exit. (work area structure is same as that of z*table).
Update statement executes fine (sy-subrc = 0).
Once this is done, I let SAP continue with standard processing. When I check the results, SAP standard processing has worked fine but Z*table is not updated. So I introduced WAIT statement after my UPDATE statem,ent and it works fine if the no of records is upto 10.
Anything after 10 records, the results are not predictable. In some cases it updates and sometimes doesnt.
( I read some threads and they talk about COMMIT statement. However I can not use that with the user-exit...it errors).
So I am trying to find a way, how to make sure that Z*table is updated and then only stnadrd SAP processing resumes.
Regards
Shirin
11-05-2008 3:24 PM
did you try increasing the wait time..
commit work and wait X seconds. X?
11-05-2008 3:44 PM
Write your update code in a function module and call the function module in STARTING A NEW TASK mode and within function module give commit work.
a®
11-05-2008 3:17 PM
Hi,
You probably have you write a function module (remote enable it ) that updates the Z table and then call that function module with destination 'NONE'. (write a commit work after the z table update )
I'm not sure if this would work but the documentation says
Note that a database commit occurs at each Remote Function Call (RFC). Consequently, you cannot use Remote Function Calls between pairs of statements that open and close a database cursor (such as SELECT ... ENDSELECT).
regards,
Advait
11-05-2008 3:19 PM
For updating Z-tables in user exits I usually call a subroutine with PERFORM ... ON COMMIT. This way your code is being executed once the standard transaction sends a COMMIT WORK. This will update the Z-table immediatly after the standard tables.
I don't think it is possible to have the Z-table updated before the standard tables though. What would be a reason that this might be mandatory?
Never invoke a COMMIT WORK directly in your user exit.
Thomas
10-09-2015 6:18 PM
hi thomas,
can youplease let explain why we should not call commit inside badi ?
ex : inside badi impl:
Select * from ZCUSTOM into table ITAB.
Read Table ITAB into WA_ITAB with key
WA_ITAB - Delivered_Quantity = WA_ITAB - Delivered_Quantity + Input_Delivered_quantity.
Modify table ITAB from WA_ITAB.
If NOT ITAB[] IS INITIAL.
MODIFY ZCUSTOM from ITAB.
commit work.
endif.
can we use this or please tell the alternate for this .