Call FM remotely in Background task

Hello,
I need some help regarding calling function modules through RFC call in background task in 4.6C.
We are calling some standard FMs in our Z program to perform some actions in a remotely called system and based on the return value from the RFC call we are deciding further processing steps in our program. The Z program takes lot of execution time (due to huge data) and hence is executed in background and when the RFC call is made to the standard FM, the FM also is taking long execution time. Because of the long execution time in the remote system (which also is 4.6C SAP system), a TIME_OUT dump is occuring and due to this  the original job (Zprogram) also gets cancelled.
As a solution we are trying to implement the RFC call as a background task, so that both the zprogram and the RFC call happen in background and get executed successfully.
But, while calling the RFC FM in background it is not allowing us to fetch any return values (which is in accordance with the standard SAP behaviour). For us to proceed further in our program we need the return value and hence want an idea to approach this issue.
Please suggest any means to solve this problem.
Many thanks,
Chaithanya.

Hi Ganesh,
Thanks for the reply.
We already have an alternate solution to adjust the design of the Z program but we want to try out any possible solutions from SAP standard (any flag to be set or any settings to be done) instead of changing the design of our Z program.
We would be really glad to have such a solution as the design change would take a lot of effort and is similar to developing a new program.
Regards,
Chaithanya.

Similar Messages

  • What is the use of CALL FUNCTION MODULE - AT BACKGROUND TASK?

    Hi experts,
    I found Call functional module in background task will make the FM run at the next commit work as some people said. So I have some questions:
    1 if we use COMMIT WORK commend, the pending FM will be called? If there are several FMs called at background task, what is the sequence of them? How many conditions will trigger the running of these FMs?
    2 Where can I find the log of this pending FMs? In SAP library, it says there are 2 tables. But I checked these tables and can only find the FM name and user of it. And I can not understand content of these tables. It seems one is for the main information of FM, and the other is for the data of the FM, maybe the parameters.
    3 If I call a FM in this way, Can I canncel it before the next commit work in some way?
    Finally, thanks for reading and help.

    HI,
    When the COMMIT WORK statement is executed, the function modules registered for the current SAP-LUW are started in the order in which they were registered. ROLLBACK WORK deletes all previous registrations for the current SAP-LUW.
    If the specified destination is not available when COMMIT WORK is executed, an executable program called RSARFCSE is started in background processing. By default, this tries to start the function modules registered for a SAP-LUW in their destination every 15 minutes and up to 30 times. These parameters can be changed in the transaction SM59. If the destination does not become available within the defined time, it is recorded in the database table ARFCSDATA as the entry "CPICERR". The entry in the database table ARFCSSTATE is deleted after a standard period of eight days

  • Lock inheritance with "CALL FUNCTION func IN BACKGROUND TASK"

    I see that the "SAP Lock concept" documentation states that for locks obtained with _scope = '3', all UPDATE tasks (spawned via "CALL FUNCTION func IN UPDATE TASK" inherit the lock (which is released only once all such update tasks and the calling process have requested a DEQUEUE).
    What should happen when instead, I use "CALL FUNCTION func IN BACKGROUND TASK" (for doing the update in a queue)? Are the locks inherited here as well?
    Cheers!

    Hopefully not, as a background task may be executed late. While update tasks are to be executed quickly (if not, administrators should review the system configuration, like increasing the number of UPD workprocesses).
    Solution: In the background task, redo the locks, as if it was a background job.

  • Calling function module in background task

    Hello,
    There is one function module which is called in background task. Is there any chance that background task is not created and function module is not executed. That function module is supposed to send some outbound message. The FM is called in one user exit. I don't have any idea as why it is called as background task. The probem is that this message is not getting send sometimes.(sometimes it gets send ). Because of this I am not able to make any conclusion.
    Please respond if anyone has come across such scenario before.
    Thanks in advance,
    Minal

    Check the below link...it might be helpfull
    It should be executed....check it with different data as to what might fail
    http://help.sap.com/saphelp_nw04/helpdata/EN/8f/53b67ad30be445b0ccc968d69bc6ff/content.htm
    http://help.sap.com/abapdocu/en/ABAPCALL_FUNCTION_BACKGROUND_TASK.htm

  • Calling function modules in background task

    Hi All,
    I am creating a notification in the background and linking it to an order. This I am doing inside a function module which is called in background task as a separate unit. I should change the user status of this newly created notification. This I am doing in another FM called as a separate unit. Now my requirement is that, I need to perform the status change only after the new notification is committed to the database. I would like to know if i can provide some time lag between the 2 FM execution. Can anyone tell me how much time will be consumed to commit the data to the database tables irrespective of the length of the data. Say for example, if i have hundreds of notifications within the object list tab of an order, I want to know what is the maximum time it will take to commit this to the database table so that I can put a wait conditionat the stat of the second FM call.
    Thanks

    Ok thanks. But let me tell you 1 thing, actually I am calling these 2 FMs within an enhancement section just before another FM CO_ZV_ORDER_POST which is actually doing a commit work. So is it OK if I call the 1st FM in background task and the second FM in update task in the same place as I am calling the FMs now(i.e., before CO_ZV_ORDER_POST)?

  • Function called IN BACKGROUND TASK goes to work process DIA, not BGD

    I'm calling a function IN BACKGROUND TASK
    In SM50, I see it running in a DIA work process.
    I want it to run in a BGD work process.
    Can this be done?  If so, how?  If not, why not?

    Hi...
    It looks like, it will always run in DIA process and not Background process...I am not sure that we can change the work process
    Check the below link..
    http://help.sap.com/saphelp_40b/helpdata/pt/69/c24f864ba111d189750000e8322d00/content.htm
    What is written in the link is...
    "Background updates (CALL FUNCTION IN BACKGROUND TASK) represent a variant of remote function call that is synchronous with the end of a transaction (COMMIT WORK). In background updating, an update is run in another dialog work process that may be in the same or in another application server and R/3 System. Because such updates run in their own LUWs, they may start only after all critical updates have been completed. Otherwise, it would not be possible to roll back background changes in the event of an error in another update component. "
    IF you get the answer of whether we can change the work process then please let us know...

  • CALL FUNCTION IN BACKGROUND TASK - enable tRFC

    Hi Experts,
    I want to call a Remote Function module 'IN bACKGROUND TASK' and get the status in SM58 within the same AS. Kindly help me to do this.
    Requirement is to call the remote function module asynchronously in a guarentied way.
    Thank you
    Nikhil

    The scenario works fine for me. The issue was unable to create a proper test condition in the RFC.
    CALL FUNCTION 'ZMY_RFCASYNC'
       IN BACKGROUND TASK
       EXPORTING...
       TABLES...
       EXCEPTIONS...
    Simulated error condition in 'ZMY_RFCASYNC'
    and got entry in SM58 by simply making an exception. 
    Thank you all.

  • How to capture errors when a Function module is called as BACKGROUND TASK

    How to capture errors when a Function module is called as BACKGROUND TASK?.Please advise.
    FUNCTION ZRPM_DELETE_PROJECT_DATA_API.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(IV_EXTERNAL_ID) TYPE  RPM_TV_EXTID OPTIONAL
    *"     VALUE(IV_PROJECT_GUID) TYPE  RPM_TV_GUID OPTIONAL
    *"     VALUE(FLAG) TYPE  BOOLEAN OPTIONAL
    *"  EXPORTING
    *"     VALUE(EV_RC) TYPE  I
    *"     VALUE(EV_MSG) TYPE  STRING
    *"     VALUE(ET_MSG) TYPE  RPM_TT_MESSAGES
      IF flag = cl_rpm_co=>sc_true.
        Call function 'RPM_DELETE_PROJECT_DATA' IN BACKGROUND TASK
          EXPORTING
            IV_EXTERNAL_ID  = IV_EXTERNAL_ID
            IV_PROJECT_GUID = IV_PROJECT_GUID
          IMPORTING
            EV_RC           = EV_RC
            EV_MSG          = EV_RC
            ET_MSG          = ET_MSG.
        COMMIT WORK.
      ELSE.
        CALL FUNCTION 'RPM_DELETE_PROJECT_DATA'
          EXPORTING
            IV_EXTERNAL_ID  = IV_EXTERNAL_ID
            IV_PROJECT_GUID = IV_PROJECT_GUID
          IMPORTING
            EV_RC           = EV_RC
            EV_MSG          = EV_MSG
            ET_MSG          = ET_MSG.
      ENDIF.
    ENDFUNCTION.
    In above code how to capture 'EV_RC' when FM is called as background task.

    Prakash,
    CALL FUNCTION IN BACKGROUND TASK allows no IMPORTING parameters, so that your code will produce a syntax error.
    The calling program can only handle errors of remote function calls (RFC) if these are either
    - synchronous RFC  (that is CALL FUNCTION ... DESTINATION ...) or
    - asynchronous RFC (that is CALL FUNCTION STARTING NEW TASK ... DESTINATION ...).
    Both synchronous and asynchronous RFC allow the capturing of errors by means of exceptions. But that is a different topic.

  • Calling RFC FM in update or background task

    hi experts,
    I have a RFC FM in system B and i want to call it from system A. if the system B is down when the call happens then the call is lost. basically i want the call happen when the system B is up. somewhere i have read that when u call the RFC FM in update task/ background task , SAP will try to make the call  to system B at periodic intervals of time till the system B is up. is that so? what is the difference between calling the RFC in update task and background task?
    thanks

    Hi,
    the transactional RFC (tRFC) implements true asynchronous communication.
    Remote system need not be available at the time of the RFC Client tRFC execution.
    If the call is sent while remote system is unavailable, the call remains in the local holding queue and the calling program can continue to run without waiting the response of the execution.
    If the RFC server is not activated until a certain period, the call is scheduled as a background job
    For the transactional call to a remote function module we use the statement:
    CALL FUNCTION <func> IN BACKGROUND TASK <task> (DESTINATION dest) u2026
    The update task that you mentioned is something different than the RFC technique and in the case of the function module, the function must have the 'Update Module' parameters marked.
    For more info about this topic please check the link:
    [http://help.sap.com/saphelp_nw04/Helpdata/EN/41/7af4daa79e11d1950f0000e82de14a/frameset.htm]
    [http://help.sap.com/saphelp_nw04/Helpdata/EN/41/7af4daa79e11d1950f0000e82de14a/frameset.htm]
    Kind regards.
    Andrea

  • Creation of spool for job created by calling FM in background task

    Hi Gurus,
    1.Wanted to confirm if it is possible to attach spool to the job that has been created by calling a function module in background task.
    Currently I have created one RFC enabled FM and called it in background task. It runs fine, and the job is created which can be seen in SM37. But it does not contain the spool even if the RFC FM contains the code for list ALV.
    2. Also is it possible to control the name of the job created by calling the RFC FM in background task?
    Code for calling the FM is given below(ZK_XX is th RFC FM):
    CALL FUNCTION 'ZK_XX' IN BACKGROUND TASK
    CALL FUNCTION 'START_OF_BACKGROUNDTASK'
    EXPORTING
       startdate       = sy-datum
       starttime       = sy-uzeit
      NOSEND          = ' '
    COMMIT WORK.
    Thanks a lot for your help!!
    Warm Regards,
    Raveesh

    Thanks for replying.
    I need to do the processing in background. Hence using 'IN BACKGROUND TASK' addition.
    Please let me knowif you have some idea.
    Thanks & Warm Regards,
    Raveesh

  • Call Function in Background Task

    Hi all,
    I have written a method in which I call a function in background task, I would like to perform a task after the function has ended succesfully. this is possible with the addition PERFORMING 'next_task' ON END OF TASK.
    This is sadly not possible in a global class.
    How can I get info back on the state of the function in the background?
    greetings Fred.

    Hi,
       try using export import statement in FM
       call function ...
        flay = 'Y'.
        export flag to memory id 'TESt'
       endfunction
        import flag from memory id 'TEST'.
        if flag = 'Y'.
          perform next_task.
          endif.
    Regards
    amole

  • Facing issue with tRFC (CALL FUNCTION in BACKGROUND TASK DESTINATION

    In transcation CJ20N there is aBADI call ZCL_IM_CL_IM_PROJ_UPDATE in which there is a method
    IF_EX_PROJECTDEF_UPDATE~AT_SAVE.  My requirement is that when the status of the project is changed and saved then after the SAVE some actions are to be performed (BDC for transcation CJ30 & CJ9FS are to be called).
    Since this method is called AT SAVE and i need to call the bdc after the comit (of SAVE) is done. So I have made a RFC FM in which I am calling the bdc. and then calling the FM as
    CALL FUNCTION <FM> in BACKGROUND TASK DESTINATION <sy-sysid>.
    For the txn. CJ9FS bdc this method is working fine and bdc is called after SAVE but for txn. CJ30, at times,the bdc  is not working though if I run the BDC FM seperately using SE37 then its working fine.
    Can any body guide me where I am going wrong.

    The scenario works fine for me. The issue was unable to create a proper test condition in the RFC.
    CALL FUNCTION 'ZMY_RFCASYNC'
       IN BACKGROUND TASK
       EXPORTING...
       TABLES...
       EXCEPTIONS...
    Simulated error condition in 'ZMY_RFCASYNC'
    and got entry in SM58 by simply making an exception. 
    Thank you all.

  • Save Order - Call function in background Task

    Hi all,
    I have written a function module which is called in order save Badi and copies the system status on the Master contract to the sub contracts.
    This works fine but when I call this function in background task the status is not getting copied over.For testing I have created a program similar to function module and scheduled that in background and this was working as required.
    Can someone please let me know if I missed out anything or how can i resolve this issue.
    Any inputs in this regard would be very helpful.
    Thanks and regards,
    Vijay

    Hi Heinz,
    You can check the result in SM58 transaction.
    For more information pls. refer this thread :
    No IMPORTING parameters allowed in CALL FUNCTION IN BACKGROUND TASK
    Best regards,
    Prashant

  • Calling RFC enabled FM IN BACKGROUND TASK

    Hi Frnds,
    I have a requirement where in I need to call a FM which executes 'VA02' BDC in some user exit.
    Since this has to be executed after the commit work is executed in the calling program i am using the background mode.
    something like below,
      CALL FUNCTION 'Z_SD_AVAILABILITY_CHECK_BDC'
        IN BACKGROUND TASK
        DESTINATION 'NONE'
        TABLES
          t_vbap = xvbap.
    This above FM is RFC enabled.
    And this FM is also called successfully and VA02 is executed without any error. But the FM's session does not get killed after its executed completly. Instead it creates another session of the same FM and executes the BDC again. This is goion on and on and multiple sessions are created at the end.
    Am I missing something here? Do I have to include the Performing RETURN_INFO ON END OF TASK  also?
    Please give ur suggestions.
    regards,
    Karthick C

    Hi,
    Check the SM58 to see how many calls are there. It might be that the function is called multiple times every time the user exit is triggered. So put a break point in the user exit and check that the function is actually only called once per transaction.
    As the SAP help says that the calls are stored in the tables ARFCSSTATE and ARFCSDATA, it might be worth checking the entries of this table for the function calls before the transaction commit work is executed. See [here|http://help.sap.com/saphelp_nw04/helpdata/en/8e/d05f3ce4dd3370e10000000a114084/frameset.htm]
    regards,
    Advait
    Edited by: Advait Gode on Jun 22, 2009 11:19 PM

  • FM call in background task

    Hi,
    I have called a function module in background task. Inside this FM I create application log and put in all the messages in the log which can be viewed using the transaction SLG1. But if the creation of the log fails I want to display the info to the user and exit the FM. I cannot display the info using the Message statement here. I tried to raise an exception, etc. from this FM so that I can process the exception in the calling FM and display a message. But this does not work as the execution of the calling FM and called FM in rfc proceeds simultaneosly. I know I can see the error using transaction sm58 but I am looking for an option wherein I can directly inform the user. Does someone have a suggestion how can proceed with this?
    Thanks.
    Best Regards,
    Pooja

    Hi
    There are two ways for you to handle,
    one manually setting up the job through SM36 which is better and convinient,
    secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.
    Find below steps in doing both:
    Procedure 1:
    1. Goto Trans -> SM36
    2. Define a job with the program and variant if any
    3. Click on start condition in application tool bar
    4. In the pop-up window, click on Date/Time
    5. Below you can see a check box "Periodic Job"
    6. Next click on Period Values
    7. Select "Other Period"
    8. Now give '15' for Minutes
    9. Save the job
    In SM37 u can check the status of the jobs that u have assigned to background...
    Here u mention the job name or the report name to check the status of the job...
    After mentioning the job name or program name u just execute it.. ( without any name also u can execute then it gives u all the jobs set by your user name..
    the status colud be released,active,finished etc..
    Procedure 2 via Program:
    Below is a sample code for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.
    DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
          L_RELEASE(1) TYPE c.
       CALL FUNCTION 'JOB_OPEN'
         EXPORTING
           JOBNAME                = 'ZTEMP2'
        IMPORTING
          JOBCOUNT               = P_JOBCNT
        EXCEPTIONS
          CANT_CREATE_JOB        = 1
          INVALID_JOB_DATA       = 2
          JOBNAME_MISSING        = 3
          OTHERS                 = 4.
       IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
       SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
              TO SAP-SPOOL WITHOUT SPOOL DYNPRO
              WITH DESTINATION = 'HPMISPRT'
              WITH IMMEDIATELY = SPACE
              WITH KEEP_IN_SPOOL = 'X' AND RETURN.
       CALL FUNCTION 'JOB_CLOSE'
         EXPORTING
           JOBCOUNT                          = P_JOBCNT
           JOBNAME                           = 'ZTEMP2'
           STRTIMMED                         = 'X'
           PRDMINS                          = 15
        IMPORTING
          JOB_WAS_RELEASED                  = L_RELEASE
        EXCEPTIONS
          CANT_START_IMMEDIATE              = 1
          INVALID_STARTDATE                 = 2
          JOBNAME_MISSING                   = 3
          JOB_CLOSE_FAILED                  = 4
          JOB_NOSTEPS                       = 5
          JOB_NOTEX                         = 6
          LOCK_FAILED                       = 7
          INVALID_TARGET                    = 8
          OTHERS                            = 9.
       IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    Hope the above helps you.
    Alternately use CALL FUNCTION func IN BACKGROUND TASK
    Regards,
    Sree

Maybe you are looking for

  • Why does is the Content tab in Preferences missing?

    When I try to view the Content tab in Preferences, it shows the last tab I clicked on. For example, when I click on Tabs and then try to view the Content tab, it shows the Tabs tab.

  • Issue with SM30 in user defined transaction

    Hi,   I have a custom transaction from where I`m calling SM30 transaction skipping the inital screen of SM30. I`m running a background BDC program to call this transaction where in I give the table name to be changed / displayed and other conditions

  • Safari address bar - bookmarks

    When you click the address and search bar, your bookmark favorites and frequently visited sites show up. This to be honest is worse than a pop-up ad...it blocks my view from the page I am looking at, my favorites bar, and the tabs it is covering. Its

  • Logic quits unexpectedly- performing systm reinstall

    recently logic 8 has been crashing a bit, so i figured it would be a good idea to do a system reinstall. however I have a few questions before I go ahead with it if any of you have any advice. my gear- apple dual 2.7ghz power pc g5 with 4.5 gb ram, 3

  • What on earth is the solution for my new but problematic iPod??

    5th gerneration iPod,only bought 2 mths ago. nearly no use. I am a beginner to use it. now it cannot turn on by any way. I have tried all the suggestions in apple website incl. "5R". The last chance I turned on it,the battery is in red,low power.I th