‎2017 Sep 06 8:47 PM
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!
‎2017 Sep 08 2:50 AM
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
‎2017 Sep 06 9:56 PM
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.
‎2017 Sep 06 10:05 PM
"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. 😞
‎2017 Sep 06 10:21 PM
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.
‎2017 Sep 07 8:24 AM
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?
‎2017 Sep 07 12:29 AM
Try:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
‎2017 Sep 07 7:19 AM
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.
‎2017 Sep 07 2:37 PM
If you read my original post, I need to do a commit INSIDE the FM, not after.
‎2017 Sep 07 3:33 PM
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.
‎2017 Sep 08 2:50 AM
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