Application Development 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: 

Background Task

Former Member
0 Kudos

Hi,

I'm running a Z program which at a certain point needs to execute a process in background.

The function I need to call is L_TO_CREATE_SINGLE I've coded this into an RFC enabled Z FM to call in background.

When the main program calls this Z FM in foreground, it works everytime. However, when I change it to call in background task it only works on occasions. L_TO_CREATE_SINGLE sometimes returns a not authorised exception message.

I can run this program, using my userid and it'll work, then work, then fail, then work (with the same data that previously failed) then work, then fail, then fail, then work.

The initial thought was timing, but given that in foreground it works everytime, I dn't think it's that.

It's almost as if the user ID changes.

Can anyone think of a reason for this ?

Cheers

James

4 REPLIES 4

Former Member
0 Kudos

Hi James,

Can you confirm if the background jobs created are getting created on ur userid always?

Bcauz I feel when u run in background the background jobs are created by sap system with its own id....

In foreground, its always get created under your userid.

Regards,

Raj

0 Kudos

Hi Raj,

That was my thought. However, when I look in AFRCSTATE the user ID is mine.

Also, if it changed the user to a SAP one for all background task it would fail everytime not just on some occasions.

It's very frustrating.

James

christian_wohlfahrt
Active Contributor
0 Kudos

Hi James!

First one of the easy guesses:

you have to use L_TO_CREATE_SINGLE with option I_COMMIT_WORK = space, because in background task no second commit work is allowed.

Which update option did you chose? In case you took a V2 or V3, you might have an independent user. So I would only go for one of the V1 (immediate) options. In general this has to be the correct user, otherwise 50% of all entries would be created by wrong user-ids.

Regards,

Christian

0 Kudos

Hi Christian,

I think you are refering more to if this was in UPDATE TASK.

We are not getting a dump, the exception returns from the function as NO_AUTHORITY.

Like I say, it's as if the user is changing.