cancel
Showing results for 
Search instead for 
Did you mean: 

Function module in background task

FredericGirod
Active Contributor
0 Kudos

Hi,

I have a user-exit, that must modify a value. But this value have a lock entry (it's my own transaction that set this lock-entry). So I would like to call a function in background task to modify the value when the lock entry disapear.

But ...

I don't see anything append in the SM50.

If I call the function not in background, I could debug the function.

When I set background debugging nothing append.

I have set the RFC option in the function module.

CALL FUNCTION 'ZCALL_MB26_CONFIRMATION_OT'
  IN BACKGROUND TASK AS SEPARATE UNIT DESTINATION 'NONE'

Rgd

Frédéric

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use the Commit work statement.

See the help on calling in background task...

<i>The function modules registered for the current SAP LUW are started at the COMMIT WORK statement in the sequence, in which they were registered. The statement ROLLBACK WORK deletes all previous registrations of the current SAP LUW.</i>

FredericGirod
Active Contributor
0 Kudos

Yes,

good idea, when I make test, the commit work start the RFC connexion (I see it in SM58). But, the problem is that the user-exit is already in background mode, so I can't use the "commit work" command.

Another good idea ?

Fred

FredericGirod
Active Contributor
0 Kudos

End of the story.

So the commit work didn't append, just because, I was in background debugging and in this mode, SAP suppress the commit work ...

Thanks again

Fred

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Fred,

This is a sample code to wait for unlock (but if a user is in modification it can be endless).

data : w_garg like seqg3-garg.

data : t_enq like seqg3 occurs 0.

concatenate sy-mandt tplnr into w_garg.

do.

refresh t_enq.

call function 'ENQUEUE_READ'

exporting

gclient = sy-mandt

gname = 'IFLOT'

garg = w_garg

  • GUNAME = SY-UNAME

  • LOCAL = ' '

  • IMPORTING

  • NUMBER =

  • SUBRC =

tables

enq = t_enq

  • EXCEPTIONS

  • COMMUNICATION_FAILURE = 1

  • SYSTEM_FAILURE = 2

  • OTHERS = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

if t_enq[] is initial.

exit.

endif.

enddo.

David

Former Member
0 Kudos

Have you included an endless loop in the FM to "catch" it at background debugging?

e.g.

data a type i value 1.

while a eq 1.

  • change value in the debugger to continue

endwhile.