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 FM in update task

Former Member
0 Likes
1,533

hi experts

i am calling 2 FM's in my program . one FM is updating a table zabc and other FM is inserting into table zxyz.

my requirement is either both ztables should be updated or none should be updated so i call the FM's in update task

and use commit work at end.

however issue comes in the following case -

1. FM1 - updated record fine in zabc

2. FM2 - here i try to insert with key field that is already existing

as second FM did not insert the values in the table zxyz , i think even the record in zabc should not be inserted.

but when the commit work is executed record is updated in first table but not in the second table.

should it not be a single LUW and NOT insert entry in the first table ?   how do i achieve this ?

hi experts

i am calling 2 FM's in my program . one FM is updating a table zabc and other FM is inserting into table zxyz.

my requirement is either both ztables should be updated or none should be updated so i call the FM's in update task

and use commit work at end.

however issue comes in the following case -

1. FM1 - updated record fine in zabc

2. FM2 - here i try to insert with key field that is already existing

as second FM did not insert the values in the table zxyz , i think even the record in zabc should not be inserted.

but when the commit work is executed record is updated in first table but not in the second table.

should it not be a single LUW and NOT insert entry in the first table ?   how do i achieve this ?

8 REPLIES 8
Read only

Former Member
0 Likes
1,346

I think you've got this a little backwards.  Don't put them in update task.  run them synchronously back to back.  If they both succeed, then commit, else rollback.

Neal

Read only

Former Member
0 Likes
1,346

Dear,kindly look at the thread same kind of discussion is already there. please try it once.

Read only

Former Member
0 Likes
1,346

but my question is as per the concept ...all the FM which are in update task should be called in same LUW  when commit work is triggered.

So if 1 FM has a insert statement that works and other FM has insert statement that does not work then when commit work executes should it not rollback the first insert and then send an error through sapmail and then i should be able to monitor that error in sm13???

This is what the documentation says

Read only

0 Likes
1,346

Hi Hema Plz share your code for more info

Read only

0 Likes
1,346

did u put breakpoin for update task.? plz do the same anc check for sy-subrc i strongly feel it is an issue there because 1 table is upated and other is not seems to me is not possible,

Read only

mahesh_madhavan
Participant
0 Likes
1,346

Dear Hema,

The update process will not terminate by itself if some table update just fails(unless an exception is triggered by system). So, you have to terminate it by yourself. This is how it should be ideally done.

Check for sy-subrc value during the insertion. If it fails, trigger a message of any type except 'S' inside the update FM itself.

This will terminate the update task and roll back the entries in the first table as well.

Cheers,

Mahesh

Message was edited by: Mahesh Madhavan

Read only

Former Member
0 Likes
1,346

Hi Hema,

As others said,

Process both the FM Synchronously one after the other.

Thanks

Pavan.N

Read only

Former Member
0 Likes
1,346

Hi Hema,

It will be working fine if you check for the SY-SUBRC after the database update statement and error message should be shown after that.

Regards

Alex