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

Calling a background Job from RFC enabled Function Module

Former Member
0 Likes
2,733

Hi Experts ,

I have a requirement to call a background Job from RFC Enabled Function Module . As soon as the background job is called , RFC enabled Function Module should exit or complete.

Please advise anyway of achieveing this.

Thanks in advance.

Regards,

Shital.

5 REPLIES 5
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,275

Just use a [JOB_OPEN, SUBMIT and JOB_CLOSE|http://help.sap.com/erp2005_ehp_04/helpdata/EN/fa/096ee5543b11d1898e0000e8322d00/frameset.htm] in your RFC enabled FM. (Don't forget to provide print parameters if needed if the call comes actually from an external system)

You may also [call your RFC FM in an asynchronous way|http://help.sap.com/erp2005_ehp_04/helpdata/EN/22/042592488911d189490000e829fbbd/frameset.htm] (STARTING NEW TASK)

Regards

Read only

0 Likes
1,275

Hi ,

Thanks for your reply.It is helpfull.

Could you please comment if Function Module BP_EVENT_RAISE can be helpfull for this requirement?

If yes , please elaborate on this.

Best Regards,

Shital.

Read only

Former Member
0 Likes
1,275

when you call a job in RFC, the background job starts and the function module is not in command ..

so you need not worry.

CALL FUNCTION 'JOB_OPEN' 
EXPORTING 
JOBNAME = JOBNAME 
IMPORTING 
JOBCOUNT = JOBNUMBER 
EXCEPTIONS 
CANT_CREATE_JOB = 01 
INVALID_JOB_DATA = 02 
JOBNAME_MISSING = 03 
OTHERS = 99. 

IF SY-SUBRC > 0. 
<Error processing> 
ENDIF.

JOB_SUBMIT.
JOB_CLOSE.

To create variants you can use

RS_VARIANT_LIST

Regards,

Lalit Mohan Gupta.

Read only

0 Likes
1,275

Hi ,

Thanks for your reply.It is helpfull.

Could you please comment if Function Module BP_EVENT_RAISE can be helpfull for this requirement?

If yes , please elaborate on this.

Best Regards,

Shital.

Read only

0 Likes
1,275

Hello Shital,

Yes, the FM BP_EVENT_RAISE will be helpful in this case:

Here is an example for the FM , Let me know if you have any questions!

Example

  • Report processing before triggering event...

  • Trigger event to start background jobs waiting for the event.

DATA: EVENTID LIKE TBTCJOB-EVENTID.

DATA: EVENTPARM LIKE TBTCJOB-EVENTPARM.

EVENTID = 'SP_TEST_EVENT'. " Event name must be defined

" with transaction SM62.

EVENTPARM = 'EVENT1'. " Optional: a job can be

" scheduled to wait for an

" EVENTID or combination of

" EVENTID and EVENTPARM.

CALL FUNCTION 'BP_EVENT_RAISE' " Event is triggered. Jobs

EXPORTING " waiting for event will be

EVENTID = EVENTID " started.

EVENTPARM = EVENTPARM

TARGET_INSTANCE = u2018 u2018 " Instance at which an event

" should be processed. Can

" generally be omitted.

EXCEPTIONS OTHERS = 1. " Exceptions include event not

" defined, no EVENTID

" exported, etc.