Function module in background task

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

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

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

  • Error in debugging tRFC Function module (in background task) in SM58

    Hi,
    I am trying to debug this statement:
    CALL FUNCTION 'CRM_UPLOAD_TRIGGER'                 
      IN BACKGROUND TASK                               
      DESTINATION gv_smof_erpsh-rfcdest AS SEPARATE UNIT
    I have followed these steps:
    When you debug a program that calls function modules using the IN BACKGROUND TASK addition, they are processed in a background work process (additional internal session). If you set the In background task: Do not process option, the system collects the function calls, but does not start the background work process. The Debugger assigns a transaction ID, which identifies the background work process uniquely. You can now start the Debugger for the background work process using transaction SM58. You can select the function module concerned here, and then execute it via the Edit menu.
    but still i cant find any entry in SM58.
    Can anybody help me out in this?
    Thanks a lot.
    Best Regards,
    Shweta

    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

  • 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)?

  • Difference between calling a function module in background task and update

    Hi experts,
    Can someone explain me the basic difference between calling a FM in  background and update tasks?
    Also what is the advantage of using backgroud RFCs over the above 2.
    Thanks in advance,
    reddy

    This is essentially a difference of synchronization with the main program calling this FM.
    For Update task, we specify explicitely that we want to update some rows in a database table. But Update task is essentially for waiting that all tasks to do before are done and updating database at the end. The main point is that MF called in Update task wait for a COMMIT WORK to be executed.
    On the other hand FM in background task are executed immediatly and are not specific to updating database table : it can be a function that would return some values or something else like that.
    If you want to see more about difference between background jobs / update jobs, you can also have a look at transaction SM51. Here you will see all the servers composing your SAP instance and what kind of task they can execute :
    - background jobs corresponds to BATCH
    - update tasks corresponds to UPDATE
    Those 2 kinds of tasks stands not necessarily on the same server...
    Best regards,
    Samuel

  • Debugging the Functional Module in Background.

    I am calling a Custom Functional module in Background mode using the syntax CALL FUNCTION ZFM in background task.
    Can anyone tell how to debug the code using this..
    Thanks ,
    Yatish

    Hello Yatish
    You could try to use the following trick:
    (1) Put an endless loop into the coding of your function module where you want to start debugging, e.g.
      DATA:
        lx_exit_loop(1)     TYPE c.
      lx_exit_loop = ' '.
      DO.
        IF ( lx_exit_loop = 'X' ).
          EXIT.
        ENDIF.
      ENDDO.
    (2) Call your function module in background task
    (3) Call transaction <b>SM50</b> and search for the background process.
    (3) Choose from menu <i>Program/Mode -> Program -> Debugging</i>
    Now you the debugger should bring you right to your endless loop. Set lx_loop_exit = 'X' in the debugger and continue (F5 or F6).
    Regards
      Uwe

  • Jco Call a Function Module in BackGround

    Hello All.
    Some one can send me a simple exemplo how to call a ABAP Function Module in BackGround.
    Can i set this in Java side?
    ..or only set the BackGround Work Process in SAP side?
    In my java application call the Abap Function Module like this:
    client.execute(function);
    How to set parameters to execute the function in BackGround.
    My rpoblem is when the return the data to java side ...occurs the error TIME_OUT in Dialog WorkProcess.
    I need to call in background to better performance and to prevent the TIME_OUT.
    Best regards.
    Taylor.

    Hi.
    I don’t know how to do, but, you can do a previous RFC, this new RFC execute the original function in background mode. I did something like that:
    - JAVA: client.execute("RFC_FUNCTION", input, output);
    - SAP: RFC_FUNCTION:
    CALL FUNCTION func IN BACKGROUND TASK
                         [DESTINATION dest]
                         parameter_list
                         [AS SEPARATE UNIT].
    or
    CALL FUNCTION update_function IN UPDATE TASK
                                 [EXPORTING p1 = a1 p2 = a2 ...]
                                 [TABLES t1 = itab1 t2 = itab2 ...].
    I hope that help you

  • Call function module in backgrouns task and in update task

    Hi Gurus,Pls crear me on the " <b>Call function module in backgrouns task and in update task</b>".
    how it works and waht is the link with LUW  releated to these .
    also heard that commit work statement aslo linked with this.
    Pls clarfiy me with expalnation of code.

    Hi sridhar,
    the explanation already given is correct and good. Small add-on:
    All functions called during one LUW with addition IN UPDATE TASK are stored together with their actual parameters in a temporary memory area. The moment a COMMIT WORK is issued, the functions are released to be executed by a so-called update task which is running in the background. This explains why functions called in update task never return anything, no SY-SUBRC and no export or table parameters If a function called in update task raises an exception or runs into an error the calling user will get an express message informing about this. Also, all database updates done by this update process are rolled back to keep consistency.
    This proceeding helps to keep database tables consistent and allows the user to keep on doing his work before all database updates are complete. You may have seen messages like "material will be changed" after saving. If you open the same material immediately, you'll get a message "object locked by...<yourself>". This means the update task is still running.
    Regards,
    Clemens

  • Function module in background work process

    Hi All,
    i'm using trfc for processing FM only in background work process
    CALL FUNCTION 'FUNCTION_MODULE' IN BACKGROUND TASK
    but when i execute FM it's occupying two work process one is dialog (running current FM )and another one is background( running SAPLERFC) .
    so pls suugest me how to avaiod FM to occupy dialog workprocess.
    Regards,
    Anuj jain

    Hi Anuj,
    It unfortunately means:
    start FM in a particular time in Dialog work process
    The BACKGROUND word in abap syntax is misleading.
    For true background processing, i.e. background WORK PROCESS (of type BGD in SM50)
    ONLY  ABAP PROGRAMS or Commands or External Programs
    can be run under background work process. (as per SM36)
    Here we are trying a function module, which is not supported. This is as per my understanding.
    regards,
    amit m.
    Edited by: Amit Mittal on Aug 17, 2010 2:03 PM
    Edited by: Amit Mittal on Aug 17, 2010 2:05 PM

  • Function module for background jobs email

    hi abaper's
                     i hace to create a function module for background jobs this function module have to send an email automatically when a background job is assigned or processed in background.
    thnks n regards
    pardeep kumar

    hi dear
    open this site
    https://weblogs.sdn.sap.com/pub/wlg/781. [original link is broken] [original link is broken] [original link is broken]
    <removed by moderator>
    Edited by: Mike Pokraka on Aug 8, 2008 12:48 PM

  • How to run ABAP Function Module in Background Wchich Takes Long Time to Run

    How to run ABAP Function Module in Background FOR LONG TIME
    I am not that experienced with ABAP. I am on SAP BI 7.0. I WANT TO RUN A FUNCTION MODULE
    RSDRT_INFOCUBE_DATA_COPY.
    I used SE37 and then executed the module, I supplied  the parameters on the form which opped-up and then  program started running. . Program was however interrupted after 10 minutes by ABAP. How can I run  it in background without interruption?
    THANKS A LOT.

    Hi,
    You can call this FM in a program and run that program in background.
    Regards,
    Raju

  • Calling Function Module in Update Task

    Hello Experts,
                              Can anyone let me know about
    Calling Function Module in Update Task.
    Why do we use this " In Update Task "  ??
    How do we Use ??
    What is the Use... ??
    Kindly let me know....
    Thanks and Regards
    Pramod

    hi,
    Why do we use this " In Update Task " ??
    The main update technique for bundling database changes in a single database LUW is to use CALL FUNCTION... IN UPDATE TASK.
    How do we Use ??
    A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.
    What is the Use... ??
    Asynchronous update is useful when response time from the transaction is critical, and the database updates themselves are so complex that they justify the extra system load
    Real time scenario.
    Suppose a user wants to change an entry in a database table, or add a new one. He or she enters the necessary data, and then starts the update process by choosing Save. This starts the following procedure in the ABAP program:
    Firstly, the program locks the database entry against other users, using the enqueue work process (or the message server in the case of a distributed system). This generates an entry in the lock table. The user is informed whether the update was successful, or whether the lock could not be set because of other users.
    If the lock is set, the program reads the entry that is to be changed and modifies it. If the user has created a new entry, the program checks whether a record with the same key values already exists.
    In the current dialog work process, the program calls a function module using CALL FUNCTION... IN UPDATE TASK, and this writes the change details as an entry in table VBLOG.
    When the program is finished (maybe after further dialog steps), a COMMIT WORK statement starts the final part of the SAP LUW. The work process that is processing the current dialog step starts an update work process.
    Based on the information passed to it from the dialog work process, the update work process reads the log entries belonging to the SAP LUW from table VBLOG.
    The update work process passes this data to the database for updating, and analyzes the return message from the database. If the update was successful, the update work process triggers a database commit after the last database change and deletes the log entries from table VBLOG.
    If an error occurred, the update work process triggers a database rollback, leaves the log entries in table VBLOG, flags them as containing errors, and sends a SAPoffice message to the user, who should then inform the system administrator.
    The corresponding entries in the lock table are reset by the update work process.
    Hope this is helpful, Do reward.

  • 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.

  • Use of function called "in background task"

    Hi folks!
    In my company there are rumors that a function called "in background task" can be used to make sure that all database changes of previous statements are already persisted. This would mean that a function called "in background task" can be used to read data from database that has been written by the same report - in any case (update dispatching over several instances,...). Usually this won't be a good idea (we know well about SAPs update concepts and read everything about it on help.sap.com). Has anybody some experiences about this or is there even a guru, able to explain why it will always work (or not)? We don't have evidence that the database has finished writing for sure when the function starts - that's why I'm worried.
    Example:
    REPORT test.
    INSERT something to database.
    CALL FUNCTION function in background task.
    End of the report
    Will it always work (when testing, it does)?
    Any help will be appreciated!
    Greetings

    Hi,
    Logically it is correct. BACKGROUND TASK Triggers an asynchronous process. This FM is executed in multiple steps.
    In first step system save the data passed to FM interface to buffer. When ever program encounters Explicit/implicit commit, the source code of the FM is processed.
    Note: You can't get back the data from this FM call.
    Check the F1 help on call function statement. You will get much more details.
    Thanks,
    Vinod.

