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

Similar Messages

  • The webdynpro/ABAP (WDA) calling RFC enabled FM of other ECC systems

    The webdynpro/ABAP (WDA) has problem calling RFC enabled FM of other ECC systems.
    WDA expects all the ABAPs, RFC FMs  of remote system(DEV, QA..) to reside inside its own instance.
    It is hard to transport and maintain these ABAPs FMs into a portal ABAP WDA instance.
    Proxy generation at WDA client:
    =======================
    1. If we can make an XI enable  an ABAP or RFC enabled FM of the remote ECC,
    I think the XI proxy classes can be generated at the client WDA system.
    Other options?
    How do I do it?  Can you give some tips.
    2. How do I manually code the RFC Call to BAPI/FM from Webdynpro controller or other interface?
    I am stuck with the above as the webservice option is not available at our ECC server.  It does not have a java engine installed for webservice to be available.
    Can you help on the above 2 options?

    Hi Mike ,
    <b><b> Answer of 2.</b></b>
    How do I manually code the RFC Call to BAPI/FM from Webdynpro controller or other interface?
    I am doing same thing for my current SRM implementation.I am taking data to SRM server from another R/3 server .
    This is solution I have used
    1) First of all I have made ABAP connection in SM59 .
    Go to SM59 .In ABAP Connection creat ABAP connection with system with which u want communicate .
    Eg I am connection with Systems PB1.
    So i developed Connection call PB1CLNT800.
    2) In my requirement I have taken data in my context from another r/3,
    I have give called RFC in my supply function of node.
    Call to RFC is as usual.
    In my case,
    CALL FUNCTION 'RFC_MATNR'
    DESTINATION 'PB1CLNT800'
    TABLES
    IT_MATNR = IT_MATNR.
    Onwards I have read my itab IT_MATNR and populated data to context.
    Hope solution will serve your purpose.
    Give point if it works .If any problem i have other ways.
    Cheers
    Parry B

  • How to enable Here Drive background task on WP8 Lu...

    Is there anyone who can enable the disabled Here Drive background task? I could enable all other background tasks, but not Here Drive...
    Restarted the phone and Here Drive a few times, Turn background tasks back on for this app the next time I open it checbox is still checked, but no success...
    The silence will fall
    Solved!
    Go to Solution.

    cjlim wrote:
    I have Here Drive+ enabled in Background Task on all my phones.
    Did you try disabling and re-enabling it again? 
    The silence will fall

  • 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

  • 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

  • Call RFC enabled function from within VBA in BI 7.0

    Hello Experts,
    the problem that we have should be general, i have found some postings on this forum concerning it, but unfortunately no proper solutiont.
    I just want to have the possibility to call the rfc enabled function module from within the callback function in VBA after executing of some query.
    I have seen the suggestion to build a new RFC connection in VBA, but therefore you should hard-code all connection parameters (including user + password)
    in the VBA code, this solution is for us not acceptable due to the security reasons.
    Is there some way to use the existing connection of BEx Analyser in order to execute the function calls?
    This functionality was possible in 3.5 but not in 7.0 since many functions that were available in 3.5 are not supported now.
    Do you have experience/suggestions for this problem?
    Any help would be great.
    Thanks a lot,
    Kirill

    I've got the same problem. Did you find the solution?
    Thank you,

  • Problem with String parameters while Calling RFC enabled Function Module

    Hi all,
    I execute BAPI(RFC enabled Function Module) from my WebDynpro Application and retrieve data from R/3.
    To fetch the data I pass few String parameters to BAPI from my Dynpro Application.
    Now the problem is that while making this call, the parameters are automatically converted to UpperCase. And I want those parameters in the original case at R/3.
    I am not able to find out whether this conversion occurs at Dynpro side or R/3 Side.
    Should i configure my BAPI(RFC enabled Function Module) or is there some option on the Dynpro Side to preserve the Case of the String?
    Please help me.
    Thanks,
    Darshil

    Hi Darshil,
    I'm not sure whether you have experience with ABAP or you are a Java Programmer, but we cannot set that flag permanently.
    Now, if you are saying that the domains are marked with the <i>Lowercase</i> attribute, then it means that the final table field will be capable of holding Case Sensitive data.
    I have a hunch that the case-conversion is happenning at the Web-Dynpro side. Or, the application logic converts the string to UPPERCASE explicitly.
    By the way, which BAPI are you talking about ?
    Regards,
    Anand Mandalika.

  • Calling RFC-enabled function as web service using XI 3.0

    Hi,
    I have a problem when trying to use web services (sending a soap-req. to XI 3.0 based on the generated WSDL from Integration Directory).
    According to the message monitoring, all steps in the central pipeline executes just fine until the last step - CALL ADAPTER.
    I don't think this is an authorization issue since I have tested the XIISUSER/pwd against the URL for adapter engine.
    Seems to me that the problem is related to the msg sent to AE:
    "HTTP response contains status code 401 with the description Unauthorized XML tag Envelope missing in SOAP message header (SAP XI Extension)"
    How to proceed from here?

    Hi Torstein,
    <i>Seems to me that the problem is related to the msg sent to AE:
    "HTTP response contains status code 401 with the description Unauthorized XML tag Envelope missing in SOAP message header (SAP XI Extension)"
    </i>
    According to you, the problem occurs within the SOAP envelope. Does your incoming SOAP message looks like the one below here?
    If that's not the case, then make sure your SOAP/Web Service client is sending a valid SOAP envelope/request (like the sample below) to XI.
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <!--  Inbound Message -->
    <SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>
    <SOAP:Header/>
    <SOAP:Body>
    <ns1:WebServiceRequest xmlns:ns1='http://company.com/xi/webservice/myws' SOAP:actor='http://schemas.xmlsoap.org/soap/encoding/' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <Customer xsi:type='xsd:string'>000025</Customer>
    <CompanyCode xsi:type='xsd:string'>BE01</CompanyCode>
    <KeyDate xsi:type='xsd:string'>20050310</KeyDate>
    <Selection>
    <OpenItems xsi:type='xsd:string'>X</OpenItems>
    <ClearItems xsi:type='xsd:string'></ClearItems>
    <GLItems xsi:type='xsd:string'></GLItems>
    <Dunning>
    <From xsi:type='xsd:string'>A</From>
    <To xsi:type='xsd:string'>Z</To>
    </Dunning>
    </Selection>
    </ns1:WebServiceRequest>
    </SOAP:Body>
    </SOAP:Envelope>
    Cheers,
    R.

  • 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

  • RFC  IN  BACKGROUND TASK

    Hai all,
    I created RFC 'ZBAPI_BACKPROCES' .
    And Im using this RFC in my ABAP program.
    BUT I having to call this FUNCTION MODULE in background Task .But I dont know how its working and also this FM does not returning any values.
    Can anyone Say  example with explaination (how its working).
    Thanks In Advance.
    regards,
    Ekadevi.S

    Here's a good explanation of the RFC types:
    [Master the five remote function call (RFC) types in ABAP|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f078394a-4469-2910-c4bf-853c75674694]
    Tim

  • 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

  • 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

  • Function Module MASTER_IDOC_DISTRIBUTE to be called in background task?

    Hi,
    We are generating outbound Idocs in a report. In this report we are using Function Module Master_Idoc_Distribute. Now we have faced some performance issues and the basis consultant is asking us to:
    Call the function module using CALL FUNCTION Master_Idoc_Distribute IN BACKGROUND TASK.
    1) How will calling the FM Master_IDOC_Distribute in background task help improve the performance?
    2) By calling the function module in background task, will it have any impact on the sequencing of the idocs? If yes what is the way out, as the idoc sequence is very important.
    Thanks in advance,
    Mick

    1) How will calling the FM Master_IDOC_Distribute in background task help improve the performance?
    ->Calling the FM in background task will help in performance as it will be called in the background process mode like a tRFC.So it will not occupy any dialog process which are limited.
    2) By calling the function module in background task, will it have any impact on the sequencing of the idocs? If yes what is the way out, as the idoc sequence is very important.
    ->It will not have any impact on IDoc sequence.

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

  • 'Missing parameter with PERFORM' error with a function IN BACKGROUND TASK

    I am getting this error when calling a custom function in MIGO user exit ZXMBCU01.  When I remove the 'IN BACKGROUND TASK' the function works fine and there are no error messages.  When using 'IN BACK...' you can't debug within it to see where the message comes from.  I see the message with SM58.  I am working in an sap 4.7 environment.  I have not found any solutions from google searches.
    Here is the statement within ZXMBCU01:
        CALL FUNCTION 'Z_UPDATE_MATERIAL_AVAIL_STATUS' IN BACKGROUND TASK
          EXPORTING
            work_order = xmseg-aufnr.
    Here is the code for the function:
    FUNCTION Z_UPDATE_MATERIAL_AVAIL_STATUS.
    ""Update function module:
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(WORK_ORDER) LIKE  AUFK-AUFNR DEFAULT '0000000000'
    TABLES: eban, resb, aufk.
    -Global Types----
    TYPES: BEGIN OF t_data,
           rsnum TYPE resb-rsnum,
           rspos TYPE resb-rspos,
           aufnr TYPE resb-aufnr,          "Order Number
           bdmng TYPE resb-bdmng,          "Requirement Quantity
           enmng TYPE resb-enmng,          "Quantity withdrawn
           bsmng TYPE eban-bsmng,          "Quantity ordered against this purchase requisition
           END OF t_data.
    DATA:  gt_data TYPE t_data OCCURS 0,
           ga_data TYPE t_data.
    -Global Variables----
    DATA: gv_refused TYPE BAPIFLAG-BAPIFLAG,
          gs_caufvd  TYPE caufvd,
          g_text TYPE t100-text,
          gv_objnr LIKE aufk-objnr,
          gv_status LIKE  bsvx-sttxt,
          gv_trig_stat TYPE c.
    TABLES RETURNED FROM BAPI
    DATA:  BEGIN OF xreturn OCCURS 0.
            INCLUDE STRUCTURE bapiret2.
    DATA:  END OF xreturn.
      SELECT SINGLE objnr FROM aufk
         INTO gv_objnr
         WHERE  aufnr = work_order.
      CALL FUNCTION 'STATUS_TEXT_EDIT'
        EXPORTING
          flg_user_stat = 'X'
          objnr         = gv_objnr
          only_active   = 'X'
          spras         = sy-langu
        IMPORTING
          line          = gv_status.
      IF ( gv_status CS 'REL' ) AND
         ( gv_status NS 'NMAT' AND gv_status NS 'CNF' AND gv_status NS 'CLSD' AND
           gv_status NS 'TECO' AND gv_status NS 'DLFL' ).
        SELECT SINGLE *
          FROM AUFK
         WHERE aufnr = work_order AND
               ( auart = 'PM01' OR
                 auart = 'PM02' OR
                 auart = 'PM03' OR
                 auart = 'PM99' ).
        IF sy-subrc = 0.
          SELECT resbrsnum resbrspos resbaufnr resbbdmng resbenmng ebanbsmng
            INTO CORRESPONDING FIELDS OF ga_data
            FROM resb LEFT JOIN eban
              ON resbrsnum = ebanarsnr AND
                 resbrspos = ebanarsps
           WHERE resb~aufnr = work_order AND
                 resb~bdmng > 0.
        SELECT rsnum rspos aufnr bdmng enmng
          INTO CORRESPONDING FIELDS OF ga_data
          FROM resb
         WHERE aufnr = work_order
           AND bdmng > 0.
              SELECT SINGLE bsmng
                INTO ga_data-bsmng
                FROM eban
               WHERE arsnr = ga_data-rsnum
                 AND arsps = ga_data-rspos.
              IF sy-subrc <> 0.
                CLEAR ga_data-bsmng.
              ENDIF.
               IF ga_data-bdmng = ga_data-enmng OR
                  ga_data-bdmng = ga_data-bsmng.
                 "update status - but all items must pass
               ELSE.
                 gv_trig_stat = 'N'.
                 EXIT. "status won't change so get out now
               ENDIF.
         ENDSELECT.
       IF ga_data~bdmng > 0.
           IF ga_data-bdmng = ga_data-enmng OR
              ga_data-bdmng = ga_data-bsmng.
         IF gv_trig_stat <> 'N'.
              CALL FUNCTION 'CO_IH_USERSTATUS_SET'
                EXPORTING
                  I_AUFNR              = ga_data-aufnr    "'000005000263'
                  I_USR_STAT_INT       = 'E0002'
      I_USR_STAT_EXT       =
      I_SET_INACTIVE       =
      I_BUF_READ           =
                  I_SPRAS              = sy-langu
                IMPORTING
                  E_CHNG_REFUSED       = gv_refused
                  E_CAUFVD             = gs_caufvd
                TABLES
                  RETURN               = xreturn.
              LOOP AT xreturn
               WHERE type = 'E'.
              ENDLOOP.
              IF sy-subrc <> 0.
                CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
                RETURN.
              ELSE.
                READ TABLE xreturn INDEX 1.
                CALL FUNCTION 'PI_BP_GET_MESSAGE_TEXT'
                  EXPORTING
                    iv_message_id     = xreturn-id
                    iv_message_type   = xreturn-type
                    iv_message_number = xreturn-number
                    iv_message_v1     = xreturn-message_v1
                    iv_message_v2     = xreturn-message_v2
                    iv_message_v3     = xreturn-message_v3
                    iv_message_v4     = xreturn-message_v4
                  IMPORTING
                    ev_message_text   = g_text.
              ENDIF.
         ENDIF.
         ENDIF.
           ENDIF.
         ENDSELECT.
        ENDIF.
      ENDIF.
    ENDFUNCTION.
    Does anyone have any ideas?  Thank you very much in advance.
    Glenn Allen
    Software Architect (specializing in SAP)

    I'd be starting a process of elimination... perhaps start with an "exit." right after
    SELECT SINGLE objnr
      FROM aufk
      INTO gv_objnr
      WHERE aufnr = work_order.
    exit.  "leave FM NOW
    and if that doesn't crash, work down the code down the code in the function e.g. comment out the BAPI_commit call... and / or build a little test harness report to call the Z function in background task... btw, does the ST22 dump point to anything more specific...?

Maybe you are looking for