Call function moduel in STARTIG NEW TASK

Hi All,
I am calling a custom function module using " <b>starting new task</b>
  call function 'Y_CT_EVENT_TRIGGER'
    starting new task yscchdr-docno
    exporting
      event   = v_event
      objtype = c_yct
      ntime   = v_ntime
    tables
      xyctc   = i_yct_p.
I am calling this function module in a Loop statement
I like know how we can find the previous call has been completed or not?
ie Within the loop i am processing first record and calling this function module, then i am going to second record . before calling this function module for second record i want to know the first record call is completed or not?
Thanks for your help.
aRs

Do like this and try..
Add one more field to ur internal table with name STATUS(20).
LOOP AT ITAB
  * call the FM here
  IF SY-SUBRC EQ 0.
    ITAB-STATUS = 'Completed'.
  ELSE.
    ITAB-STATUS = 'Not Completed'.
  ENDIF.
MODIFY ITAB INDEX SY-TABIX TRANSPORTING STATUS.
ENDLOOP

Similar Messages

  • Call function ... starting new task endless

    Hi to all,
    this post is ideally the continious of my previous post
    "how to attach custom code after invoice create/modification".
    Here the problem.
    In the BADI of the invoice document i call a custom function module (F1) with the addition "in update task". This to ensure that the code inside is executed only if the commit is triggrered.
    In this function module, i call another custom function module (F2), with the addition "starting new task".
    This function module (F2) contains a batch that waits 10 seconds (to ensure the "standard" modify) and then modify the invoice document with my custom data (by a call transaction).
    The problem is that this new task is .... endless !!
    I watch it writing a log file after the call transaction. Using AL11, i watched that every 10 second, the file is updated.
    Seems that this new task never ends: it call the trasaction, it writes the log file and the start again.
    The only way i have to stop that, is modify manually the same invoice document with VF02 trx.
    At exit, i don't save data (otherwise the endless cycle begins again) and then i watch that the log file stops to be updated.
    This task must be executed just one time. I've already try to put "exit" instruction at the end of the function module, but it doesen't work, the task start again and again.
    How i can solve this problem?
    Usefull solutions/hints/ideas etc will be sure rewarded (as usually).
    Thx a lot
    Andrea

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

  • Calling function module in the background task

    Hello everybody,
    I have a function module which wil create conditon records,the problem is it has performance problems because of which i am planning to make this as background job.
    Can any one of please tell me how the call function ' fun name ' in background task behaves.
    Regards,
    Aruna

    hi,
    try to refer to the link below:
    http://help.sap.com/saphelp_nw04/helpdata/EN/8f/53b67ad30be445b0ccc968d69bc6ff/content.htm
    i hope it helps
    regards
    arjun

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

  • Starting new task task .. performing subroutine .... error

    HI.
    i used a Perform to call a Function module.
       Perform <form name which contains the Function module>.
    I am calling the FM as -
    Form
    data: done type c value 'X',
              functioncall1(1).
       call function <FM name>
                      starting new task <Taskname>
                      destination in group default
                      performing <subroutine> on end of task
                        Exporting
    wait until functioncall1 = done.
    Endform
    Later -
    Form <subroutine> using taskname.
      receive results from Function "FM name'
                                       importing
    functioncall1 = done.
    endform.
    i do not get the importing data.. the passing Importing parameter are not recognized in the subroutine form..
    can any one check and inform me the problem.
    thanks in advance.
    Regards,
    AJ.

    Hi,
    You need to define the internal table globally.
    Regards,
    Nandha

  • Facing problem in call function starting new task taskname

    Hi all,
    when i call a function module using starting new task, it is failing with sy-subrc 3. can anyone guide me in this.
    see the code :
      DATA   lv_taskname(7) TYPE c VALUE 'PEM_EXE'.
        CALL FUNCTION 'PEM_SCHEDULE'  STARTING NEW TASK lv_taskname
             EXPORTING
                  iv_packid             = gv_packid
                  iv_pebid              = ls_alv_out-peb_id
             EXCEPTIONS
                  invalid_state_request = 1
                  database_error        = 2
                  OTHERS                = 3.
    Thanks in advance.
    Best Regards,
    Prashant

    when i change the function module from normal to remote, it gives me a error that the "generic types are not allowed in RFC", but i have not given any generic type in the parameters.
    see the signature of the function module.
    *"  IMPORTING
    *"     VALUE(IV_PACKID) TYPE  CNVMBTPACK-PACKID
    *"     VALUE(IV_PEBID) TYPE  CNVMBTPEB-PEB_ID
    *"  EXPORTING
    *"     VALUE(EV_ERROR_DETECTED) TYPE  C
    *"     VALUE(EV_STOP) TYPE  C
    *"  EXCEPTIONS
    *"      INVALID_STATE_REQUEST
    *"      DATABASE_ERROR
    *"      FORIEGN_LOCK
    Can u please check it and find out the problem
    Thanks,
    Prasanth

  • Call function IN BACKGROUND TASK don't work

    Hello,
    I've a interface RFC to JDBC asyncronous.
    When i call function in R3 (IN BACKGROUND TASK), sy-subrc = 0, however i don't see any message in SXMB_MONI and runtime workbench.
    The CC sender (for RFC) is OK,
    what happen?
    thanks very much

    Have this code after your call function:
    CALL FUNCTION 'START_OF_BACKGROUNDTASK'
         EXPORTING
              STARTDATE = SY-DATUM
              STARTTIME = TIME
         EXCEPTIONS
              OTHERS    = 1.
    IF SY-SUBRC = 1.
      EXIT.
    ENDIF.
    COMMIT WORK.
    Also, if you want to call your RFC function module in async mode, you can try
    Call function '<fm name>' in update task....
    Regards,
    Ravi Kanth Talagana

  • Call function module in update task

    Hi
    I am using the follwoing logic in my prog
    CALL FUNCTION 'Z_Update _Task'    In update task
      EXPORTING
        t_vbak        =  t_vbak.
    But the program goes to dump at call function
    Please let me know if the syntax i am using is correct.
    Edited by: kittu reddy on Feb 28, 2008 5:29 AM

    It might be the type conflict . Please check once .
    Here am giving some information abt UPDATE TASK.
    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
    Thanks
    Jagadeesh

  • Calling fm in new task only when it is possible.

    I'm calling a fm in a new task, and I need to check it is possible to open a new task before proceeding.
    How can I check the number of open tasks? How can I check the maximum number of tasks allowed?
    Thanks in advance.

    Hi!
    You don't have to check it, it is handled by SAP automatically.
    The only requirement, there has to be at least 3 dialog processes in your SAP system.
    For this check transaction SM50.
    Because startin an FM in a new task is an asyncronous processing, it's result is not important to your program run.
    Regards
    Tamá

  • Remote call function and destination

    Hi all @SAPforums,
    I used to call remotely a custom function, in a report, from many backends:
    CALL FUNCTION ZFOO destination mydest
    where mydest is a string containing the name of an RFC destination.
    My question is: is there a way, on the destination machine, to get the name/id of the "caller" ?
    The question arises from this task: I have to use the caller ID in a WHERE clause of a SELECT statement I have to write in ZFOO. I can - of course - pass the caller ID by adding a new parameter to the function, but this would make necessary a change on the CALL FUNCTION in every backend (quite expensive task, in terms of time). So if it's possible, from the callee, to get the name of the caller, I could just modify the function leaving the calls in every backend as they are.
    Thanks in advance

    >
    Matteo Montalto wrote:
    > Hello Wolfgang,
    > sorry for the stupid question... what does "destination" stands for?
    > Thanks for the help
    Hi ,
    they are two types of RFC calling is ther..
    1......
    CALL FUNCTION "function0module-name' DESTINATION "DEST" 
    --that means you are picking data from another r/3 sytem using detination from 'DEST'..
    2....
    CALL FUNCTION "function0module-name' IN BACKGROUND TASK DESTINATION "DEST" 
    --that means you are sending data to another r/3 sytem or any other sytem XI or and EDI
    using detination from 'DEST'..
    for 1 and 2..
    --go to t-code SM59 and see the DEST what type of connection is and what system it is connected..
    Regards,
    Prabhudas

  • STARTING NEW TASK

    can ny 1 give me a simple example as to WHY call function STARTING NEW TASK is used ???
    i need a very very simple example to demonstrate the concept

    hi there...
    Syntax
    CALL FUNCTION func STARTING NEW TASK task
                  DESTINATION {dest
                  parameter list
                  {PERFORMING subr}.
    Additions:
    1. ...DESTINATION IN GROUP { group |DEFAULT}
    2. ...{PERFORMING subr}|{CALLING meth} ON END OF TASK
    Effect
    Asynchronous call of a remote-capable function module specified in func using the RFC interface. You can use the addition DESTINATION to specify a single destination in dest, or to specify a group of application servers by using IN GROUP. The latter supports parallel processing of multiple function modules. The calling program is continued using the statement CALL FUNCTION, as soon as the remotely called function has been started in the target system, without having to wait for its processing to be finished. You can use PERFORMING and CALLINGto specify callback routines for copying results when the remotely called function is finished. Character-type data objects are expected for func and dest.
    If the destination has not been specified, the destination NONE is used implicitly. When the destination NONE is used, a new main session is opened for the current user session. The asynchronous RFC does not support communication with external systems or programs written in other programming languages.
    A character-type data object must be specified for task, one which contains for the remotely called function module a freely definable task ID that has a maximum eight digits. This task ID must be unique for each call, and is handed to the callback routines for identifying the function. Each task ID defines a separate RFC connection with its own context, meaning that, in the case of repeated function module calls of the same task ID, the global data of the relevant function group can be accessed, if the connection still exists.
    In dialog processing, note that the maximum number of six main sessions cannot be exceeded, else an error message is displayed.
    Addition 1
    ... DESTINATION IN GROUP {group|DEFAULT}
    Effect
    Specifying IN GROUP as a destination allows you to execute multiple function modules in parallel on a predefined group of application servers in the current SAP system.
    For group, you must specify a data object of the type RZLLI_APCL from the ABAP Dictionary, one that is either initial, or one that includes the name of an RFC server group created in transaction RZ12. When specifying DEFAULT, or if group is initial, all application servers that are currently available in the current SAP system are used as a group. Only one RFC server group may be used within a program. During the first asynchronous RFC using the addition IN GROUP, the specified RFC server group is initialized. For each asynchronous RFC where the group is specified, the most suitable application server is determined automatically, and the called function module is executed on this.
    If the function module cannot be executed on any application server, due to not enough resources being currently available, this leads to the predefined exception RESOURCE_FAILURE, to which a return value can be assigned, in addition to the remaining RFC exceptions. For this exception, the addition MESSAGE is not permitted.
    ·        The parallel processing of function modules using the addition IN GROUP makes optimum use of the resources available, and is preferred to self-programmed parallel processing with destinations that are specified explicitly.
    ·        An application server that is used as part of an RFC server group for parallel processing must have at least three dialog work processes, of which one is currently free. Other resources such as requests in the queue, number of system logons and so on, are also taken into account, and are not allowed to exceed certain limit values.
    ·        To ensure that only those application servers that have enough resources are accessed, we recommend that you work with explicitly defined RFC server groups instead of working with the addition DEFAULT.
    ·        The function modules of the function group SPBT provide service functions for parallel processing, for example, initialization of RFC server groups, determining the used destination, or temporarily removing an application server from an RFC server group.
    Addition 2
    ... {PERFORMING subr}|{CALLING meth} ON END OF TASK
    Effect
    You can use this addition to specify either a subprogram subr or, as of Release 6.20, a method meth as a callback routine, which is executed after the asynchronously called function module has finished. For subr, you have to directly specify a subprogram of the same program. For meth, you can enter the same details as for the general method call.
    The specified subprogram subr can have exactly one SING parameter of type clike only. The method meth must be public, and can have only one non-optional input parameter p_task of type clike. When the RFC interface is called, this parameter is supplied with the task ID of the remotely called function that was specified in the call in task. The results of the remote function can be received in the subprogram subr or method meth using the statement RECEIVE. In the callback routine, no statements can be executed that cause the program run to terminate or end an SAP LUW. Statements for list output are not executed.
    Prerequisite for executing a callback routine is that, after the remote function has ended, the calling program is still internally available. It is then executed the next time the work process is changed. If the program has ended, or if it is part of a call sequence in the stack, then the callback routine is not executed. The statement WAIT can be used to stop the program execution until certain or all callback routines have been executed.
    CALL FUNCTION - STARTING NEW TASK parameter_list
    Syntax
        [EXCEPTIONS exc1 = n1  exc2 = n2 ...
    Effect
    These additions are used to assign actual parameters to the formal parameters of the function module, and return values to exceptions that are not class-based. These additions have the same meaning as for the synchronous RFC. The only exception is that no values can be copied with IMPORTING and CHANGING.
    do reward if helpful

  • Starting new task in FM

    Hi,
    I have FM 'update_table' with asynchrounous call(FM which use starting new task). This FM updates the table and commits the work.But when I try to read the datas from table I don't get the updated datas.This happens only in in real scenario.
    When I try to debug the program it works fine and I get the updated data.
    Let me know how to resolve the issue?
    thanks
    Suganya

    Hi,
    As you want to update table in the function module, are you calling this fm in UPDATE TASK?
    Here are more details about the command.
    CALL FUNCTION func IN UPDATE TASK.
    Extras:
    ... EXPORTING  p1 = f1     ... pn = fn
    ... TABLES     p1 = itab1  ... pn = itabn
    Effect
    Flags the function module func for execution in the update task. 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. Update function modules must be flagged as such in the Function Builder
    The return value is not set.
    Addition 1
    ... EXPORTING p1 = f1 ... pn = fn
    Effect
    Values of fields and field strings specified under EXPORTING are passed from the calling program to the function module. In the function module, the formal parameters are defined as import parameters. In the interface definition, default values must be assigned to all import parameters of the update function module.
    Addition 2
    ... TABLES p1 = itab1 ... pn = itabn
    Effect
    TABLES passes references to internal tables. All table parameters of the function module must have values.
    Note
    With update function modules, both import parameters and exceptions are ignored when the call is made.
       1. During updating processes of function modules, you may not make any calls using the language statements SUBMIT, CALL DIALOG, CALL SCREEN, CALL TRANSACTION, COMMIT WORK or ROLLBACK WORK . All other language elements that trigger a database Commit (for example, a screen change using the MESSAGE statement) also lead to a runtime error during updating.
    ashish

  • Starting new task inside an Update Task

    Hi guys,
    I need an expert opinion for a problem I'm facing at the moment.
    The requirement is this: I need to trigger a function module during the update task of a material document.
    This function module however should not slow down the posting of the document, so it must not be in the same LUW, but in a separate task.
    My question is: does it work to call a function module with STARTING NEW TASK inside an UPDATE TASK (for example a user exit) and if it does work, what's your opinion on it? Is if safe? Does it come with problems? According to the SAP documentation, STARTING NEW TASK does not trigger a COMMIT when it's called inside an update task.
    The alternative would be to trigger a work flow, but that's much more work.
    Any input is welcome.
    Thanks.

    Hello Janis,
    Just to reiterate this aRFC call triggers an implicit database commit. So the OP is partially correct
    Klaus Kronawetter we have 2 things which we need to consider -
    Asynchronous RFC triggers a database commit in the calling program.
    Any database commits or database rollbacks that occur within the update task cancel the update.
    Simply put, as per SAP documentation, you cannot use aRFC within an update task.
    BR,
    Suhas

  • Remote call function troubleshooting

    I am trying to connect to a target ECC6.0 system from 46c system using SM59 (remote logon). For some reason it keeps displaying the login screen everytime even though I have specified the user and password details. The login screen shows up evertime with current user id in source system.
    Is there any configuration that needs to be done in source or target system so that the user details are passed correctly?

    >
    Matteo Montalto wrote:
    > Hello Wolfgang,
    > sorry for the stupid question... what does "destination" stands for?
    > Thanks for the help
    Hi ,
    they are two types of RFC calling is ther..
    1......
    CALL FUNCTION "function0module-name' DESTINATION "DEST" 
    --that means you are picking data from another r/3 sytem using detination from 'DEST'..
    2....
    CALL FUNCTION "function0module-name' IN BACKGROUND TASK DESTINATION "DEST" 
    --that means you are sending data to another r/3 sytem or any other sytem XI or and EDI
    using detination from 'DEST'..
    for 1 and 2..
    --go to t-code SM59 and see the DEST what type of connection is and what system it is connected..
    Regards,
    Prabhudas

Maybe you are looking for