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

Similar Messages

  • 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

  • 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

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

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

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

  • CALL FUNCTION IN BACKGROUND TASK - enable tRFC

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

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

  • Qs about call FM in background task, and monitoring in SM37.

    Hi, guys, i got a question here, if I call a FM using addition "in background task" in a Z program, does this mean the FM process is running in background? And can I monitor my task in sm37?
    i've tried to do that, the FM was successfully proceeded, but I cannot see anything related to that task in SM37 under mine user ID.

    No, you cannot see that in SM37.
    What it means is that the function is being executed in a seprated thread and the program that called the function will continue the execution without waiting for the function finish execution, that means the function is called in a synchronous manner.
    Regards,
    Ravi
    Note : Please mark all the helpful answers

  • 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 in Background Task

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

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

  • Creation of Spool for a Report Output in background.

    Hi Gurus,
    I am working on a Report and my requirement is that a Spool should be Generated for the Report Output in background. Instead of generating the spool manually, I need it to be generated in background.
    Please let me know ASAP.
    Regards,
    Amit.

    Get print parameters using 'GET_PRINT_PARAMETERS'.
      DATA : rep LIKE pri_params-plist,
    w_title TYPE tsp01-rqtitle,
    mstr_print_parms LIKE pri_params.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING destination           = 'LP01'
                  copies                = 1
                  list_name             = rep
                  list_text             = w_title
                  immediately           = 'X'
                  release               = 'X'
                  new_list_id           = 'X'
                  expiration            = 1
                  line_size             = 132
                  line_count            = 65
                  layout                = 'X_65_132'
                  sap_cover_page        = 'X'
                  cover_page            = ' '
                  receiver              = sy-uname
                  department            = 'System'
                  no_dialog             = 'X'
        IMPORTING out_parameters        =  mstr_print_parms
      valid = mc_valid.
    and then use submit statement-
      SUBMIT
      zp1012_ar_rep_vendstat
      TO SAP-SPOOL
      WITHOUT SPOOL DYNPRO
              SPOOL PARAMETERS mstr_print_parms
      WITH s_lifnr IN s_lifnr
      WITH p_bukrs eq p_bukrs
      WITH s_gjahr eq p_gjahr SIGN 'I'
      WITH s_monat BETWEEN p_per-low AND p_per-high SIGN 'I'
                       AND RETURN.
      COMMIT WORK.
    Regards,
    Aparna Gaikwad

  • General BADi question:Call BADi in background job/batch input. Possible?

    Hi out there,
    i'm using thoe following BADi: /SAPSLL/CTRL_SD0C_R3 (Global Trade Service).
    But also, this question is a general question.
    If we are calling on screen the transaction VF01, the BADi is called correctly.
    But unfortunately it seemes that the BADi is NOT called (im not really sure, cause i can't debug the background task) when we are calling a batch input sequence wth f.e. form bdc_transaction VF01 nothing happens.
    Maybe BADi cannot be called in a background task? If it's possible, how could it be monitored. Thare isw no spool entry or anything like that!
    Any answer can help.
    Thank you in advance!
    Regards,
    Timo
    Edited by: Timo Ehl on Apr 14, 2009 7:27 PM

    Hi,
    generally BADIs are called in background mode. You can use the following trick to debug your BADI. You just need to create an infinite loop in your BADI implementation. Something like this.
    DATA: l_a TYPE c.
    WHILE l_a IS INITIAL.
    ENDWHILE.
    Obviously when your BADI is called in background mode then program will get into infinite loop. You can easily connect and debug running programs from transaction SM50. You need to select your background process and go to Program/Session -> Program -> Debugging. You will jump directly into your BADI methos with infinite loop. Then you will just set value to l_a and you will start debugging your BADI. If you can not find any process then your BADI is not called in background mode.
    Cheers

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

    Hi All,
    Please tell me the method how to use FM IN Backgorund job(only  IN BACKGROUND UNIToref)
    CALL FUNCTION IN BACKGROUND UNIToref.
    it would be better if give practical example.
    Regards,
    Anuj jain

    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

  • Call FM remotely in Background task

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

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

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

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

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

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

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

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

Maybe you are looking for