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

Handle error or warning message in updata task fm

abhishek_diwvedi
Explorer
0 Likes
4,396


Hi Experts,

I have an requirement of creating materials. I am doing this in an update task FM. Now i want that if some error comes during creation of material then i display them in an alv on the screen.So inside the FM in case of error i populated it in the tables parameter of FM.But when i come back to the calling program this table is always coming empty. Could anybody please explain how to solved this problem or how we can pass the data back to the main program.

Thanks in advance

1 ACCEPTED SOLUTION
Read only

former_member201275
Active Contributor
0 Likes
2,824

Unfortunately, this type of error cannot be handled in the calling routine. They occur after the update has been passed.

You have to use SM13 or SM14 to examine the problem.


Hi Experts,

I have an requirement of creating materials. I am doing this in an update task FM. Now i want that if some error comes during creation of material then i display them in an alv on the screen.So inside the FM in case of error i populated it in the tables parameter of FM.But when i come back to the calling program this table is always coming empty. Could anybody please explain how to solved this problem or how we can pass the data back to the main program.

Thanks in advance

10 REPLIES 10
Read only

former_member201275
Active Contributor
0 Likes
2,825

Unfortunately, this type of error cannot be handled in the calling routine. They occur after the update has been passed.

You have to use SM13 or SM14 to examine the problem.

Read only

0 Likes
2,824

Hi ,

But if i am updating in synchronus mode then the calling routine wait for the update work to be completed.But even in this case i am getting the tables parameters empty..If we are not able to find out in calling routine that whethere updation has been successful or not then what is the advantage of synchronus update.

Read only

0 Likes
2,824

You are using in Update task, that is asynchronous. The values to update are send in a separate LUW, an update LUW.

You will nedd to add checks before you call the update module like read the database if the entry already exist or any other error warning that you are expecting.

Read only

Former Member
0 Likes
2,824

you cant use exporting / changing / tables parameters in update task as it is not synchronous. You can't easily get the success / erro information. Therefore your code has to be written so that all errors are catched before the update task function module is called. You can turn on the update debugging and test, what happens.

Read only

Former Member
0 Likes
2,824

This message was moderated.

Read only

former_member212005
Active Contributor
0 Likes
2,824

Why Update Task FM? If you can use STARTING NEW TASK.....then I think below option is available.

I am not sure whether this is correct (haven't tried)....but there is one more addition called

... {CALLING meth}|{PERFORMING subr} ON END OF TASK

In the above case....u can mention a subroutine which would be called after the FM is executed in ....

and you can pass your parameters also...which could be retrieved using below addition...

RECEIVE RESULTS FROM FUNCTION func

                [KEEPING TASK]

                parameter_list.

Read only

0 Likes
2,824

I guess because it is an Update Function Module that is the reason why he used Update task.

Read only

0 Likes
2,824

From what has been written....it seems he designed the FM as an update function module....So I am trying to understand what might be the reason behind this....

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,824

Can you confirm you are creating a material reference by directly calling a standard update task FM without any database consistency check and only raising database-sql errors ? (Correct answer is 'No')

Regards,

Raymond

Read only

Former Member
0 Likes
2,824

Hi,

Do you know how an update BAPI  ( Create, Change ) works .

1) At First, it does validation for important fields for every tables passed in the BAPI.

perform check_on_header.

*  In the subroutine called, if error occurs, it sets sy-subrc value to 8 and fills the bapireturn     parameter.

check sy-subrc < 8.

perform check_on_items.

check sy-subrc < 8.

------

------

At the end, when all the data is clean, it calls the update task

if sy-subrc = 0.

CALL FUNCTION 'BAPI_XXX_POST' in update task.

endif.

2) We check the return parameters of the bapi call and if successful call 'BAPI_TRANSACTION_COMMIT'.

3) The actual posting in 'BAPI_XXX_POST' happens once commit work statement is called in 'BAPI_TRANSACTION_COMMIT' .

You too have to adopt similar approach.

Regards,

DPM