Application Development 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: 

How to do a commit from update task mode.

bettinasilveira
Participant

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!

1 ACCEPTED SOLUTION

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

9 REPLIES 9

pokrakam
Active Contributor

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.

0 Kudos

"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. 😞

pokrakam
Active Contributor
0 Kudos

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.

horst_keller
Product and Topic Expert
Product and Topic Expert

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?

vera_kulish2
Explorer
0 Kudos

Try:

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

Former Member
0 Kudos

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.

0 Kudos

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

horst_keller
Product and Topic Expert
Product and Topic Expert

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.

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