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

Call function starting new task:

Former Member
0 Likes
1,572

I am trying to create a program in which few database update are mentioned.

after database updates , I am calling a function module using starting new task

in which I want to commit database updates inside in function module.

Problem is I want to commit only database updates if function module , not of main program. For that I tried using COMMIT WORK in function module and rollback statement after calling FM. But it is not working.COMMIT statement in FM also commiting database updates of main program also that is not required.

Can anybody help me in solving this problem.

Thanks

Ruchika

7 REPLIES 7
Read only

Maciej_DomagaBa
Contributor
0 Likes
963

I think this may be caused by an implicit database commit performed by the system at the moment of calling a fm with "starting new task".

Try the following test:

- Put "rollback work" statement inside your fm which you call "starting new task" (instead of "commit") and check if the updates performed by the code executed before the call to this fm are stored in db - inspite of the rollback. If they are (as I suppose) this means that the commit effect you observe is not due to the "commit work" statement executed inside your fm but due to an implicit commit issued automatically at the time of calling the fm. If this is the case the solution could be placing the code which you now execute before "call function...starting new task" into a seperate fm called "in update task" - then the final commit or rollback statement in your main program should have the expected effect.

regards

Read only

0 Likes
963

Thanks for your suggestion....but this will not solve my problem

can u tell me how to commit 2 diffrent LUWs independently.....

They shul not effect each other's commit

Read only

0 Likes
963

Hello Ruchika,

to have 2 LUW´s at same time controlled by one process is not possible by default. One exception might be a secondary connection (see COMMIT CONNECTION) but it is not advisable.

Regards

Klaus

Read only

0 Likes
963

I'm not sure if I understand your goal, I guess what you want to achieve is to be able to decide about commit/rollback separately. In this case try a program structured like this:


perform F1 on commit.
call function FM destination 'NONE' ...
perform F2 on commit.
commit work (or rollback work).

FORM F1 ...
" some db updates here
ENDFORM.

FORM F2 ...
" another db updates here if you need
ENDFORM.

Function module FM should be RFC enabled (set in fm attributes).

regards

Read only

0 Likes
963

Thanks...This I had already done....but I also one more isuue..because i will not work in case there is dump.

In case of runtime error. or .dump.. ..I want to save few database changes that were written in sub routine,how to achieve this..so that If dump occurs , I am able to save updates into database.

Is there any badI IN crm THAT can help in such cases..

Read only

former_member183804
Active Contributor
0 Likes
963

Hello Ruchika,

an alternative approach is not to do the db updates in the main program but keep a kind of description what to do. For example store records in internal tables. Then you can call the FuBa safely.

Regards

Klaus

Read only

0 Likes
963

Can you explain what is FuBa and how to use..actually I want to create two LUWs and commit them separately in a same program.Both of them shud not effect each other.

If You or anybody can tell me how to do this....please let me know