Is It Possible to use Call Function in update task in perform on commit

Hi Friends,
I have to send an email once the commit work is done. so i am writing code like this,
Perform send_email on commit.
form send_email.
call function 'SO_NEW_DOCUMENT_SEND_API1' in update task
endform.
endform.
.... ( Some other code)
commit work.
But, I am getting error saying Update task is not possible. Please suggest me how to solve this.
Thanks in Advance,
Phani.

Hi Phani,
      Check whether <b>COMMIT Work</b> has be performed. I think this might be the problem.
Regards,
Prashanth

Similar Messages

  • Call function '' in update task - code inside is BDC

    hi to all,
    in using call function '' in update task
    the code inside is bdc. is this possible? 
    my scenario is from VA01 then post billing to VF01,
    i am using user-exit MV45AFZZ in subroutine userexit_save_document.
    i need to post billing after va01 save.
    thanks to all.

    To debug in the update task, you have to set that option on in the debugger.
    If the user exit runs in the update task, then you must have something like: CALL FUNCTION MODULE my_fm_to_do_BDC STARTING NEW TASK.   ( This function module should wait until the SD is created.  You might want to check in a loop, with a WAIT command.   Once it is created, then you start your BDC and CALL TRANSACTION. )  This is NOT an update function module.  It may need to be RFC enabled - I'm not certain at the moment.
    If the user exit doesn't run in the update task, you need to create, and call from the user exit, an update function module that calls your function module "my_fm_to_do_BDC" STARTING NEW TASK. 
    The attribute "collective run", which is V3, means that the update task won't run that function module until a regularly scheduled job on the application server runs.  For processing to run during the rest of the SD save, you must use V1 (could be run in any order with other V1s) or V2 (Will run after V1, but in any order with other V2s).  Typically, I use V2 for this kind of task.
    matt

  • Queries on  Call Function In update Task

    Hi ,
         I have a requirement where I have to update a ztable in background once I execute the report.THe requirement is to exceute the updation in background.Will
    Call funtion in update task help me?If yes, I have never used call function in update task .so can you guide me on the same.If no, how best can  I acheive this?
    Thanks & Regards,
    Jyotsna

    Hi,
    look F1 to call function pls:
    It is not executed at once, but the data passed with EXPORTING or TABLES is placed in a database table and a subsequent COMMIT WORK then causes the function module to be executed by the update task.
    -> so in error case you can analyse err. with TA SM13
    (update records)
    regards Andreas

  • Problem when using Call FM IN UPDATE TASK.

    we plan to update ztable using Call FM in update task, and write the success/error message into log.
    Does below is right??  I found the commit work can not be used here. Thanks..
    CALL FUNCTION 'ENQUEUE_ETABLE'.
    IF sy-subrc = 0.
    CALL FUNCTION 'update_ztable'' IN UPDATE TASK.
    Endif.
    COMMIT WORK and wait.
    IF sy-subrc <> 0.   
         ROLLBACK WORK.
         write error log.
    Else.
        Write successful log.
    Endif.
    CALL FUNCTION 'DNQUEUE_ALL'.

    Hi ,
    Please see the refernce of UPDATE FUNCTION MODULES:
    UPDATE FUNCTION MODULE
    -In the attributes tab, under processing type, choose Update Module, 
    Start Immediately. Define your import parameters, enter the source
    code, All validations should have been done prior to the call to this
    function module, so all you need in the source, is the updating of the
    database, INSERT, MODIFY, UPDATE, whatever.
    -When you call you function module, use IN UPDATE TASK, after the call, 
    COMMIT WORK. The commit work will trigger the db update.
    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.
    Q:We are calling Sales Order Change in update task inside the user Exit MV50FZ1. We can see that the FM is called in update task after the commit work and the return of the FM shows the success message. But still the changes are not saved to the DB.
    A: check sm21 or sm13 to see if the update was successful  .. In SM21 I checked. It is giving me the error Transaction Failed
    Reward if useful
    Thanks
    Jagadeesh.G

  • Call function in update task empty variables error

    Hello,
    I'm experiencing a weird error while using the addition "In update task".
    My Scenario is the following:
    Use the bapi_goodsmvt_create -> if there are no errors, fill some values and call my function and then commit everything.
    The problem is, when the function runs in update task, all import parameters are empty!
    Also, this only happens in the following code structure
    CALL METHOD run_migo( IMPORTING bapireturn = t_bapireturn).
    IF t_bapireturn IS INITIAL.
      CALL METHOD save_custom_tables. "this runs my function 'IN UPDATE TASK'
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.
    if I commit inside the method SAVE_CUSTOM_TABLES, the data is passed normally to the function, if I commit like the code above, everything is empty.

    Here's the code:
    METHOD save_partial.
      DATA: t_wegritm    LIKE gt_wegritm,
            t_tegrp_parc TYPE TABLE OF ztegrp_parc,
            w_tegrp_parc TYPE ztegrp_parc,
            w_tegrk_parc TYPE ztegrk_parc.
      FIELD-SYMBOLS <w_wegritm> LIKE LINE OF t_wegritm.
      t_wegritm = gt_wegritm.
      DELETE t_wegritm WHERE mengee IS INITIAL.
      CHECK NOT t_wegritm IS INITIAL.
    *-->save xml iten
      LOOP AT t_wegritm ASSIGNING <w_wegritm>.
        MOVE-CORRESPONDING <w_wegritm> TO w_tegrp_parc.
        w_tegrp_parc-id = gw_tegrk-id.
        w_tegrp_parc-gr_docto = <w_wegritm>-gr_docto.
        w_tegrp_parc-gr_mjahr = <w_wegritm>-gr_mjahr.
        w_tegrp_parc-gr_zeile = <w_wegritm>-gr_zeile.
        APPEND w_tegrp_parc TO t_tegrp_parc.
      ENDLOOP.
      MOVE-CORRESPONDING gw_tegrk TO w_tegrk_parc.
      CALL FUNCTION 'Z_SAVE_PARTIAL'
        IN UPDATE TASK
        EXPORTING
          iw_tegrk_parc = w_tegrk_parc
        TABLES
          it_tegrp_parc = t_tegrp_parc.
    ENDMETHOD.
    I tried to re-create this scenario with a local class, but the code that I originally sent worked(the commit work outside of the routine).

  • Call Function in Update task

    I have written the FM Call function 'COMMITROUTINE' in update task.
    but this FM is not getting triggered when some commit happens. In all, this FM is not commiting tha data in the table.
    CALL FUNCTION 'COMMITROUTINE' IN UPDATE TASK
      EXPORTING
        lt_dfkkbrlevyrec       = lt_dfkkbrlevyrec
    and the
    What is missing in it?
    Regards,
    Seema Dadhwal.

    Hi,
    if you want to call your FM when a commit happens you should write a routine which is called upon commit and this routine will call your fm.
    e.g
    form call_my_fm .
    CALL FUNCTION 'COMMITROUTINE' IN UPDATE TASK
    EXPORTING
    lt_dfkkbrlevyrec = lt_dfkkbrlevyrec
    endform.
    perform call_my_fm on commit.
    commit work. " now your routine will be called
    Kostas

  • Calling function in Update Task problem

    Hello Friends,
    I'm calling FM 'REVISION_LEVEL_POST' in Update Task to insert a revision level for a material when saving a Change Master (CC02 T-Code). But the calling is triggered a bit early (Before updating the Data Base AEOI Table!). An Update Task FM is called right after the COMMIT WORK is executed. Here in my case, a commit work is done but not for my change Master but for a text... So my FM does not find the record to be updated.
    Is there a way to solve this ?
    Thank you for your Help!

    Check the log in VBLOG table ..

  • COMMUNICATION_FAILURE in CALL FUNCTION STARTING NEW TASK/Background task

    Hi friends,
    I am trying to use a FM in a Print Program (when user prints a document), using
    CALL FUNCTION STARTING NEW TASK 'TASK' DESTINATION 'NONE'.
    The program is triggered from VL02N tcode.
    But it's giving an exception - COMMUNICATION_FAILURE. Message is Error when opening an RFC connection
    I also tried
    CALL FUNCTION IN BACKGROUND TASK as Separate Unit
    then error message pops up - Database error when recording transactional RFC
    We are attaching a PDF file of the print to content server within this function module and because the "attaching" takes a while, this part needs to be detached from the print program so that we can avoid performance issue.
    I can't figure out the issue. i gues this is happening because print program is already running in Update task. I also tried with RFC enabled FM. Please help me resolve/understand the issue.
    Appreciate your help.
    Regards,
    Ronjan.

    Hi Ronjan,
    COMMUNICATION_FAILURE. Message is Error when opening an RFC connection
    I guess the reason for the above is that every RFC call synchronous/Asynchronous issues a DB COMMIT and we cannot have DB COMMITs in the V1/V2 updates, please go through the link below.
    http://help.sap.com/saphelp_nw70ehp2/helpdata/en/23/e9aa61638e404d81575e939b5cd847/frameset.htm
    Now, the possible solutions i can think of are,
    1) Call the FM in update task delayed start and try.
    2) Or create a report program and use SUBMIT (look at the job options as well).
    @Mainak
    3. Write a statement COMMIT WORK AND WAIT. This will actually invoke the FM
    Mainak, this will lead to a Update termination, as the program is running in an update task.
    Regards,
    Chen

  • Call function in background task... How to get the result?

    I want to use Call function in background task parameter.
    But I cannot find the result of this function. (No export parameter, no table result, no exception)
    How to get the result of this function module? Correct or not?

    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

  • Use of CALL FUNCTION - STARTING NEW TASK parameter_list.

    SELECT strt_code
                 city_code
                 commu_code
                 regiogroup
          INTO TABLE gt_adrstreet1
          FROM adrstreet
          FOR ALL ENTRIES IN gt_street_district
          WHERE strt_code EQ gt_street_district-strt_code.
    To optimize the performance of teh above query I am planning to use call function CALL FUNCTION - STARTING NEW TASK .....
    by spliting the above internal table gt_street_district into two internal tables and use the value of each internal table into two different queries and these queries will be put in call function - start new task ....so that these queries are run in different workprocess and thus improve the performance of the program.
    Can you please let me know if this would be a good option and also how to implement the same.
    Thanks.....

    >To optimize the performance of teh above query I am planning to use call function CALL FUNCTION - STARTING NEW TASK .....
    nonsense! You should not try parallel processing for a non-optimized SELECT statement.
    Better add the first key field of the WHERE condition as said above and check
    + whether the driver table is empfty
    + and whether there are duplicated entries
    ... And it is also a good idea to really use the SINGLE RECORD BUFFER, therefore you must write
    field-symbol:  <fs>  type ...
    LOOP AT gt_street_district ASSIGNING <fs>
       SELECT *
                    INTO TABLE gt_adrstreet1
                    FROM adrstreet
                    WHERE counrty =
                     AND       strt_code = <fs>-strt_code.
    ENDLOOP.
    Then it will be extremely fast!

  • Modify toolbar for alv using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

    Hi Experts,
    I am using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' inside an exit.
    I need to modify the tolbar with just three options :-
    a-  add new row
    b- delete rows
    c- save data
    Please guide me step by step as how to proceed as I am very new to ALV.
    and after applying your solution to show the toolbar what should I do to Make these buttons working.
    Thanks a lot for your replies in advance.
    regards,
    Udit

    I'm not really sure why you would use an ALV grid display in a user exit.  I'm not sure how that works.  Another point is that the ALV object is really easier to use once you get used to it.
    However:
    Usually you would create a GUI status, and just add your buttons to it.  Then when the function module is called specify the gui status, and user command.
    For example
    v_repid = sy-repid.
    w_user_command = 'USER_COMMAND'
    w_set_status = "Status you define below.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_bypassing_buffer       = 'X'
          i_callback_program       = w_repid
          i_callback_pf_status_set = w_set_status
          i_callback_user_command  = w_user_command
          is_layout                = w_layout
          i_structure_name         = 'ZGOODSMOVE'
        tables
          t_outtab                 = gt_outtab
        exceptions
          program_error            = 1
          others                   = 2.
      if sy-subrc <> 0.
        message e000 with 'Error in Displaying the Output Report'(025).
      endif.
    Put your code for the different functions into one user function module
    form user_command using r_comm like sy-ucomm
                            rs_selfield type slis_selfield.
      read table it_final1 index rs_selfield-tabindex.  " This will give you back the row you selected
      if sy-subrc = 0.
      endif.
    endform.
    To define the GUI Status:
    Copy the status from
    Then change it to add your fields

  • Call function starting new task:

    I am trying to create a program in which few database update are mentioned.
    after database updates , I am calling a function module using starting new task
    in which I want to commit database updates inside in function module.
    Problem is I want to commit only database updates if function module , not of main program. For that I tried using COMMIT WORK in function module and rollback statement after calling FM.  But it is not working.COMMIT statement in FM also commiting database updates of main program also that is not required.
    Can anybody help me in solving this problem.
    Thanks
    Ruchika

    I think this may be caused by an implicit database commit performed by the system at the moment of calling a fm with "starting new task".
    Try the following test:
    - Put "rollback work" statement inside your fm which you call "starting new task" (instead of "commit") and check if the updates performed by the code executed before the call to this fm are stored in db - inspite of the rollback. If they are (as I suppose) this means that the commit effect you observe is not due to the "commit work"  statement executed inside your fm but due to an implicit commit issued automatically at the time of calling the fm. If this is the case the solution could be placing the code which you now execute before "call function...starting new task" into a seperate fm called "in update task" - then the final commit or rollback statement in your main program should have the expected effect.
    regards

  • CALL FUNCTION STARTING NEW TASK  DESTINATION

    Hi All,
    I have tried to use CALL FUNCTION 'ZWHV_TEST' STARTING NEW TASK 'TEST' DESTINATION 'NONE' But it didnt work.
    Please explain me  to use above statement and detail me more about NEW TASK 'TEST'.
    How to declare TEST in new task ?
    Thanks ,
    Vinay.

    >
    Vinay parakala wrote:
    > ...But it didnt work.
    Moderator message - Give more information please in a new thread - post locked

  • Parallel Processing Issue : call function starting new task

    Hi
    I am using the parallel processing functionality using the call function new task  destination in group default  Performing    on end of task  inside a loop ( i am splitting the internal table )
    However when i am debugging the code, i am able to see the function module( it opens a new session in debugging ) ,  and i see that new task is started after the RFC Function module is executed .
    How is this parallel processing ? I mean the new task starts after control returns back to main program , after the execution of the RFC FM.
    I thought the idea was to have the same FM executing in multi threads. So that time is saved.

    Thanks for the answers.
    There were too many  complications in the 'call function in new task '  option.
    So we are trying it with the job submit option. So we are splitting up the data into smaller tables and submiting it with this statement : Submit  'prog' with selection-table 's_sel' via job 'job' and return .
    Thanks

  • 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

Maybe you are looking for

  • Iphone import is not working

    Final Cut Pro X is no longer showing my iphone in the import screen, i only see the Appe Build-in iSight. Some weeks ago it was working fine. I can't find the problem... Final Cut Pro X 10.0.4 Iphone 4

  • Mail quits every time i try to open it

    i am a new mac user, i just signed up to the .mac service, everytime i now try to open mail, it quits before i can do anything, this happens if i try to open it directly or indirectly (for example when i want to send a note to people to invite them t

  • Itunes keeps crashing at launch

    I've tried every single waste of time I found on Google and on this forum. iTunes just refuses the launch for about 4 weeks now. In the meantime I have got the new iLife etc. No use. called Apple Care and spent several times 10 minutes waiting to not

  • Expanding stacks loses files from Lightroom - help!

    I've just discovered the delights of stacking, and have stacked brackets in several folders. The first time I expanded these (via Photo > Stacking > expand all stacks), in order to rename all the files in the folder, it worked fine. However since the

  • BAPI_GOODSMVT_CREATE - Movement type 309

    I am using  this BAPI to do a 309 movement.  I get the error message M7 E021                                                                  Deficit of SL Unrestricted-use . I do not get the error message for the same data when i use MB1b.  The prob