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

a question about update task

Former Member
0 Likes
807

Hi, everybody.

In order to the transaction effect of update for mutiple tables, I create a update type function, and insert/update several tables in it.

And I call it like this:

CALL FUNCTION 'ZTEST_UPDATE'

IN UPDATE TASK

EXPORTING ...

EXCEPTIONS ...

COMMIT WORK.

After commit, update will do,

when a update in 'ZTEST_UPDATE' fail, all of the action will be cancel, it goes well.

But my question is how can I get the call function result? in this UPDATE TASK mode

I want to know after commit, if the 'ZTEST_UPDATE' is success or fail. Can I only reference sy-subrc?

Hope your reply, and any suggestion is welcome.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
722

At first, thanks a lot.

Brad, your reply is very valuable.

But I also thought about validate the data before update, it is a good way to avoid most of error when update. But anyway, it is still possible that occur some issue in the update action. So get the result is necessary.(there is also some requirement by client for result report)

COMMIT WORK AND WAIT. is a good way, though its poor synchronize, it can meet the requirement in my object.

And thank for your remind on V1.

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
722

I believe that you must use the following line of code in order to know the exceptions for the ZTEST_UPDATE function module.



SET UPDATE TASK LOCAL.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
722

Hi Zhenglin,

As the update task runs in a seperate thread, then it becomes difficult to determine its success from within your program (and not really desirable anyway).

You should design your program so that the only activities that occur within the UPDATE function are database inserts/updates/deletes.

All the data should be validated and checked prior to calling your UPDATE function.

If you want to check the success of your UPDATE function you can do so via transaction SM13, but this should only have errors if you have encountered system / database problems- not logic issues.

Cheers,

Brad

Read only

0 Likes
722

Hi Zhenglin,

If you really want to know the success of the update, you can also use the command:

COMMIT WORK <b>AND WAIT</b>.

The sy-subrc will be non zero if you have a problem.

BUT, this defeats the whole purpose of calling the function in UPDATE TASK in the first place (you get a seperate thread, but your first thread waits for the second one to finish anyway). You might as well call the function within your own task.

Cheers,

Brad

Read only

0 Likes
722

Please note, however, that only V1 update functions are captured using these techniques, V2 update functions will not be affected (and hence you wont be able to determine the return codes).

To determine which type of function you have (V1,V2) then check the FM attributes:

V1 is for Start Immed. and Immediate start, no restart

V2 is for Start delayed and Coll. run

Cheers,

Brad

Read only

Former Member
0 Likes
722

Thanks Zhenglin,

Has your question been addressed?

If so, please close the thread - either "solved it on my own" or "solved problem".

Have a good weekend.

Brad

Read only

Former Member
0 Likes
723

At first, thanks a lot.

Brad, your reply is very valuable.

But I also thought about validate the data before update, it is a good way to avoid most of error when update. But anyway, it is still possible that occur some issue in the update action. So get the result is necessary.(there is also some requirement by client for result report)

COMMIT WORK AND WAIT. is a good way, though its poor synchronize, it can meet the requirement in my object.

And thank for your remind on V1.

Read only

0 Likes
722

No problem zhenglin,

It'd be really great if you could close off the thread now though.

It really helps people when they see if a thread is closed:

1. People looking to help others will know that this thread is closed, and won't need to waste time solving problems that are already solved.

2. When people are searching the forums for their problem they can filter by those that have been solved. This should mean that they only get useful information for their problem.

Its a constant problem for SDN but you can help by closing off a thread each time it has been solved to your satisfaction (either by yourself or someone else).

Cheers,

Brad