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 RFC

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

"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

0 Kudos

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

0 Kudos

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

AbhishekSharma
Active Contributor
0 Kudos

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

0 Kudos

Thanks Abhishek.

I want to execute a FM RFC in background work process.

0 Kudos

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

0 Kudos

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

former_member186660
Participant
0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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