2015 Oct 23 12:42 PM
Hello all,
I am executing a RFC in background via a report, but the RFC is running in dialog work process.
I want the RFC to run in background work process.
I am using the below code, in this case the background job is getting finished in 0 secs.
CALL FUNCTION 'ZFM_USAGE' in BACKGROUND TASK
DESTINATION wa_rfc-rfc_name
how to run a RFC in Background work process ?
Regards,
Shony KJ
2015 Oct 26 12:27 PM
AFAIK If you actually want a background job (SM37, background processes) you must use some JOB_OPEN/SUBMIT/JOB_CLOSE in your FM)
Regards,
Raymond
2015 Oct 23 1:41 PM
"BACKGROUND TASK" makes the process as tRFC which uses Dialogue work process.
What you try to achieve can be achieved if you wrap the RFC in a JOB ( You can create a separate executable report and use "SUBMIT VIA BACKGROUND JOB option), then only it will consume a background work process instead of dialogue work process.
R
2015 Oct 23 2:01 PM
Thanks Rudra for your reply.
Actually I am calling the RFC FM via a report only, and I am calling it in the below syntax, but its still running in the dialogue work process.
CALL FUNCTION 'ZFM_USAGE' DESTINATION wa_rfc-rfc_name
2015 Oct 23 2:12 PM
So create another program(Program 2) and submit that in a job and inside program 2 call your RFC normally CALL FUNCTION 'ZFM_USAGE' DESTINATION wa_rfc-rfc_name
2015 Oct 23 2:22 PM
Hi Shony,
Are you trying to call this FM in Multi threaded mode ? If yes you can call as below :
CALL FUNCTION 'ZFM_USAGE'
STARTING NEW TASK <your task name>
DESTINATION IN GROUP <your logon group name>
PERFORMING get_data ON END OF TASK
EXPORTING
lv_start = lv_start
lv_end = lv_end
EXCEPTIONS
communication_failure = 1
system_failure = 2
resource_failure = 3
OTHERS = 4.
And then you need to create one Subroutine with name 'get_data' (based on above code)
*--> Here we are receiveing data so only receiving table will be here..
RECEIVE RESULTS FROM FUNCTION 'ZFM_USAGE'
IMPORTING
ev_bool = lv_bool
TABLES
lt_output = it_data_temp1
EXCEPTIONS
communication_failure = 1
system_failure = 2
resource_failure = 3
OTHERS = 4.
APPEND LINES OF it_data_temp1 TO it_data.
CLEAR it_data_temp1[].
But before calling you need to find out how many Worker Processes are available in system.
This can be done using API: SPBT_INITIALIZE which takes logon group name and returns Total and Available WPs.
Hope this will help.
Thanks-
Abhishek
2015 Oct 23 2:27 PM
Thanks Abhishek.
I want to execute a FM RFC in background work process.
2015 Oct 23 2:54 PM
Hi Shony,
Try calling below code just after your code
CALL FUNCTION 'ZFM_USAGE' in BACKGROUND TASK
DESTINATION wa_rfc-rfc_name
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
<your exporting Parametes>
After calling this Function check in SM50 you will see WP running in Background mode.
What ever RFC you will call using "in BACKGROUND TASK" that will create Dialog WP, but once you call "START_OF_BACKGROUNDTASK" it will crate another WP which will run in Background mode.
Hope this will Help.
Thanks-
Abhishek
2024 Oct 15 1:32 PM
@AbhishekSharma wrote:once you call "START_OF_BACKGROUNDTASK" it will crate another WP which will run in Background mode.
That's wrong, it still runs in a dialog work process (START_OF_BACKGROUNDTASK is just to schedule the start of an RFC unit at a given date and time). Any ABAP code running in RFC runs in a dialog work process.
2015 Oct 26 11:22 AM
Thanks Abhishek,
As you suggested , I have used the FM 'START_OF_BACKGROUNDTASK' also.
but the jobs are finished in 0 secs in the source system and in the target system there is no job scheduled or finished.
Thanks
Shony
2015 Oct 23 2:31 PM
Good day Shony,
Article from scn regarding the parallel processing. calling the function module inside a report on a background job will use background process but will process function module inside report using the dialog work process.
http://wiki.scn.sap.com/wiki/display/ABAP/Parallel+Processing
Regards,
Tumelo Modise
2015 Oct 26 12:27 PM
AFAIK If you actually want a background job (SM37, background processes) you must use some JOB_OPEN/SUBMIT/JOB_CLOSE in your FM)
Regards,
Raymond