Maybe you are looking for

  • Migrate documents from the windows file server into km

    Hi All, I have around 100 GB of documents in a file server and i want to migrate the same data in to KM. I am sure that there should be some standard process to do this,can any one please help me out in solving this. Thanks Ajay

  • Floppy  Drive - 3 1/2

    Is it possible to get a Floppy Drive that reads 3 1/2 floppies for the Intel Mac? The reason I ask is I have quite a few graphic floppies that I would like to use if I can. If I there is one, would the Intel be able to read them or would I have probl

  • IndexOutOfBoundsException and invokeAction

    Hello, I have an IndexOutOfBoundsException when trying to rollback and editable table. In my use case, I don't want to see "no data found", so I must createInsert a row if there is no data found. I use an involeAction with a refreshCondition for this

  • Subtotals in adobe forms

    Hi,    Sorry for this question.Although this has been asked a lot of times,i am getting problems. I want to print the subtotal for each page in adobe forms.I am getting the total at end of last page. This is the code given in sdn and saptechnical. va

  • Query to Find the Student ids by group

    Hi, I have a table which has 2 columns student_id and Course_id. Sample Data Student_id Course_id 1 -->     1 1 -->     2 1 -->     3 1 -->     4 2 -->     1 2 -->     3 3 -->     1 3 -->     2 3 -->     4 I want to find those students who have taken