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

How to advoid COMMIT_IN_POSTING - Detect if running in update process

Former Member
0 Likes
1,541

Hi,

Background

I have written a FM that sends email with cl_document_bcs and cl_gbt_multirelated_service. I plan to use that FM in many places so it must work both in normal mode and in an update process but my problem is that when running in an update process (example when sending email from order) the COMMIT WORK. creates a dump.

My question:

- How can the function module detect when it is running in an update process?

This is how I have solved it right now, but it really feels like a dirty fix...

IF sy-title NE 'Update control'.
  COMMIT WORK.
ENDIF.

I hope that you have a simple answer to this....

1 ACCEPTED SOLUTION
Read only

arseni_gallardo
Active Participant
0 Likes
1,136

Use this:


  IF CL_SYSTEM_TRANSACTION_STATE=>GET_IN_UPDATE_TASK( )  EQ 0 .
    COMMIT WORK.
  ENDIF.

Hi,

Background

I have written a FM that sends email with cl_document_bcs and cl_gbt_multirelated_service. I plan to use that FM in many places so it must work both in normal mode and in an update process but my problem is that when running in an update process (example when sending email from order) the COMMIT WORK. creates a dump.

My question:

- How can the function module detect when it is running in an update process?

This is how I have solved it right now, but it really feels like a dirty fix...

IF sy-title NE 'Update control'.
  COMMIT WORK.
ENDIF.

I hope that you have a simple answer to this....

4 REPLIES 4
Read only

Former Member
0 Likes
1,136

Hi again,

I now have another dirty solution, a new imported parameter i_commit_work. I don't like it but I must perhaps have it like this...

Br Linus

Read only

arseni_gallardo
Active Participant
0 Likes
1,137

Use this:


  IF CL_SYSTEM_TRANSACTION_STATE=>GET_IN_UPDATE_TASK( )  EQ 0 .
    COMMIT WORK.
  ENDIF.

Read only

0 Likes
1,136

Thank you!

I used Arsens suggestion, it worked for me!

Br Linus

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,136

Have a look at the system field[SY-ONCOM|http://help.sap.com/saphelp_nw04/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm]

You can also use the function module TH_IN_UPDATE_TASK for this .

Kesav