Skip to Content
0

How to do a commit from update task mode.

Sep 06, 2017 at 07:47 PM

118

avatar image
Former Member

Hi guys!

I have a problem, inside a function module called in update task mode I need to add a record to a Z table and do a commit so its available in a step later in the same process.

If I do a commit, I get a dump because you can't do that. I tried another thing, to call another function module as a new task and inside this FM add the insert and the commit. It's not doing anything.

Code works because if I execute the first FM from SE37 as a normal FM, the records is added to the table.

So, is there a way to add a record to a table and do the correspondent commit inside a FM called in update task mode? Keep in mind that I'm doing a select to retrieve this record in a posterior step, that's why I need it, I'm adding functionality to an existing program and trying to modify as little as I can.

Thanks for your help!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
avatar image
Former Member Sep 08, 2017 at 01:50 AM
0

Hi,

The code which you are using to update the z table, place it in a RFC enabled function module and write a commit statement inside this RFC enabled FM.

Call this RFC enabled FM from the main program or FM as DESTIANTION 'NONE'.

EG: CALL FUNCTION '<RFC ENABLED FM>' DESTINATION 'NONE'.


In this way you can avoid dump and you can update the z table.

Refer notes 1895298, 896173

Share
10 |10000 characters needed characters left characters exceeded
Mike Pokraka Sep 06, 2017 at 08:56 PM
2

How exactly is the later step performed? Read consistency means your select should already 'see' the new data if it is in the same LUW, So im wondering whether there's some caching or something involved or it's going into another LUW?

Alternatively, is it possible to transport the updated info to the later step? Perhaps using a static class attribute or something like that.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

"Later step" is in the same process, same function module, same LUW. I could save the info to memory, but I'm trying to not alter the code so much. If that's the only option I have, I guess there's no other way. :(

0

Hmmm, it does make me wonder whether the program logic is optimal if we are writing to and then reading from the same table in the same code unit? It does sound a bit unusual.

0

Then why do you do an explicit COMMIT at all?

If you change a DB table, the change is visible in "the same process, same function module, same (DB-)LUW". Or do I miss something?

1
Horst Keller
Sep 07, 2017 at 02:33 PM
1

But why an explicit commit? Inside an update FM and everything called there you are by default inside a DB LUW. There are no rollbacks, only in case of errors.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 07, 2017 at 06:19 AM
-1

Hi,

You can do a Commit after call the FM in update task mode, so the FM will be execute and add the record, but in fact it is the same as call the FM in normal way.

Best regards.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

If you read my original post, I need to do a commit INSIDE the FM, not after.

0
Vera Kulish Sep 06, 2017 at 11:29 PM
-4

Try:

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.

Share
10 |10000 characters needed characters left characters exceeded