‎2012 Mar 22 9:31 AM
Hi experts,
I have experience with another prog. languages - > what was in the block below was done all or nothing
begin work
call function
delete
update
commit work or rollback
i don't have experience with commit and rollback in ABAP.
i have e.g. code below
* start block
CALL FUNCTION 'RSDU_TABLE_TRUNCATE'
EXPORTING
i_tablnm = 'table1
CALL FUNCTION 'RSDRI_ODSO_INSERT'
EXPORTING
i_odsobject = 'table1
CALL FUNCTION 'RSDU_TABLE_TRUNCATE'
EXPORTING
i_tablnm = 'table2'
CALL FUNCTION 'RSDRI_ODSO_INSERT'
EXPORTING
i_odsobject = 'table2'
CALL FUNCTION 'RSEC_GENERATE_FROM_ODS'
* end block
please practise example what should i do to all things will be done "together" ( commit ) or nothing ( rollback - situation before running this code ).
( maybe i have to use ENQUEUE or something like this )
I tried something, but only part of the code in block was rollback.
Is possible add into this block internal table and use rollback for them too ?
Thanks in advance
Martin
‎2012 Mar 22 9:38 AM
Hi,
Create a custom Function module ZCUSTOM and call all the function mdules in that custom function module
and call
CALL FUNCTION ZCUSTOM IN UPDATE TASK......
You can rollback all the changes in same LUW or Save all the changes.
For further info google it on LUW you will get more info
thanks,Chandra
‎2012 Mar 22 1:04 PM
‎2012 Mar 22 1:17 PM
Call all your mentioned funciton modules and check if sy-subrc eq 0.
if sy-subrc <> 0.
lv_subrc = 4.
endif.
If all your FM's are executed with sy-subrc eq 0. Your lv_subrc is also 0.
You can write:
if lv_subrc eq 0.
commit work and wait.
else.
rollback work.
endif.
br
Jürgen
‎2012 Mar 22 1:33 PM
The theory is clear, but if i write the code below, i suppose that after rollback will be data in table1 and table2 as before running code, but
in table1 are new data
and table2 is empty ( it seems that rollback has relation only to command before - > insert into table2)
* start block
CALL FUNCTION 'RSDU_TABLE_TRUNCATE'
EXPORTING
i_tablnm = 'table1
CALL FUNCTION 'RSDRI_ODSO_INSERT'
EXPORTING
i_odsobject = 'table1
CALL FUNCTION 'RSDU_TABLE_TRUNCATE'
EXPORTING
i_tablnm = 'table2'
CALL FUNCTION 'RSDRI_ODSO_INSERT'
EXPORTING
i_odsobject = 'table2'
rollback work
* end block
‎2012 Mar 22 2:07 PM
Well, a couple of things:
First, you need to check sy-subrc after each FM call. That should tell you if the FM worked as expected.
Second, each of these FMs may or may not be calling a COMMIT or ROLLBACK.
Rob
‎2012 Mar 22 2:21 PM
it is clear, i should have to check sy-subrc in the future.
But only for my test example, without check of sy-subrc.
i would like to have the "original" data after rollback, what should i do (code) ?
Thanks
‎2012 Mar 22 2:31 PM
There is at least one COMMIT buried in one of these FMs, so I expect you will have to do this using native SQL.
Rob
‎2012 Mar 22 2:49 PM
‎2012 Mar 22 3:00 PM
Please example of the code.
I would like to have for my test code always original data after rollback ( it means ALL "block rollback")
Thanks
Martin
‎2012 Mar 22 3:02 PM
You're not going to be able to do this using these FMs. Like I said - native SQL.
Rob
‎2012 Mar 23 9:09 AM
Does it mean that i cannot use these FMs as "block" ? I suppose that the similar examples are "frequent" in ABAP. Which solution is suitable for that ?
please give me small example with "native SQL"
Thanks
Martin
‎2012 Mar 23 10:13 AM
Hello Martin,
What you are trying to achieve is called Bundling of Updates. And the only way of doing it is thorugh -
You can try to wrap these standard FMs inside a custom Update function module which ensures te atomicity of the transaction.
BR,
Suhas
‎2012 Mar 23 2:58 PM